artisynth.core.renderables
Class TextComponent3d

java.lang.Object
  extended by artisynth.core.modelbase.ModelComponentBase
      extended by artisynth.core.modelbase.RenderableComponentBase
          extended by artisynth.core.renderables.TextComponentBase
              extended by artisynth.core.renderables.TextComponent3d
All Implemented Interfaces:
ModelComponent, RenderableComponent, TransformableGeometry, java.lang.Cloneable, HasProperties, HierarchyNode, GLRenderable, GLSelectable, HasRenderProps, Renderable, Disposable, Scannable

public class TextComponent3d
extends TextComponentBase
implements TransformableGeometry

Allows adding text to a root model, with the option of having the text follow the viewer.

Author:
Antonio, July 7, 2013

Nested Class Summary
 
Nested classes/interfaces inherited from class artisynth.core.renderables.TextComponentBase
TextComponentBase.FontStyle, TextComponentBase.HorizontalAlignment, TextComponentBase.VerticalAlignment
 
Nested classes/interfaces inherited from interface artisynth.core.modelbase.ModelComponent
ModelComponent.NavpanelVisibility
 
Field Summary
static boolean defaultByReference
           
static int defaultFontSize
           
static double defaultTextSize
           
static PropertyList myProps
           
 
Fields inherited from class artisynth.core.renderables.TextComponentBase
defaultFontName, defaultHAlignment, defaultVAlignment
 
Fields inherited from class artisynth.core.modelbase.ModelComponentBase
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
 
Fields inherited from interface artisynth.core.util.TransformableGeometry
ARTICULATED, SIMULATING
 
Fields inherited from interface maspack.render.GLRenderable
TRANSLUCENT, TWO_DIMENSIONAL
 
Constructor Summary
TextComponent3d(java.lang.String name)
          Sets both name and text to the provided string
TextComponent3d(java.lang.String text, Point3d pos)
          Sets both name (if valid) and text to provided string
TextComponent3d(java.lang.String name, java.lang.String text, Point3d pos)
          Main constructor
 
Method Summary
 PropertyList getAllPropertyInfo()
          Returns a list giving static information about all properties exported by this object.
 AxisAngle getOrientation()
           
 Point3d getPosition()
          Returns position by reference
 int getRenderHints()
          Returns a bit code giving rendering hints about this renderable.
 java.lang.String getText()
           
 boolean isFollowingEye()
          Checks whether the text is following the viewer's eye
 boolean isSelectable()
          Returns true if this object is in fact selectable.
 int numSelectionQueriesNeeded()
          If this selectable manages its own selection (by issuing selection queries within its render method), then this method should return the maximum number of selection queries that will be required.
 void render(GLRenderer renderer, int flags)
          Render this object using Open GL via the JOGL.
 void setFollowEye(boolean set)
          Sets whether to have the text follow the user's eye
 void setFontSize(int size)
          Sets the base font size.
 void setOrientation(AxisAngle orient)
          Orientation w.r.t.
 void setPosition(Point3d pos)
          Sets the position to display text
 void setPosition(Point3d pos, boolean byRef)
          Sets world position to display text.
 void setText(java.lang.String text)
          Sets the text to display
 void transformGeometry(AffineTransform3dBase X)
          Applies an affine transformation to the geometry of this object.
 void transformGeometry(AffineTransform3dBase X, TransformableGeometry topObject, int flags)
          Applies an affine transformation to the geometry of this object.
 void updateBounds(Point3d pmin, Point3d pmax)
          Update the minimum and maximum points for this object.
 
Methods inherited from class artisynth.core.renderables.TextComponentBase
createDefaultRenderProps, createRenderProps, dispose, getFontFamily, getFontSize, getFontStyle, getHorizontalAlignment, getTextSize, getVerticalAlignment, setFont, setFontFamily, setFontStyle, setHorizontalAlignment, setTextColor, setTextRenderer, setTextSize, setVerticalAlignment
 
Methods inherited from class artisynth.core.modelbase.RenderableComponentBase
copy, getRenderProps, getSelection, prerender, setRenderProps, updateRenderProps
 
Methods inherited from class artisynth.core.modelbase.ModelComponentBase
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getChildren, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, hasChildren, hasState, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, postscan, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, scan, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setSelected, updateReferences, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface artisynth.core.modelbase.ModelComponent
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, postscan, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, updateReferences
 
Methods inherited from interface maspack.properties.HasProperties
getProperty
 
Methods inherited from interface maspack.properties.HierarchyNode
getChildren, hasChildren
 
Methods inherited from interface maspack.util.Scannable
isWritable, write
 

Field Detail

defaultFontSize

public static int defaultFontSize

defaultTextSize

public static double defaultTextSize

defaultByReference

public static boolean defaultByReference

myProps

public static PropertyList myProps
Constructor Detail

TextComponent3d

public TextComponent3d(java.lang.String name)
Sets both name and text to the provided string

Parameters:
name -

TextComponent3d

public TextComponent3d(java.lang.String text,
                       Point3d pos)
