public class WebMultiLineLabelUI
extends javax.swing.plaf.basic.BasicLabelUI
implements java.awt.event.ComponentListener
\n) are preserved. If the dimensions of
the label is too small to fit all content, the string will be clipped and "..." appended to the end of the visible text (similar to the
default behavior of JLabel).| Modifier and Type | Class and Description |
|---|---|
protected static class |
WebMultiLineLabelUI.SegmentCache
Static singleton
Segment cache. |
| Modifier and Type | Field and Description |
|---|---|
protected static java.awt.Rectangle |
paintIconR |
protected static java.awt.Rectangle |
paintTextR |
protected static java.awt.Insets |
paintViewInsets |
protected static java.awt.Rectangle |
paintViewR |
static java.lang.String |
PROPERTY_KEY
Client property key used to store the calculated wrapped lines on the JLabel.
|
| Constructor and Description |
|---|
WebMultiLineLabelUI() |
| Modifier and Type | Method and Description |
|---|---|
protected int |
alignmentX(javax.swing.JLabel label,
java.awt.FontMetrics fm,
java.lang.String s)
Establish the horizontal text alignment.
|
protected int |
alignmentY(javax.swing.JLabel label,
java.awt.FontMetrics fm,
java.awt.Rectangle bounds)
Establish the vertical text alignment.
|
protected int |
calculateBreakPosition(javax.swing.text.Document doc,
int p0,
int p1)
Calculate the position on which to break (wrap) the line.
|
protected void |
clearCache(javax.swing.JLabel l)
Clear the wrapped line cache.
|
protected java.lang.String |
clip(java.lang.String text)
Add a clip indication to the string.
|
void |
componentHidden(java.awt.event.ComponentEvent e) |
void |
componentMoved(java.awt.event.ComponentEvent e) |
void |
componentResized(java.awt.event.ComponentEvent e) |
void |
componentShown(java.awt.event.ComponentEvent e) |
static javax.swing.plaf.ComponentUI |
createUI(javax.swing.JComponent c)
UI instance creation.
|
protected int |
getAvailableHeight(javax.swing.JLabel l)
Returns the available height to paint text on.
|
protected int |
getPreferredHeight(javax.swing.JLabel label)
The preferred height of the label is the height of the lines with added top and bottom insets.
|
java.awt.Dimension |
getPreferredSize(javax.swing.JComponent c) |
java.awt.Color |
getShadeColor() |
protected java.util.List<java.lang.String> |
getTextLines(javax.swing.JLabel l)
Get the lines of text contained in the text label.
|
protected void |
installListeners(javax.swing.JLabel c) |
void |
installUI(javax.swing.JComponent c) |
boolean |
isDrawShade()
View settings
|
void |
paint(java.awt.Graphics g,
javax.swing.JComponent c) |
protected void |
paintDisabledText(javax.swing.JLabel l,
java.awt.Graphics g,
java.lang.String s,
int textX,
int textY) |
protected void |
paintEnabledText(javax.swing.JLabel l,
java.awt.Graphics g,
java.lang.String s,
int textX,
int textY) |
protected void |
paintTextLines(java.awt.Graphics g,
javax.swing.JLabel label,
java.awt.FontMetrics fm)
Paint the wrapped text lines.
|
protected java.util.List<java.lang.String> |
prepareLines(javax.swing.JLabel l)
Prepare the text lines for rendering.
|
void |
propertyChange(java.beans.PropertyChangeEvent e) |
void |
setDrawShade(boolean drawShade) |
void |
setShadeColor(java.awt.Color shadeColor) |
protected void |
uninstallDefaults(javax.swing.JLabel c) |
protected void |
uninstallListeners(javax.swing.JLabel c) |
protected void |
updateLayout(javax.swing.JLabel l,
java.awt.FontMetrics fm,
int width,
int height)
Calculate the paint rectangles for the icon and text for the passed label.
|
protected void |
wrap(java.util.List<java.lang.String> lines,
javax.swing.text.Element elem)
If necessary, wrap the text into multiple lines.
|
getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, installComponents, installDefaults, installKeyboardActions, layoutCL, uninstallComponents, uninstallKeyboardActions, uninstallUIpublic static final java.lang.String PROPERTY_KEY
protected static java.awt.Rectangle paintIconR
protected static java.awt.Rectangle paintTextR
protected static java.awt.Rectangle paintViewR
protected static java.awt.Insets paintViewInsets
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
c - the component about to be installedpublic void installUI(javax.swing.JComponent c)
installUI in class javax.swing.plaf.basic.BasicLabelUIprotected void uninstallDefaults(javax.swing.JLabel c)
uninstallDefaults in class javax.swing.plaf.basic.BasicLabelUIprotected void installListeners(javax.swing.JLabel c)
installListeners in class javax.swing.plaf.basic.BasicLabelUIprotected void uninstallListeners(javax.swing.JLabel c)
uninstallListeners in class javax.swing.plaf.basic.BasicLabelUIpublic boolean isDrawShade()
public void setDrawShade(boolean drawShade)
public java.awt.Color getShadeColor()
public void setShadeColor(java.awt.Color shadeColor)
protected void clearCache(javax.swing.JLabel l)
l - the label containing a cached valuepublic void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange in interface java.beans.PropertyChangeListenerpropertyChange in class javax.swing.plaf.basic.BasicLabelUIprotected void updateLayout(javax.swing.JLabel l,
java.awt.FontMetrics fm,
int width,
int height)
l - a labelfm - the font metrics to use, or null to get the font metrics from the labelwidth - label widthheight - label heightpublic void paint(java.awt.Graphics g,
javax.swing.JComponent c)
paint in class javax.swing.plaf.basic.BasicLabelUIprotected void paintTextLines(java.awt.Graphics g,
javax.swing.JLabel label,
java.awt.FontMetrics fm)
g - graphics component to paint onlabel - the label being paintedfm - font metrics for current fontprotected void paintEnabledText(javax.swing.JLabel l,
java.awt.Graphics g,
java.lang.String s,
int textX,
int textY)
paintEnabledText in class javax.swing.plaf.basic.BasicLabelUIprotected void paintDisabledText(javax.swing.JLabel l,
java.awt.Graphics g,
java.lang.String s,
int textX,
int textY)
paintDisabledText in class javax.swing.plaf.basic.BasicLabelUIprotected int getAvailableHeight(javax.swing.JLabel l)
l - a componentprotected java.lang.String clip(java.lang.String text)
text - the to be paintedprotected int alignmentY(javax.swing.JLabel label,
java.awt.FontMetrics fm,
java.awt.Rectangle bounds)
label - the label to paintfm - font metricsbounds - the text bounds rectangleprotected int alignmentX(javax.swing.JLabel label,
java.awt.FontMetrics fm,
java.lang.String s)
label - the label to paintfm - font metricss - the string to paintpublic java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
getPreferredSize in class javax.swing.plaf.basic.BasicLabelUIprotected int getPreferredHeight(javax.swing.JLabel label)
label - the labelprotected java.util.List<java.lang.String> getTextLines(javax.swing.JLabel l)
PROPERTY_KEY.l - the labelpublic void componentHidden(java.awt.event.ComponentEvent e)
componentHidden in interface java.awt.event.ComponentListenerpublic void componentMoved(java.awt.event.ComponentEvent e)
componentMoved in interface java.awt.event.ComponentListenerpublic void componentResized(java.awt.event.ComponentEvent e)
componentResized in interface java.awt.event.ComponentListenerpublic void componentShown(java.awt.event.ComponentEvent e)
componentShown in interface java.awt.event.ComponentListenerprotected java.util.List<java.lang.String> prepareLines(javax.swing.JLabel l)
l - the label to renderprotected void wrap(java.util.List<java.lang.String> lines,
javax.swing.text.Element elem)
lines - line array in which to store the wrapped lineselem - the document element containing the text contentprotected int calculateBreakPosition(javax.swing.text.Document doc,
int p0,
int p1)
doc - the documentp0 - start positionp1 - end positionp1 if content does not need to wrap, otherwise it will be less than
p1.