com.threerings.opengl.gui
Class LabelRenderer

java.lang.Object
  extended by com.threerings.opengl.gui.LabelRenderer
All Implemented Interfaces:
UIConstants

public class LabelRenderer
extends Object
implements UIConstants

Handles the underlying layout and rendering for Label and Button.


Nested Class Summary
protected static class LabelRenderer.Config
           
protected static class LabelRenderer.Glyphs
           
 
Field Summary
protected  float _alpha
           
protected  LabelRenderer.Config _config
           
protected  TextComponent _container
           
protected  Label.Fit _fit
           
protected  int _gap
           
protected  Icon _icon
           
protected  int _ix
           
protected  int _iy
           
protected  int _orient
           
protected  LabelRenderer.Config _prefconfig
           
protected  Dimension _prefsize
           
protected  int _prefWidth
           
protected  Rectangle _srect
           
protected  int _textRotation
           
protected  int _tx
           
protected  int _ty
           
protected  String _value
           
 
Fields inherited from interface com.threerings.opengl.gui.UIConstants
BOTTOM, CENTER, DEFAULT_SIZE, DEFAULT_SPACING, GLOW, HORIZONTAL, LEFT, NORMAL, OUTLINE, OVERLAPPING, PLAIN, RIGHT, SHADOW, TOP, VERTICAL
 
Constructor Summary
LabelRenderer(TextComponent container)
           
 
Method Summary
 Dimension computePreferredSize(int whint, int hhint)
          Computes the preferred size of the label.
protected  Dimension computeSize(LabelRenderer.Config config)
           
protected static int getHeight(int width, int height, int rotation)
          Returns the height under the supplied rotation.
 Icon getIcon()
          Returns the icon being displayed by this label.
 int getIconTextGap()
          Returns the gap between the icon and the text.
 int getIconX()
          Returns the x coordinate of the icon.
 int getIconY()
          Returns the y coordinate of the icon.
protected static int getOffsetX(int width, int height, int rotation)
          Returns the x offset for rotating the supplied dimensions by the specified amount.
protected static int getOffsetY(int width, int height, int rotation)
          Returns the y offset for rotation the supplied dimensions by the specified amount.
 String getText()
          Returns the text currently being displayed by this label.
protected static int getWidth(int width, int height, int rotation)
          Returns the width under the supplied rotation.
protected  int getXOffset(Insets insets, int contWidth, int width)
           
protected  int getYOffset(Insets insets, int contHeight, int height)
           
 void layout(Insets insets, int contWidth, int contHeight)
          Lays out the label text and icon.
protected  LabelRenderer.Config layoutConfig(LabelRenderer.Config oconfig, int twidth)
          Creates glyphs for the current text at the specified target width.
 void render(Renderer renderer, int x, int y, int contWidth, int contHeight, float alpha)
          Renders the label text and icon.
protected  void renderText(Renderer renderer, int contWidth, int contHeight, float alpha)
           
 void setFit(Label.Fit mode)
          Configures whether this label will wrap, truncate or scale if it cannot fit text into its allotted width.
 void setIcon(Icon icon)
          Configures the label to display the specified icon.
 void setIconTextGap(int gap)
          Configures the gap between the icon and the text.
 void setOrientation(int orient)
          Sets the orientation of this label with respect to its icon.
 void setPreferredWidth(int width)
          Configures the preferred width of this label (the preferred height will be calculated from the font).
 void setText(String text)
          Updates the text displayed by this label.
 void setTextRotation(int rotation)
          Sets the rotation for the text (in ninety degree increments).
protected  void useConfig(LabelRenderer.Config config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_container

protected TextComponent _container

_value

protected String _value

_textRotation

protected int _textRotation

_orient

protected int _orient

_gap

protected int _gap

_fit

protected Label.Fit _fit

_icon

protected Icon _icon

_ix

protected int _ix

_iy

protected int _iy

_config

protected LabelRenderer.Config _config

_tx

protected int _tx

_ty

protected int _ty

_alpha

protected float _alpha

_prefconfig

protected LabelRenderer.Config _prefconfig

_prefsize

protected Dimension _prefsize

_prefWidth

protected int _prefWidth

_srect

protected Rectangle _srect
Constructor Detail

LabelRenderer

public LabelRenderer(TextComponent container)
Method Detail

setText

public void setText(String text)
Updates the text displayed by this label.


getText

public String getText()
Returns the text currently being displayed by this label.


setIcon

public void setIcon(Icon icon)
Configures the label to display the specified icon.


getIcon

public Icon getIcon()
Returns the icon being displayed by this label.


setIconTextGap

public void setIconTextGap(int gap)
Configures the gap between the icon and the text.


getIconTextGap

public int getIconTextGap()
Returns the gap between the icon and the text.


setTextRotation

public void setTextRotation(int rotation)
Sets the rotation for the text (in ninety degree increments).


setOrientation

public void setOrientation(int orient)
Sets the orientation of this label with respect to its icon. If the horizontal (the default) the text is displayed to the right of the icon, if vertical the text is displayed below it.


setFit

public void setFit(Label.Fit mode)
Configures whether this label will wrap, truncate or scale if it cannot fit text into its allotted width. The default is to wrap.


setPreferredWidth

public void setPreferredWidth(int width)
Configures the preferred width of this label (the preferred height will be calculated from the font).


computePreferredSize

public Dimension computePreferredSize(int whint,
                                      int hhint)
Computes the preferred size of the label.


layout

public void layout(Insets insets,
                   int contWidth,
                   int contHeight)
Lays out the label text and icon.


getIconX

public int getIconX()
Returns the x coordinate of the icon.


getIconY

public int getIconY()
Returns the y coordinate of the icon.


render

public void render(Renderer renderer,
                   int x,
                   int y,
                   int contWidth,
                   int contHeight,
                   float alpha)
Renders the label text and icon.


renderText

protected void renderText(Renderer renderer,
                          int contWidth,
                          int contHeight,
                          float alpha)

computeSize

protected Dimension computeSize(LabelRenderer.Config config)

getXOffset

protected int getXOffset(Insets insets,
                         int contWidth,
                         int width)

getYOffset

protected int getYOffset(Insets insets,
                         int contHeight,
                         int height)

layoutConfig

protected LabelRenderer.Config layoutConfig(LabelRenderer.Config oconfig,
                                            int twidth)
Creates glyphs for the current text at the specified target width.


useConfig

protected void useConfig(LabelRenderer.Config config)

getWidth

protected static int getWidth(int width,
                              int height,
                              int rotation)
Returns the width under the supplied rotation.


getHeight

protected static int getHeight(int width,
                               int height,
                               int rotation)
Returns the height under the supplied rotation.


getOffsetX

protected static int getOffsetX(int width,
                                int height,
                                int rotation)
Returns the x offset for rotating the supplied dimensions by the specified amount.


getOffsetY

protected static int getOffsetY(int width,
                                int height,
                                int rotation)
Returns the y offset for rotation the supplied dimensions by the specified amount.