Package com.jidesoft.plaf.basic
Class BasicStyledLabelUI
- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.LabelUI
-
- javax.swing.plaf.basic.BasicLabelUI
-
- com.jidesoft.plaf.basic.BasicStyledLabelUI
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,javax.swing.SwingConstants
public class BasicStyledLabelUI extends javax.swing.plaf.basic.BasicLabelUI implements javax.swing.SwingConstants
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<StyleRange>
_comparator
protected static BasicStyledLabelUI
styledLabelUI
-
Constructor Summary
Constructors Constructor Description BasicStyledLabelUI()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
buildStyledText(StyledLabel label)
static javax.swing.plaf.ComponentUI
createUI(javax.swing.JComponent c)
protected java.awt.Font
getFont(StyledLabel label)
Gets the font from the label.protected java.awt.Dimension
getPreferredSize(StyledLabel label)
Gets the preferred size of the text portion of the StyledLabel including the icon.java.awt.Dimension
getPreferredSize(javax.swing.JComponent c)
protected java.lang.String
layoutCL(javax.swing.JLabel label, java.awt.FontMetrics fontMetrics, java.lang.String text, javax.swing.Icon icon, java.awt.Rectangle viewR, java.awt.Rectangle iconR, java.awt.Rectangle textR)
static java.lang.String
layoutCompoundLabel(java.awt.FontMetrics fm, java.lang.String text, javax.swing.Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, java.awt.Rectangle viewR, java.awt.Rectangle iconR, java.awt.Rectangle textR, int textIconGap)
Compute and return the location of the icons origin, the location of origin of the text baseline, and a possibly clipped version of the compound labels string.static java.lang.String
layoutCompoundLabel(javax.swing.JComponent c, java.awt.FontMetrics fm, java.lang.String text, javax.swing.Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, java.awt.Rectangle viewR, java.awt.Rectangle iconR, java.awt.Rectangle textR, int textIconGap)
Compute and return the location of the icons origin, the location of origin of the text baseline, and a possibly clipped version of the compound labels string.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
paintStyledText(StyledLabel label, java.awt.Graphics g, int textX, int textY)
void
propertyChange(java.beans.PropertyChangeEvent e)
-
Methods inherited from class javax.swing.plaf.basic.BasicLabelUI
getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, installComponents, installDefaults, installKeyboardActions, installListeners, installUI, paint, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI
-
-
-
-
Field Detail
-
_comparator
public static java.util.Comparator<StyleRange> _comparator
-
styledLabelUI
protected static BasicStyledLabelUI styledLabelUI
-
-
Method Detail
-
createUI
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
- Overrides:
propertyChange
in classjavax.swing.plaf.basic.BasicLabelUI
-
paintEnabledText
protected void paintEnabledText(javax.swing.JLabel l, java.awt.Graphics g, java.lang.String s, int textX, int textY)
- Overrides:
paintEnabledText
in classjavax.swing.plaf.basic.BasicLabelUI
-
paintDisabledText
protected void paintDisabledText(javax.swing.JLabel l, java.awt.Graphics g, java.lang.String s, int textX, int textY)
- Overrides:
paintDisabledText
in classjavax.swing.plaf.basic.BasicLabelUI
-
buildStyledText
protected void buildStyledText(StyledLabel label)
-
getPreferredSize
public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
- Overrides:
getPreferredSize
in classjavax.swing.plaf.basic.BasicLabelUI
-
layoutCL
protected java.lang.String layoutCL(javax.swing.JLabel label, java.awt.FontMetrics fontMetrics, java.lang.String text, javax.swing.Icon icon, java.awt.Rectangle viewR, java.awt.Rectangle iconR, java.awt.Rectangle textR)
- Overrides:
layoutCL
in classjavax.swing.plaf.basic.BasicLabelUI
-
getPreferredSize
protected java.awt.Dimension getPreferredSize(StyledLabel label)
Gets the preferred size of the text portion of the StyledLabel including the icon.- Parameters:
label
- the StyledLabel- Returns:
- the preferred size.
-
getFont
protected java.awt.Font getFont(StyledLabel label)
Gets the font from the label.- Parameters:
label
- the label.- Returns:
- the font. If label's getFont is null, we will use Label.font instead.
-
paintStyledText
protected void paintStyledText(StyledLabel label, java.awt.Graphics g, int textX, int textY)
-
layoutCompoundLabel
public static java.lang.String layoutCompoundLabel(javax.swing.JComponent c, java.awt.FontMetrics fm, java.lang.String text, javax.swing.Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, java.awt.Rectangle viewR, java.awt.Rectangle iconR, java.awt.Rectangle textR, int textIconGap)
Compute and return the location of the icons origin, the location of origin of the text baseline, and a possibly clipped version of the compound labels string. Locations are computed relative to the viewR rectangle. The JComponents orientation (LEADING/TRAILING) will also be taken into account and translated into LEFT/RIGHT values accordingly.- Parameters:
c
- the componentfm
- the font metricstext
- the texticon
- the iconverticalAlignment
- vertical alignment modehorizontalAlignment
- horizontal alignment modeverticalTextPosition
- vertical text positionhorizontalTextPosition
- horizontal text positionviewR
- view rectangleiconR
- icon rectangletextR
- text rectangletextIconGap
- the gap between text and icon- Returns:
- the layout string
-
layoutCompoundLabel
public static java.lang.String layoutCompoundLabel(java.awt.FontMetrics fm, java.lang.String text, javax.swing.Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, java.awt.Rectangle viewR, java.awt.Rectangle iconR, java.awt.Rectangle textR, int textIconGap)
Compute and return the location of the icons origin, the location of origin of the text baseline, and a possibly clipped version of the compound labels string. Locations are computed relative to the viewR rectangle. This layoutCompoundLabel() does not know how to handle LEADING/TRAILING values in horizontalTextPosition (they will default to RIGHT) and in horizontalAlignment (they will default to CENTER). Use the other version of layoutCompoundLabel() instead.- Parameters:
fm
- the font metricstext
- the texticon
- the iconverticalAlignment
- vertical alignment modehorizontalAlignment
- horizontal alignment modeverticalTextPosition
- vertical text positionhorizontalTextPosition
- horizontal text positionviewR
- view rectangleiconR
- icon rectangletextR
- text rectangletextIconGap
- the gap between text and icon- Returns:
- the layout string
-
-