org.xith3d.ui.text2d
Class Text2D

java.lang.Object
  extended by org.xith3d.scenegraph.SceneGraphObject
      extended by org.xith3d.scenegraph.Node
          extended by org.xith3d.scenegraph.GroupNode
              extended by org.xith3d.scenegraph.Group
                  extended by org.xith3d.scenegraph.TransformGroup
                      extended by org.xith3d.ui.text2d.Text2D
All Implemented Interfaces:
org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.spatial.SpatialNode, Transformable, UpdatableNode

public class Text2D
extends TransformGroup
implements UpdatableNode

As there is no ( or no dynamic ) text node for Xith3D here is mine.
While the Text2D version org.xith3d.text.Text2D by Terje Wiesener uses a single face with a static texture this class uses a seperate Shape3d for every char it uses. Those shapes are stored in a static HashMap to prevent some load when using many text objects.

Thanks to Terje Wiesener ( who wrote the other Text2D implementation ), i borrowed the render stuff from his work :)

See Also:
First Announcement (old version), Secondary Announcement (new version)

Field Summary
 
Fields inherited from class org.xith3d.scenegraph.GroupNode
children, hostGroup, numChildren, totalNumChildren, totalNumShapes
 
Fields inherited from class org.xith3d.scenegraph.Node
bounds, boundsAutoCompute, boundsDirty, globalIgnoreBounds, instanceBoundsTypeHint, transformGroup, untransformedBounds
 
Fields inherited from class org.xith3d.scenegraph.SceneGraphObject
XITH3D_USERDATAKEY_OLDUSERDATA
 
Constructor Summary
Text2D(java.lang.String text)
          Create a new Text Object with standard Attributes
Text2D(java.lang.String text, org.openmali.vecmath2.Colorf color)
          Creates a new Text2D object
Text2D(java.lang.String text, org.openmali.vecmath2.Colorf color, java.awt.Font font, TextAlignment alignFlags)
          Create a new Text Object with all options
Text2D(java.lang.String text, org.openmali.vecmath2.Colorf color, java.lang.String fontname, int fontFlags, int resolution, TextAlignment alignFlags)
          Create a new Text Object with all options
Text2D(java.lang.String text, float r, float g, float b, java.awt.Font font, TextAlignment alignFlags)
          Create a new Text Object with all options
Text2D(java.lang.String text, float r, float g, float b, java.lang.String fontname, int fontFlags, int resolution, TextAlignment alignFlags)
          Create a new Text Object with all options
Text2D(java.lang.String text, TextAlignment alignFlags)
          Create a text object with alignflags
 
Method Summary
 TextAlignment getAlignment()
           
 float getBlueValue()
           
 org.openmali.vecmath2.Colorf getColor()
           
 java.awt.Font getFont()
           
 float getGreenValue()
           
 java.util.List<Line2D> getLines()
           
 float getRedValue()
           
 org.openmali.vecmath2.Tuple2f getSize()
           
 float getTransparency()
           
 void setAlignment(TextAlignment alignment)
          Sets new text alignment.
 void setColor(org.openmali.vecmath2.Colorf color)
          Sets the color of current text
(this should be called after setText if both are called once per frame)
 void setColor(float r, float g, float b)
          Sets the color of current text
has a small bug: while changing text rapidly the color doesn't change correctly when setColor is called before setText
 void setFont(java.awt.Font font)
          Changes/sets the text's font
 void setFont(java.lang.String fontname)
          Changes/sets the text's font name
 void setFontFlags(int fontFlags)
          Sets new fontflags @see java.awt.Font.
 void setResolution(int resolution)
          Sets new resolution.
 void setText(java.lang.String newText)
          Set new text (this is finally done in an efficient way).
 void setTransparency(float transparency)
           
 boolean update(View view, org.openmali.spatial.bodies.Frustum frustum, long nanoTime, long nanoStep)
          
 
Methods inherited from class org.xith3d.scenegraph.TransformGroup
getLocalTransform, getLocalTransform, getPosition, getPosition, getTransform, getTransform, getWorldTransform, newInstance, onTransformChanged, setLocalTransform, setPosition, setPosition, setTransform, traverse, updateTransform
 
Methods inherited from class org.xith3d.scenegraph.Group
moveTo
 
Methods inherited from class org.xith3d.scenegraph.GroupNode
absorbDetails, addChild, addChild, checkChild, dump, dump, ensureCapacity, expandBounds, findAll, findAll, findFirst, findFirst, freeOpenGLResources, getChild, getChildren, getChildren, getClipper, getPickHost, getScissorRect, getTotalNumChildren, getTotalNumShapes, indexOf, isPickHost, mergeInheritedClipper, mergeInheritedNodes, mergeInheritedScissorRect, numChildren, removeAllChildren, removeChild, removeChild, setBoundsDirty, setBoundsDirtyUpward, setChild, setClipper, setLive, setPickHost, setPickHost, setScissorRect, setShowBounds, sharedCopy, sharedCopy, traverse, unmergeInheritedFog, unmergeInheritedLight, unmergeInheritedNodes, updateBounds, updateBoundsCheap
 
Methods inherited from class org.xith3d.scenegraph.Node
cloneNode, detach, duplicateNode, freeOpenGLResources, getBounds, getBoundsAutoCompute, getBoundsType, getBoundsTypeHint, getDefaultPickable, getIndentString, getInheritedNodeAttributes, getModListener, getOrderedChild, getOrderedState, getParent, getRoot, getShadowAttachment, getShowBounds, getTransformGroup, getTreeCell, getWorldBounds, getWorldTransform, isBillboard, isIgnoreBounds, isOccluder, isPickable, isRenderable, isUpdatableNode, popGlobalIgnoreBounds, printBounds, pushGlobalIgnoreBounds, setBounds, setBoundsAutoCompute, setBoundsTypeHint, setDefaultPickable, setGlobalIgnoreBounds, setIgnoreBounds, setIsOccluder, setModListener, setOrderedChild, setParent, setPickable, setPickableRecursive, setPickableRecursive, setRenderable, setShadowAttachment, setShowBounds, setTransformGroup, setTreeCell, updateOrderedChild, updateTransformGroup, updateWorldTransform
 
Methods inherited from class org.xith3d.scenegraph.SceneGraphObject
getName, getUserData, getUserData, getUserDataMap, isLive, setName, setUserData, setUserData, setUserDataRecursive, setUserDataRecursive, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xith3d.scenegraph.Transformable
getName, setName
 

Constructor Detail

Text2D

public Text2D(java.lang.String text,
              float r,
              float g,
              float b,
              java.awt.Font font,
              TextAlignment alignFlags)
Create a new Text Object with all options

Parameters:
text - the initial text to set
r - the foreground color to use
g - the foreground color to use
b - the foreground color to use
font - the font to use
as the font size is fixed on to the texture it's just necessary to give the fontname which can be any font that Font can handle
alignFlags - align flags to use

Text2D

public Text2D(java.lang.String text,
              org.openmali.vecmath2.Colorf color,
              java.awt.Font font,
              TextAlignment alignFlags)
Create a new Text Object with all options

Parameters:
text - the initial text to set
font - the font to use
as the font size is fixed on to the texture it's just necessary to give the fontname which can be any font that Font can handle
color - the foreground color to use
alignFlags - align flags to use

Text2D

public Text2D(java.lang.String text,
              float r,
              float g,
              float b,
              java.lang.String fontname,
              int fontFlags,
              int resolution,
              TextAlignment alignFlags)
Create a new Text Object with all options

Parameters:
text - the initial text to set
r - the foreground color to use
g - the foreground color to use
b - the foreground color to use
fontname - the font to use
as the font size is fixed on to the texture it's just necessary to give the fontname which can be any font that Font can handle
fontFlags - font flags to use @see java.awt.Font
resolution - font resolution
every letter has a fixed geometry size of 1x1.5. The resolution is the width of the texture
alignFlags - align flags to use

Text2D

public Text2D(java.lang.String text,
              org.openmali.vecmath2.Colorf color,
              java.lang.String fontname,
              int fontFlags,
              int resolution,
              TextAlignment alignFlags)
Create a new Text Object with all options

Parameters:
text - the initial text to set
fontname - the font to use
as the font size is fixed on to the texture it's just necessary to give the fontname which can be any font that Font can handle
fontFlags - font flags to use @see java.awt.Font
resolution - font resolution
every letter has a fixed geometry size of 1x1.5. The resolution is the width of the texture
color - the foreground color to use
alignFlags - align flags to use

Text2D

public Text2D(java.lang.String text,
              org.openmali.vecmath2.Colorf color)
Creates a new Text2D object

Parameters:
text - new text
color - color

Text2D

public Text2D(java.lang.String text,
              TextAlignment alignFlags)
Create a text object with alignflags

Parameters:
text - new text
alignFlags - new alignFlags

Text2D

public Text2D(java.lang.String text)
Create a new Text Object with standard Attributes

Parameters:
text - first Text
Method Detail

getLines

public java.util.List<Line2D> getLines()
Returns:
an unmodifiable List of all contained Lines

setColor

public void setColor(float r,
                     float g,
                     float b)
Sets the color of current text
has a small bug: while changing text rapidly the color doesn't change correctly when setColor is called before setText

Parameters:
r - red value
g - green value
b - blue value

setColor

public void setColor(org.openmali.vecmath2.Colorf color)
Sets the color of current text
(this should be called after setText if both are called once per frame)

Parameters:
color - new Color to set
See Also:
setColor( float, float, float )

getColor

public org.openmali.vecmath2.Colorf getColor()

getRedValue

public float getRedValue()

getBlueValue

public float getBlueValue()

getGreenValue

public float getGreenValue()

setTransparency

public void setTransparency(float transparency)

getTransparency

public float getTransparency()

getSize

public org.openmali.vecmath2.Tuple2f getSize()

setFont

public void setFont(java.awt.Font font)
Changes/sets the text's font

Parameters:
font - new font to use

setFont

public void setFont(java.lang.String fontname)
Changes/sets the text's font name

Parameters:
fontname - new font to use

getFont

public java.awt.Font getFont()

setFontFlags

public void setFontFlags(int fontFlags)
Sets new fontflags @see java.awt.Font.

Parameters:
fontFlags - new flags

setResolution

public void setResolution(int resolution)
Sets new resolution.

Parameters:
resolution - new resolution

setAlignment

public void setAlignment(TextAlignment alignment)
Sets new text alignment.

Parameters:
alignment - new text alignment

getAlignment

public TextAlignment getAlignment()
Returns:
the current text alignment

update

public boolean update(View view,
                      org.openmali.spatial.bodies.Frustum frustum,
                      long nanoTime,
                      long nanoStep)

Specified by:
update in interface UpdatableNode
Parameters:
view - the view that's currently used for rendering
frustum - view frustum
Returns:
True if this should be rendered, false if it should not.

setText

public void setText(java.lang.String newText)
Set new text (this is finally done in an efficient way).

Parameters:
newText - new text