Sets both name (if valid) and text to provided string


TextComponent3d

public TextComponent3d(java.lang.String name,
                       java.lang.String text,
                       Point3d pos)
Main constructor

Method Detail

getAllPropertyInfo

public PropertyList getAllPropertyInfo()
Description copied from interface: HasProperties
Returns a list giving static information about all properties exported by this object.

Specified by:
getAllPropertyInfo in interface HasProperties
Overrides:
getAllPropertyInfo in class TextComponentBase
Returns:
static information for all exported properties

setText

public void setText(java.lang.String text)
Sets the text to display


getText

public java.lang.String getText()

setPosition

public void setPosition(Point3d pos)
Sets the position to display text


setPosition

public void setPosition(Point3d pos,
                        boolean byRef)
Sets world position to display text. If byRef is true, then sets position by reference.


getPosition

public Point3d getPosition()
Returns position by reference


setOrientation

public void setOrientation(AxisAngle orient)
Orientation w.r.t. world. If we are following the viewer, this is usually the identity.


getOrientation

public AxisAngle getOrientation()

render

public void render(GLRenderer renderer,
                   int flags)
Description copied from interface: GLRenderable
Render this object using Open GL via the JOGL.

Specified by:
render in interface GLRenderable
Specified by:
render in class RenderableComponentBase
Parameters:
renderer - renderer object which is used to perform the rendering. Provides pointers to GL and GLU, along with helper functions.
flags - supplies flags that may be used to control different aspects of the rendering. Flags are defined in GLRenderer and currently include GLRenderer.SELECTED, GLRenderer.VERTEX_COLORING, GLRenderer.HSV_COLOR_INTERPOLATION, GLRenderer.SORT_FACES, and GLRenderer.CLEAR_MESH_DISPLAY_LISTS.

getRenderHints

public int getRenderHints()
Description copied from interface: GLRenderable
Returns a bit code giving rendering hints about this renderable. Current bit codes include TRANSLUCENT.

Specified by:
getRenderHints in interface GLRenderable
Overrides:
getRenderHints in class RenderableComponentBase
Returns:
bit code of rendering hints.

isFollowingEye

public boolean isFollowingEye()
Checks whether the text is following the viewer's eye


setFollowEye

public void setFollowEye(boolean set)
Sets whether to have the text follow the user's eye


updateBounds

public void updateBounds(Point3d pmin,
                         Point3d pmax)
Description copied from interface: GLRenderable
Update the minimum and maximum points for this object. In an x-y-z coordinate system with x directed to the right and y directed upwards, the minimum and maximum points can be thought of as defining the left-lower-far and right-upper-near corners of a bounding cube. This method should only reduce the elements of the minimum point and increase the elements of the maximum point, since it may be used as part of an iteration to determine the bounding cube for several different objects.

Specified by:
updateBounds in interface GLRenderable
Overrides:
updateBounds in class RenderableComponentBase
Parameters:
pmin - minimum point
pmax - maximum point

transformGeometry

public void transformGeometry(AffineTransform3dBase X)
Description copied from interface: TransformableGeometry
Applies an affine transformation to the geometry of this object. This method should be equivalent to
 transformGeometry (X, this, 0);
 

Specified by:
transformGeometry in interface TransformableGeometry
Parameters:
X - affine transformation

transformGeometry

public void transformGeometry(AffineTransform3dBase X,
                              TransformableGeometry topObject,
                              int flags)
Description copied from interface: TransformableGeometry
Applies an affine transformation to the geometry of this object. If recursively invoked within a component hierarchy, then topComponent should be the component for which the method was initially invoked. The variable flags provides information about the context in which the transformation is being applied. At present, the available flags are TransformableGeometry.SIMULATING and TransformableGeometry.ARTICULATED.

Specified by:
transformGeometry in interface TransformableGeometry
Parameters:
X - affine transformation
topObject - component on which the method was initially invoked
flags - provides information about the context in which the transformation is being applied.

isSelectable

public boolean isSelectable()
Description copied from class: RenderableComponentBase
Returns true if this object is in fact selectable.

Specified by:
isSelectable in interface GLSelectable
Overrides:
isSelectable in class TextComponentBase
Returns:
true if this object is selectable

numSelectionQueriesNeeded

public int numSelectionQueriesNeeded()
Description copied from interface: GLSelectable
If this selectable manages its own selection (by issuing selection queries within its render method), then this method should return the maximum number of selection queries that will be required. Otherwise, this method should return -1.

Specified by:
numSelectionQueriesNeeded in interface GLSelectable
Overrides:
numSelectionQueriesNeeded in class TextComponentBase
Returns:
maximum number of selection queries needed by this component, or -1 if this component does not manage its own selection.

setFontSize

public void setFontSize(int size)
Sets the base font size. This should be used only to adjust the resolution of the font. For controlling the text size, use TextComponentBase.setTextSize(double).

Overrides:
setFontSize in class TextComponentBase
Parameters:
size -
See Also:
TextComponentBase.setTextSize(double)