Groovy Documentation

com.wordpress.tipsforjava.swing.plaf
[Java] Class VerticalLabelUI

java.lang.Object
  javax.swing.plaf.ComponentUI
      javax.swing.plaf.LabelUI
          javax.swing.plaf.basic.BasicLabelUI
              com.wordpress.tipsforjava.swing.plaf.VerticalLabelUI

public class VerticalLabelUI
extends BasicLabelUI

A UI delegate for JLabel that rotates the label 90 degrees

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.

Authors:
Rob Camick
Darryl Burke


Field Summary
private static VerticalLabelUI SAFE_VERTICAL_LABEL_UI

private boolean clockwise

Rectangle verticalIconR

protected static VerticalLabelUI verticalLabelUI

Rectangle verticalTextR

Rectangle verticalViewR

 
Constructor Summary
VerticalLabelUI()

Constructs a VerticalLabelUI with the default anticlockwise rotation

VerticalLabelUI(boolean clockwise)

Constructs a VerticalLabelUI with the desired rotation.

 
Method Summary
private Rectangle copyRectangle(Rectangle from, Rectangle to)

static ComponentUI createUI(JComponent c)

@see ComponentUI#createUI(javax.swing.JComponent)

int getBaseline(JComponent c, int width, int height)

Overridden to always return -1, since a vertical label does not have a meaningful baseline.

Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)

Overridden to always return Component.BaselineResizeBehavior.OTHER, since a vertical label does not have a meaningful baseline

Dimension getMaximumSize(JComponent c)

Returns a Dimension appropriate for vertical rendering

Dimension getMinimumSize(JComponent c)

Returns a Dimension appropriate for vertical rendering

Dimension getPreferredSize(JComponent c)

Returns a Dimension appropriate for vertical rendering

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 by SwingUtilities.layoutCompoundLabel

void paint(Graphics g, JComponent c)

Transforms the Graphics for vertical rendering and invokes the super method.

private Dimension transposeDimension(Dimension from)

private Rectangle transposeRectangle(Rectangle from, Rectangle to)

 
Methods inherited from class BasicLabelUI
getPreferredSize, getMinimumSize, getMaximumSize, paint, getBaseline, getBaselineResizeBehavior, installUI, uninstallUI, propertyChange, createUI, contains, update, getAccessibleChildrenCount, getAccessibleChild, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 
Methods inherited from class LabelUI
contains, update, getPreferredSize, getMinimumSize, getMaximumSize, paint, getAccessibleChildrenCount, getAccessibleChild, getBaseline, getBaselineResizeBehavior, installUI, uninstallUI, createUI, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

SAFE_VERTICAL_LABEL_UI

private static final VerticalLabelUI SAFE_VERTICAL_LABEL_UI


clockwise

private boolean clockwise


verticalIconR

Rectangle verticalIconR


verticalLabelUI

protected static VerticalLabelUI verticalLabelUI


verticalTextR

Rectangle verticalTextR


verticalViewR

Rectangle verticalViewR


 
Constructor Detail

VerticalLabelUI

public VerticalLabelUI()
Constructs a VerticalLabelUI with the default anticlockwise rotation


VerticalLabelUI

public VerticalLabelUI(boolean clockwise)
Constructs a VerticalLabelUI with the desired rotation.

Parameters:
clockwise - true to rotate clockwise, false for anticlockwise


 
Method Detail

copyRectangle

private Rectangle copyRectangle(Rectangle from, Rectangle to)


createUI

public static ComponentUI createUI(JComponent c)
See Also:
ComponentUI#createUI(javax.swing.JComponent)


getBaseline

@Override
public int getBaseline(JComponent c, int width, int height)
Overridden to always return -1, since a vertical label does not have a meaningful baseline.
See Also:
ComponentUI.getBaseline


getBaselineResizeBehavior

@Override
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
Overridden to always return Component.BaselineResizeBehavior.OTHER, since a vertical label does not have a meaningful baseline
See Also:
ComponentUI#getBaselineResizeBehavior(javax.swing.JComponent)


getMaximumSize

@Override
public Dimension getMaximumSize(JComponent c)
Returns a Dimension appropriate for vertical rendering
See Also:
ComponentUI#getMaximumSize(javax.swing.JComponent)


getMinimumSize

@Override
public Dimension getMinimumSize(JComponent c)
Returns a Dimension appropriate for vertical rendering
See Also:
ComponentUI#getMinimumSize(javax.swing.JComponent)


getPreferredSize

@Override
public Dimension getPreferredSize(JComponent c)
Returns a Dimension appropriate for vertical rendering
See Also:
ComponentUI#getPreferredSize(javax.swing.JComponent)


layoutCL

@Override
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 by SwingUtilities.layoutCompoundLabel


paint

@Override
public void paint(Graphics g, JComponent c)
Transforms the Graphics for vertical rendering and invokes the super method.


transposeDimension

private Dimension transposeDimension(Dimension from)


transposeRectangle

private Rectangle transposeRectangle(Rectangle from, Rectangle to)


 

Groovy Documentation