Package cnuphys.splot.plot
Class VerticalLabelUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.LabelUI
javax.swing.plaf.basic.BasicLabelUI
cnuphys.splot.plot.VerticalLabelUI
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
A UI delegate for JLabel that rotates the label 90 deg
Extends BasicLabelUI
.
The only difference between the appearance of labels in the Basic and Metal L&Fs is the manner in which diabled text is painted. As VerticalLabelUI does not override the method paintDisabledText, this class can be adapted for Metal L&F by extending MetalLabelUI instead of BasicLabelUI.
No other changes are required.
- Author:
- Darryl
-
Field Summary
FieldsFields inherited from class javax.swing.plaf.basic.BasicLabelUI
labelUI
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aVerticalLabelUI
with the default anticlockwise rotationVerticalLabelUI
(boolean clockwise) Constructs aVerticalLabelUI
with the desired rotation. -
Method Summary
Modifier and TypeMethodDescriptionstatic ComponentUI
int
getBaseline
(JComponent c, int width, int height) Overridden to always return -1, since a vertical label does not have a meaningful baseline.Overridden to always return Component.BaselineResizeBehavior.OTHER, since a vertical label does not have a meaningful baselineReturns a Dimension appropriate for vertical renderingReturns a Dimension appropriate for vertical renderingReturns a Dimension appropriate for vertical renderingprotected String
layoutCL
(JLabel label, FontMetrics fontMetrics, String text, Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR) Transposes the view rectangles as appropriate for a vertical view before invoking the super method and copies them after they have been altered bySwingUtilities#layoutCompoundLabel(FontMetrics, String, Icon, int, int, int, int, Rectangle, Rectangle, Rectangle, int)
void
paint
(Graphics g, JComponent c) Transforms the Graphics for vertical rendering and invokes the super method.Methods inherited from class javax.swing.plaf.basic.BasicLabelUI
installComponents, installDefaults, installKeyboardActions, installListeners, installUI, paintDisabledText, paintEnabledText, propertyChange, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, update
-
Field Details
-
verticalLabelUI
-
-
Constructor Details
-
VerticalLabelUI
public VerticalLabelUI()Constructs aVerticalLabelUI
with the default anticlockwise rotation -
VerticalLabelUI
public VerticalLabelUI(boolean clockwise) Constructs aVerticalLabelUI
with the desired rotation.- Parameters:
clockwise
- true to rotate clockwise, false for anticlockwise
-
-
Method Details
-
createUI
-
getBaseline
Overridden to always return -1, since a vertical label does not have a meaningful baseline.- Overrides:
getBaseline
in classBasicLabelUI
- See Also:
-
getBaselineResizeBehavior
Overridden to always return Component.BaselineResizeBehavior.OTHER, since a vertical label does not have a meaningful baseline- Overrides:
getBaselineResizeBehavior
in classBasicLabelUI
- See Also:
-
layoutCL
protected String layoutCL(JLabel label, FontMetrics fontMetrics, String text, Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR) Transposes the view rectangles as appropriate for a vertical view before invoking the super method and copies them after they have been altered bySwingUtilities#layoutCompoundLabel(FontMetrics, String, Icon, int, int, int, int, Rectangle, Rectangle, Rectangle, int)
- Overrides:
layoutCL
in classBasicLabelUI
-
paint
Transforms the Graphics for vertical rendering and invokes the super method.- Overrides:
paint
in classBasicLabelUI
-
getPreferredSize
Returns a Dimension appropriate for vertical rendering- Overrides:
getPreferredSize
in classBasicLabelUI
- See Also:
-
getMaximumSize
Returns a Dimension appropriate for vertical rendering- Overrides:
getMaximumSize
in classBasicLabelUI
- See Also:
-
getMinimumSize
Returns a Dimension appropriate for vertical rendering- Overrides:
getMinimumSize
in classBasicLabelUI
- See Also:
-