PulpCore

pulpcore.sprite
Class Label

java.lang.Object
  extended by pulpcore.sprite.Sprite
      extended by pulpcore.sprite.Label
All Implemented Interfaces:
PropertyListener

public class Label
extends Sprite

The Label is a Sprite that displays text. The text can be formatted using printf-style parameters

See Also:
StringUtil

Field Summary
 Int numDisplayChars
           
 
Fields inherited from class pulpcore.sprite.Sprite
alpha, anchorX, anchorY, angle, CENTER, DEFAULT, EAST, enabled, height, NORTH, NORTH_EAST, NORTH_WEST, pixelSnapping, SOUTH, SOUTH_EAST, SOUTH_WEST, visible, WEST, width, x, y
 
Constructor Summary
Label(CoreFont font, String text, double x, double y)
           
Label(CoreFont font, String text, double x, double y, double w, double h)
          If height < 0, the height is automatically set to fit the font height.
Label(CoreFont font, String text, int x, int y)
           
Label(CoreFont font, String text, int x, int y, int w, int h)
          If height < 0, the height is automatically set to fit the font height.
Label(String text, double x, double y)
           
Label(String text, double x, double y, double w, double h)
          If height < 0, the height is automatically set to fit the font height.
Label(String text, int x, int y)
           
Label(String text, int x, int y, int w, int h)
          If height < 0, the height is automatically set to fit the font height.
 
Method Summary
static Group createMultilineLabel(CoreFont font, String text, double x, double y)
          Creates a Group of Labels with the specified Font.
static Group createMultilineLabel(CoreFont font, String text, double x, double y, int viewWidth)
          Creates a Group of Labels with the specified Font.
static Group createMultilineLabel(CoreFont font, String text, int x, int y)
          Creates a Group of Labels with the specified Font.
static Group createMultilineLabel(CoreFont font, String text, int x, int y, int viewWidth)
          Creates a Group of Labels with the specified Font.
static Group createMultilineLabel(String text, double x, double y)
          Creates a Group of Labels with the system font.
static Group createMultilineLabel(String text, double x, double y, int viewWidth)
          Creates a Group of Labels with the system font.
static Group createMultilineLabel(String text, int x, int y)
          Creates a Group of Labels with the system font.
static Group createMultilineLabel(String text, int x, int y, int viewWidth)
          Creates a Group of Labels with the system font.
protected  void drawSprite(CoreGraphics g)
          Draws the sprite.
protected  void drawText(CoreGraphics g, String text)
           
 CoreFont getFont()
           
protected  int getNaturalHeight()
          Gets the fixed-point value of the Sprite's natural height.
protected  int getNaturalWidth()
          Gets the fixed-point value of the Sprite's natural width.
 String getText()
           
 void propertyChange(Property p)
          On a property change this Sprite is marked as dirty.
 void setFont(CoreFont font)
          Set this Label's font and resizes it if necessary.
 void setFormatArg(Object arg)
           
 void setFormatArgs(Object[] args)
           
 void setText(String text)
           
 void update(int elapsedTime)
          Updates all of this Sprite's properties.
 
Methods inherited from class pulpcore.sprite.Sprite
bindLocationTo, bindSizeTo, clearCursor, clearDirtyRect, contains, draw, getBlendMode, getCursor, getDirtyRect, getFilter, getLocalX, getLocalY, getParent, getPixelLevelChecks, getRoot, getScene2D, getTag, getViewX, getViewX, getViewY, getViewY, intersects, isDirty, isEnabled, isEnabledAndVisible, isMouseDoubleClicked, isMouseDown, isMouseHover, isMouseOver, isMousePressed, isMouseReleased, isMouseTripleClicked, isMouseWheelRotated, isOpaque, isPick, isPickEnabledAndVisible, isTransparent, move, move, move, move, move, move, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, removeFromParent, scale, scale, scale, scale, scale, scale, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, setAnchor, setAnchor, setBlendMode, setCursor, setDirty, setFilter, setLocation, setLocation, setSize, setSize, setTag, translate, translate, updateDirtyRect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numDisplayChars

public final Int numDisplayChars
Constructor Detail

Label

public Label(String text,
             int x,
             int y)

Label

public Label(String text,
             double x,
             double y)

Label

public Label(String text,
             int x,
             int y,
             int w,
             int h)
If height < 0, the height is automatically set to fit the font height.


Label

public Label(String text,
             double x,
             double y,
             double w,
             double h)
If height < 0, the height is automatically set to fit the font height.


Label

public Label(CoreFont font,
             String text,
             int x,
             int y)

Label

public Label(CoreFont font,
             String text,
             double x,
             double y)

Label

public Label(CoreFont font,
             String text,
             int x,
             int y,
             int w,
             int h)
If height < 0, the height is automatically set to fit the font height.


Label

public Label(CoreFont font,
             String text,
             double x,
             double y,
             double w,
             double h)
If height < 0, the height is automatically set to fit the font height.

Method Detail

propertyChange

public void propertyChange(Property p)
Description copied from class: Sprite
On a property change this Sprite is marked as dirty.

Specified by:
propertyChange in interface PropertyListener
Overrides:
propertyChange in class Sprite
Parameters:
p - the property whose value has changed.

getNaturalWidth

protected int getNaturalWidth()
Description copied from class: Sprite
Gets the fixed-point value of the Sprite's natural width. Subclasses will override this method to specify the natural width. The natural width is the width of the Sprite if no scaling is applied - for an ImageSprite, the natural width is the width of the image.

Overrides:
getNaturalWidth in class Sprite

getNaturalHeight

protected int getNaturalHeight()
Description copied from class: Sprite
Gets the fixed-point value of the Sprite's natural height. Subclasses will override this method to specify the natural height. The natural height is the height of the Sprite if no scaling is applied - for an ImageSprite, the natural height is the height of the image.

Overrides:
getNaturalHeight in class Sprite

update

public void update(int elapsedTime)
Description copied from class: Sprite
Updates all of this Sprite's properties. Subclasses that override this method should call super.update().

Overrides:
update in class Sprite

getFont

public CoreFont getFont()
Returns:
this Label's font.

setFont

public void setFont(CoreFont font)
Set this Label's font and resizes it if necessary.


getText

public String getText()
Returns:
the formatted display text.

setText

public void setText(String text)

setFormatArg

public void setFormatArg(Object arg)

setFormatArgs

public void setFormatArgs(Object[] args)

drawSprite

protected void drawSprite(CoreGraphics g)
Description copied from class: Sprite
Draws the sprite. The graphic context's alpha is set to this sprite's alpha, and it's translation is offset by this sprite's location. This method is not called if the sprite is not visible or it's alpha is less than or equal to zero.

This method may be called multiple times for each dirty rectangle. The clip of the graphics context will be set to the current dirty rectangle.

When the contents of this sprite change (in another words, the graphic output of this method will be different from the last time it is called), subclasses should call setDirty(true).

Implementors should not save a reference to the graphics context as it can change between calls to this method.

Specified by:
drawSprite in class Sprite

drawText

protected void drawText(CoreGraphics g,
                        String text)

createMultilineLabel

public static Group createMultilineLabel(String text,
                                         int x,
                                         int y)
Creates a Group of Labels with the system font. The newline ('\n') character can be used to specify explicit line breaks.


createMultilineLabel

public static Group createMultilineLabel(String text,
                                         int x,
                                         int y,
                                         int viewWidth)
Creates a Group of Labels with the system font. Word-wrapping is used to confine the text to the specified viewWidth. The newline ('\n') character can be used to specify explicit line breaks.


createMultilineLabel

public static Group createMultilineLabel(String text,
                                         double x,
                                         double y)
Creates a Group of Labels with the system font. The newline ('\n') character can be used to specify explicit line breaks.


createMultilineLabel

public static Group createMultilineLabel(String text,
                                         double x,
                                         double y,
                                         int viewWidth)
Creates a Group of Labels with the system font. Word-wrapping is used to confine the text to the specified viewWidth. The newline ('\n') character can be used to specify explicit line breaks.


createMultilineLabel

public static Group createMultilineLabel(CoreFont font,
                                         String text,
                                         int x,
                                         int y)
Creates a Group of Labels with the specified Font. The newline ('\n') character can be used to specify explicit line breaks.


createMultilineLabel

public static Group createMultilineLabel(CoreFont font,
                                         String text,
                                         int x,
                                         int y,
                                         int viewWidth)
Creates a Group of Labels with the specified Font. Word-wrapping is used to confine the text to the specified viewWidth. The newline ('\n') character can be used to specify explicit line breaks.


createMultilineLabel

public static Group createMultilineLabel(CoreFont font,
                                         String text,
                                         double x,
                                         double y)
Creates a Group of Labels with the specified Font. The newline ('\n') character can be used to specify explicit line breaks.


createMultilineLabel

public static Group createMultilineLabel(CoreFont font,
                                         String text,
                                         double x,
                                         double y,
                                         int viewWidth)
Creates a Group of Labels with the specified Font. Word-wrapping is used to confine the text to the specified viewWidth. The newline ('\n') character can be used to specify explicit line breaks.


PulpCore

Copyright © 2007-2009 Interactive Pulp, LLC.