|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.plaf.ComponentUI javax.swing.plaf.LabelUI javax.swing.plaf.basic.BasicLabelUI com.alee.extended.label.WebMultiLineLabelUI
public class WebMultiLineLabelUI
Label UI delegate that supports multiple lines and line wrapping. Hard line breaks (\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
).
Nested Class Summary | |
---|---|
protected static class |
WebMultiLineLabelUI.SegmentCache
Static singleton Segment cache. |
Field Summary | |
---|---|
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. |
Fields inherited from class javax.swing.plaf.basic.BasicLabelUI |
---|
labelUI |
Constructor Summary | |
---|---|
WebMultiLineLabelUI()
|
Method Summary | |
---|---|
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. |
Methods inherited from class javax.swing.plaf.basic.BasicLabelUI |
---|
getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, installComponents, installDefaults, installKeyboardActions, layoutCL, uninstallComponents, uninstallKeyboardActions, uninstallUI |
Methods inherited from class javax.swing.plaf.ComponentUI |
---|
contains, getAccessibleChild, getAccessibleChildrenCount, update |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public 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
Constructor Detail |
---|
public WebMultiLineLabelUI()
Method Detail |
---|
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
c
- the component about to be installed
public void installUI(javax.swing.JComponent c)
installUI
in class javax.swing.plaf.basic.BasicLabelUI
protected void uninstallDefaults(javax.swing.JLabel c)
uninstallDefaults
in class javax.swing.plaf.basic.BasicLabelUI
protected void installListeners(javax.swing.JLabel c)
installListeners
in class javax.swing.plaf.basic.BasicLabelUI
protected void uninstallListeners(javax.swing.JLabel c)
uninstallListeners
in class javax.swing.plaf.basic.BasicLabelUI
public 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.PropertyChangeListener
propertyChange
in class javax.swing.plaf.basic.BasicLabelUI
protected 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.BasicLabelUI
protected 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.BasicLabelUI
protected 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.BasicLabelUI
protected int getAvailableHeight(javax.swing.JLabel l)
l
- a component
protected java.lang.String clip(java.lang.String text)
text
- the to be painted
protected int alignmentY(javax.swing.JLabel label, java.awt.FontMetrics fm, java.awt.Rectangle bounds)
label
- the label to paintfm
- font metricsbounds
- the text bounds rectangle
protected int alignmentX(javax.swing.JLabel label, java.awt.FontMetrics fm, java.lang.String s)
label
- the label to paintfm
- font metricss
- the string to paint
public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
getPreferredSize
in class javax.swing.plaf.basic.BasicLabelUI
protected int getPreferredHeight(javax.swing.JLabel label)
label
- the label
protected java.util.List<java.lang.String> getTextLines(javax.swing.JLabel l)
PROPERTY_KEY
.
l
- the label
public void componentHidden(java.awt.event.ComponentEvent e)
componentHidden
in interface java.awt.event.ComponentListener
public void componentMoved(java.awt.event.ComponentEvent e)
componentMoved
in interface java.awt.event.ComponentListener
public void componentResized(java.awt.event.ComponentEvent e)
componentResized
in interface java.awt.event.ComponentListener
public void componentShown(java.awt.event.ComponentEvent e)
componentShown
in interface java.awt.event.ComponentListener
protected java.util.List<java.lang.String> prepareLines(javax.swing.JLabel l)
l
- the label to render
protected 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 position
p1
if content does not need to wrap, otherwise it will be less than
p1
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |