com.jme.scene
Class Text

java.lang.Object
  extended by com.jme.scene.Spatial
      extended by com.jme.scene.Geometry
          extended by com.jme.scene.Text
All Implemented Interfaces:
Savable, java.io.Serializable
Direct Known Subclasses:
Text2D

public class Text
extends Geometry

Text allows text to be displayed on the screen. The renderstate of this Geometry must be a valid font texture.

Author:
Mark Powell, Joshua Slack
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode
 
Field Summary
static java.lang.String DEFAULT_FONT
          A default font cantained in the jME library.
 
Fields inherited from class com.jme.scene.Geometry
binormalBuf, bound, castsShadows, colorBuf, compVect, defaultColor, displayListID, enabled, fogBuf, hasDirtyVertices, normBuf, states, tangentBuf, texBuf, vboInfo, vertBuf, vertQuantity
 
Fields inherited from class com.jme.scene.Spatial
cullHint, frustrumIntersects, geometricalControllers, isCollidable, lightCombineMode, localRotation, localScale, localTranslation, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, normalsMode, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
Text()
           
Text(java.lang.String name, java.lang.String text)
          Creates a texture object that starts with the given text.
 
Method Summary
protected  void applyRenderState(java.util.Stack<? extends RenderState>[] states)
          applyRenderState determines if a particular render state is set for this Geometry.
static Text createDefaultTextLabel(java.lang.String name)
           
static Text createDefaultTextLabel(java.lang.String name, java.lang.String initialText)
           
 void draw(Renderer r)
          draw calls super to set the render state then calls the renderer to display the text string.
 void findCollisions(Spatial scene, CollisionResults results)
          checks this spatial against a second spatial, any collisions are stored in the results object.
static TextureState getDefaultFontTextureState()
          Creates the texture state if not created before.
static BlendState getFontBlend()
           
 float getHeight()
           
 java.lang.StringBuffer getText()
          getText retrieves the text string of this Text object.
 ColorRGBA getTextColor()
          Returns the current text color.
 float getWidth()
           
 boolean hasCollision(Spatial scene, boolean checkTriangles)
          Checks this spatial against a second spatial for collisions.
 void print(java.lang.String text)
          print sets the text to be rendered on the next render pass.
 void print(java.lang.StringBuffer text)
          Sets the text to be rendered on the next render.
 void read(JMEImporter e)
           
static void resetDefaultFontTextureState()
          Cleans up the default font texture and state for the Text class.
static void resetFontTexture()
           
 void setTextColor(ColorRGBA color)
          Sets the color of the text.
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.Geometry
addTextureCoordinates, addTextureCoordinates, checkTextureCoordinates, clearBuffers, clearTextureBuffers, copyTextureCoordinates, copyTextureCoordinates, findPick, getBinormalBuffer, getColorBuffer, getDefaultColor, getDisplayListID, getFogBuffer, getLightState, getModelBound, getNormalBuffer, getNumberOfUnits, getTangentBuffer, getTextureCoords, getTextureCoords, getTriangleCount, getVBOInfo, getVertexBuffer, getVertexCount, getWorldCoords, getWorldNormals, hasDirtyVertices, isCastsShadows, lockMeshes, postdraw, predraw, randomVertex, reconstruct, resizeTextureIds, rotateNormals, rotatePoints, scaleTextureCoordinates, scaleTextureCoordinates, setBinormalBuffer, setCastsShadows, setColorBuffer, setDefaultColor, setDisplayListID, setFogCoordBuffer, setHasDirtyVertices, setLightState, setModelBound, setNormalBuffer, setRandomColors, setSolidColor, setTangentBuffer, setTextureCoords, setTextureCoords, setTextureCoords, setVBOInfo, setVertexBuffer, setVertexCount, sortLights, translatePoints, translatePoints, unlockMeshes, updateModelBound, updateWorldBound
 
Methods inherited from class com.jme.scene.Spatial
addController, calculateCollisions, calculatePick, clearControllers, clearRenderState, clearRenderState, getClassTag, getController, getControllerCount, getControllers, getCullHint, getLastFrustumIntersection, getLightCombineMode, getLocalCullHint, getLocalLightCombineMode, getLocalNormalsMode, getLocalRenderQueueMode, getLocalRotation, getLocalScale, getLocalTextureCombineMode, getLocalToWorldMatrix, getLocalTranslation, getLocks, getName, getNormalsMode, getParent, getRenderQueueMode, getRenderState, getRenderState, getTextureCombineMode, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, hasAncestor, isCollidable, localToWorld, lock, lock, lockBounds, lockBranch, lockMeshes, lockShadows, lockTransforms, lookAt, onDraw, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeController, removeFromParent, removeUserData, rotateUpTo, setCullHint, setIsCollidable, setLastFrustumIntersection, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setLocalTranslation, setLocks, setLocks, setName, setNormalsMode, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setUserData, setZOrder, setZOrder, toString, unlock, unlock, unlockBounds, unlockBranch, unlockMeshes, unlockShadows, unlockTransforms, updateGeometricState, updateRenderState, updateRenderState, updateWorldData, updateWorldRotation, updateWorldScale, updateWorldTranslation, updateWorldVectors, updateWorldVectors, worldToLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jme.util.export.Savable
getClassTag
 

Field Detail

DEFAULT_FONT

public static final java.lang.String DEFAULT_FONT
A default font cantained in the jME library.

See Also:
Constant Field Values
Constructor Detail

Text

public Text()

Text

public Text(java.lang.String name,
            java.lang.String text)
Creates a texture object that starts with the given text.

Parameters:
name - the name of the scene element. This is required for identification and comparision purposes.
text - The text to show.
See Also:
TextureManager
Method Detail

print

public void print(java.lang.String text)
print sets the text to be rendered on the next render pass.

Parameters:
text - the text to display.

print

public void print(java.lang.StringBuffer text)
Sets the text to be rendered on the next render. This function is a more efficient version of print(String).

Parameters:
text - The text to display.

getText

public java.lang.StringBuffer getText()
getText retrieves the text string of this Text object.

Returns:
the text string of this object.

draw

public void draw(Renderer r)
draw calls super to set the render state then calls the renderer to display the text string.

Overrides:
draw in class Geometry
Parameters:
r - the renderer used to display the text.
See Also:
Spatial.draw(com.jme.renderer.Renderer)

setTextColor

public void setTextColor(ColorRGBA color)
Sets the color of the text.

Parameters:
color - Color to set.

getTextColor

public ColorRGBA getTextColor()
Returns the current text color.

Returns:
Current text color.

findCollisions

public void findCollisions(Spatial scene,
                           CollisionResults results)
Description copied from class: Spatial
checks this spatial against a second spatial, any collisions are stored in the results object.

Specified by:
findCollisions in class Spatial
Parameters:
scene - the scene to test against.
results - the results of the collisions.

hasCollision

public boolean hasCollision(Spatial scene,
                            boolean checkTriangles)
Description copied from class: Spatial
Checks this spatial against a second spatial for collisions.

Specified by:
hasCollision in class Spatial
Parameters:
scene - the scene to test against.
checkTriangles - check for collisions on triangle accuracy level
Returns:
true if any collision were found

getWidth

public float getWidth()

getHeight

public float getHeight()

createDefaultTextLabel

public static Text createDefaultTextLabel(java.lang.String name)
Parameters:
name - name of the spatial
Returns:
a Text with DEFAULT_FONT and correct blend state

createDefaultTextLabel

public static Text createDefaultTextLabel(java.lang.String name,
                                          java.lang.String initialText)
Parameters:
name - name of the spatial
Returns:
a Text with DEFAULT_FONT and correct blend state

getFontBlend

public static BlendState getFontBlend()

resetFontTexture

public static void resetFontTexture()

applyRenderState

protected void applyRenderState(java.util.Stack<? extends RenderState>[] states)
Description copied from class: Geometry
applyRenderState determines if a particular render state is set for this Geometry. If not, the default state will be used.

Overrides:
applyRenderState in class Geometry
Parameters:
states - An array of stacks for each state.

getDefaultFontTextureState

public static TextureState getDefaultFontTextureState()
Creates the texture state if not created before.

Returns:
texture state for the default font

resetDefaultFontTextureState

public static void resetDefaultFontTextureState()
Cleans up the default font texture and state for the Text class.


write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class Geometry
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class Geometry
Throws:
java.io.IOException