com.jmex.bui
Class Label

java.lang.Object
  extended by com.jmex.bui.Label
All Implemented Interfaces:
BConstants

public class Label
extends java.lang.Object
implements BConstants

Handles the underlying layout and rendering for BLabel and BButton.


Nested Class Summary
protected static class Label.Config
           
protected static class Label.Text
           
 
Field Summary
protected  float _alpha
           
protected  Label.Config _config
           
protected  BTextComponent _container
           
protected  BLabel.Fit _fit
           
protected  int _gap
           
protected  BIcon _icon
           
protected  int _ix
           
protected  int _iy
           
protected  Orientation _orient
           
protected  Label.Config _prefconfig
           
protected  Dimension _prefsize
           
protected  Rectangle _srect
           
protected  int _tx
           
protected  int _ty
           
protected  java.lang.String _value
           
 
Fields inherited from interface com.jmex.bui.BConstants
DEFAULT_SIZE, DEFAULT_SPACING
 
Constructor Summary
Label(BTextComponent container)
           
 
Method Summary
 Dimension computePreferredSize(int whint, int hhint)
          Computes the preferred size of the label.
protected  Dimension computeSize(Label.Config config)
           
 BIcon getIcon()
          Returns the icon being displayed by this label.
 int getIconTextGap()
          Returns the gap between the icon and the text.
 java.lang.String getText()
          Returns the text currently being displayed by this label.
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  Label.Config layoutConfig(Label.Config oconfig, int twidth)
          Creates glyphs for the current text at the specified target width.
 void releaseText()
          Releases any underlying texture resources created by this label.
 void render(com.jme.renderer.Renderer renderer, int x, int y, int contWidth, int contHeight, float alpha)
          Renders the label text and icon.
protected  void renderText(com.jme.renderer.Renderer renderer, int contWidth, int contHeight, float alpha)
           
 void setFit(BLabel.Fit mode)
          Configures whether this label will wrap, truncate or scale if it cannot fit text into its allotted width.
 void setIcon(BIcon icon)
          Configures the label to display the specified icon.
 void setIconTextGap(int gap)
          Configures the gap between the icon and the text.
 void setOrientation(Orientation orient)
          Sets the orientation of this label with respect to its icon.
 void setText(java.lang.String text)
          Updates the text displayed by this label.
protected  void useConfig(Label.Config config)
           
 void wasAdded()
          Called by our containing component when it was added to the interface hierarchy.
 void wasRemoved()
          Called by our containing component when it was removed from the interface hierarchy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_container

protected BTextComponent _container

_value

protected java.lang.String _value

_orient

protected Orientation _orient

_gap

protected int _gap

_fit

protected BLabel.Fit _fit

_icon

protected BIcon _icon

_ix

protected int _ix

_iy

protected int _iy

_config

protected Label.Config _config

_tx

protected int _tx

_ty

protected int _ty

_alpha

protected float _alpha

_prefconfig

protected Label.Config _prefconfig

_prefsize

protected Dimension _prefsize

_srect

protected Rectangle _srect
Constructor Detail

Label

public Label(BTextComponent container)
Method Detail

setText

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

Parameters:
text - String

getText

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

Returns:
String

setIcon

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

Parameters:
icon - BIcon

getIcon

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

Returns:
BIcon

setIconTextGap

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

Parameters:
gap - int

getIconTextGap

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

Returns:
int

setOrientation

public void setOrientation(Orientation 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.

Parameters:
orient - Orientation

setFit

public void setFit(BLabel.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.

Parameters:
mode - BLabel.Fit

wasAdded

public void wasAdded()
Called by our containing component when it was added to the interface hierarchy.


wasRemoved

public void wasRemoved()
Called by our containing component when it was removed from the interface hierarchy.


computePreferredSize

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

Parameters:
whint - int
hhint - int
Returns:
Dimension

layout

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

Parameters:
insets - Insets
contWidth - int
contHeight - int

releaseText

public void releaseText()
Releases any underlying texture resources created by this label.


render

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

Parameters:
renderer - Renderer
x - int
y - int
contWidth - int
contHeight - int
alpha - float

renderText

protected void renderText(com.jme.renderer.Renderer renderer,
                          int contWidth,
                          int contHeight,
                          float alpha)
Parameters:
renderer - Renderer
contWidth - int
contHeight - int
alpha - float

computeSize

protected Dimension computeSize(Label.Config config)
Parameters:
config - Config
Returns:
Dimension

getXOffset

protected int getXOffset(Insets insets,
                         int contWidth,
                         int width)
Parameters:
insets - Insets
contWidth - int
width - int
Returns:
int

getYOffset

protected int getYOffset(Insets insets,
                         int contHeight,
                         int height)
Parameters:
insets - Insets
contHeight - int
height - int
Returns:
int

layoutConfig

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

Parameters:
oconfig - Config
twidth - int
Returns:
Config

useConfig

protected void useConfig(Label.Config config)
Parameters:
config - Config


Copyright © 2011 Michael Bayne. All Rights Reserved.