public class Text2D extends Geometry
A single line of text is normalise to always be one unit high regardless of
the original font size. The relative size can then be changed using a
multiplication factor, though the polygonalisation stays the same. If using
large text, and need fine polygonalisation, then making use of a custom
CharacterCreator with a large point size font and finer
flatness would be recommended.
Because all the methods for setting values in this class can influence the final bounds of the object, they are all required to use the boundsChanged() callback from NodeUpdateListener.
Since the text is 2D, it has no depth. If an intersection test is created such that the ray is parallel to the local X-Y plane and does not change in Z depth, then no intersection will be generated. The implementation attempts to optimise the testing based on the bounds of the individual character before checking polygons.
The default setup following construction follows English requirements:
horizontal: true
leftToRight: true
topToBottom: true
size: 1.0
spacing: 1.0
horizontal justification: JUSTIFY_BEGIN
vertical justification: JUSTIFY_BEGIN
Internationalisation Resource Names
| Modifier and Type | Field and Description |
|---|---|
static int |
JUSTIFY_BEGIN
Justify to the beginning of the line
|
static int |
JUSTIFY_END
Justify to the end of the string
|
static int |
JUSTIFY_FIRST
Justify to the first character of the line
|
static int |
JUSTIFY_MIDDLE
Justify about the middle
|
bounds, implicitBounds, internalUpdater, INVALID_BOUNDS, lastParentList, parentList, pickFlags, validAlphalastParent, liveCountalive, LISTENER_SET_TIMING_ERR_PROP, updateHandlerCOLLIDABLE_OBJECT, GENERAL_OBJECT, PROXIMITY_OBJECT, VISIBLE_OBJECTCUSTOM_PICK_TYPE, GROUP_PICK_TYPE, LEAF_PICK_TYPE, SINGLE_PICK_TYPE| Constructor and Description |
|---|
Text2D()
Create a new, default text representation.
|
Text2D(org.j3d.geom.CharacterCreator charGen)
Create a new text representation using the provided
CharacterCreator. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Object o)
Compares this object with the specified object for order.
|
int |
compareTo(Text2D txt)
Compares this object with the specified object for order.
|
boolean |
equals(Object o)
Compare this object for equality to the given object.
|
boolean |
equals(Text2D txt)
Compares this object with the specified object to check for equivalence.
|
float |
getHorizontalJustification()
Get the value of the line size multiplier.
|
float |
getSize()
Get the value of the line size multiplier.
|
float |
getSpacing()
Get the value of the line spacing multiplier.
|
String[] |
getText()
Get a reference to the currently set collection of strings.
|
float |
getVerticalJustification()
Get the value of the line size multiplier.
|
boolean |
is2D()
Check to see whether this shape is something that represents 2D or 3D
geometry.
|
boolean |
isHorizontal()
Get the state of the horizontal rendering flag.
|
boolean |
isLeftToRight()
Get the state of the left to right rendering flag.
|
boolean |
isTopToBottom()
Get the state of the top to bottom rendering flag.
|
protected boolean |
isVisible()
Check to see if this geometry is making the geometry visible or not.
|
boolean |
pickLineRay(float[] origin,
float[] direction,
boolean findAny,
float[] dataOut,
int dataOutFlags)
Check for all intersections against this geometry using a line ray and
return the exact distance away of the closest picking point.
|
boolean |
pickLineSegment(float[] start,
float[] end,
boolean findAny,
float[] dataOut,
int dataOutFlags)
Check for all intersections against this geometry using a line segment and
return the exact distance away of the closest picking point.
|
protected void |
recomputeBounds()
Internal method to recalculate the implicit bounds of this Node.
|
void |
render(com.jogamp.opengl.GL2 gl)
This method is called to render this node.
|
void |
setCharacterCreator(org.j3d.geom.CharacterCreator charGen)
Replace the internal character generator with another.
|
void |
setHorizontal(boolean horizontal)
Change whether the text should be rendered vertically or horizontally.
|
void |
setHorizontalJustification(int justify)
Change the horizontal justification of the text.
|
void |
setLeftToRight(boolean leftToRight)
Change whether the text should be placing characters left to right or
right to left.
|
protected void |
setLive(boolean state)
Notification that this object is live now.
|
void |
setSize(float size)
Change size multiplier of a single row of text.
|
void |
setSpacing(float spacing)
Change spacing multiplier between rows of text.
|
void |
setText(String[] text,
int numText)
Set the list of strings that you want to have rendered.
|
void |
setTopToBottom(boolean topToBottom)
Change whether the text should be placed from top to bottom or bottom
to top.
|
void |
setVerticalJustification(int justify)
Change the vertical justification of the text.
|
addParent, boundsChanged, checkPickMask, getBounds, getPickableBounds, getPickMask, getPickTargetType, hasTransparency, markBoundsDirty, pickBatch, pickSingle, removeParent, setBounds, setPickMask, updateBoundsaddParent, getParents, numParents, removeParentcheckForCyclicChild, checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setUpdateHandler, setUserDatapublic static final int JUSTIFY_FIRST
public static final int JUSTIFY_BEGIN
public static final int JUSTIFY_MIDDLE
public static final int JUSTIFY_END
public Text2D()
public Text2D(org.j3d.geom.CharacterCreator charGen)
CharacterCreator. If the argument is null, then
the default generator is used.charGen - The creator of characters to use, or nullpublic void render(com.jogamp.opengl.GL2 gl)
gl - The gl context to draw withpublic int compareTo(Object o) throws ClassCastException
o - The objec to be comparedClassCastException - The specified object's type prevents it from
being compared to this Objectpublic boolean equals(Object o)
protected boolean isVisible()
public boolean is2D()
EffectRenderable, while 3D is.
Note that this can be changed depending on the type of geometry itself.
A Shape3D node with an IndexedLineArray that only has 2D coordinates is
as much a 2D geometry as a raster object.protected void setLive(boolean state)
setLive in class SceneGraphObjectstate - true if this should be marked as live nowprotected void recomputeBounds()
recomputeBounds in class Geometrypublic boolean pickLineSegment(float[] start,
float[] end,
boolean findAny,
float[] dataOut,
int dataOutFlags)
throws NotPickableException
pickLineSegment in interface LeafPickTargetpickLineSegment in class Geometrystart - The start point of the segmentend - The end point of the segmentfindAny - True if it only has to find a single intersection and can
exit as soon as it finds the first intersection. False if it must find
the closest polygondataOut - An array to put the data in for the intersection. Exact
format is described by the flagsdataOutFlags - A set of derived-class specific flags describing what
data should be included in the output arrayNotPickableException - This object has been marked as non pickable,
but you decided to try to call the method anywaypublic boolean pickLineRay(float[] origin,
float[] direction,
boolean findAny,
float[] dataOut,
int dataOutFlags)
throws NotPickableException
pickLineRay in interface LeafPickTargetpickLineRay in class Geometryorigin - The start point of the raydirection - The direction vector of the rayfindAny - True if it only has to find a single intersection and can
exit as soon as it finds the first intersection. False if it must find
the closest polygondataOut - An array to put the data in for the intersection. Exact
format is described by the flagsdataOutFlags - A set of derived-class specific flags describing what
data should be included in the output arrayNotPickableException - This object has been marked as non pickable,
but you decided to try to call the method anywaypublic void setCharacterCreator(org.j3d.geom.CharacterCreator charGen)
charGen - The creator of characters to use, or nullpublic void setText(String[] text, int numText)
text - An array of strings to rendernumText - The number of strings to renderInvalidWriteTimingException - An attempt was made to write outside
of the NodeUpdateListener bounds callback methodpublic String[] getText()
public void setHorizontal(boolean horizontal)
throws InvalidWriteTimingException
horizontal - true if the text should be rendered horizontallyInvalidWriteTimingException - An attempt was made to write outside
of the NodeUpdateListener bounds callback methodpublic boolean isHorizontal()
public void setLeftToRight(boolean leftToRight)
throws InvalidWriteTimingException
leftToRight - true if the text should be rendered leftToRightlyInvalidWriteTimingException - An attempt was made to write outside
of the NodeUpdateListener bounds callback methodpublic boolean isLeftToRight()
public void setTopToBottom(boolean topToBottom)
throws InvalidWriteTimingException
topToBottom - true if the text should be rendered top to bottomInvalidWriteTimingException - An attempt was made to write outside
of the NodeUpdateListener bounds callback methodpublic boolean isTopToBottom()
public void setSpacing(float spacing)
throws InvalidWriteTimingException,
IllegalArgumentException
spacing - true if the text should be rendered horizontallyIllegalArgumentException - The value was not positiveInvalidWriteTimingException - An attempt was made to write outside
of the NodeUpdateListener bounds callback methodpublic float getSpacing()
public void setSize(float size)
throws InvalidWriteTimingException,
IllegalArgumentException
size - true if the text should be rendered horizontallyIllegalArgumentException - The value was not positiveInvalidWriteTimingException - An attempt was made to write outside
of the NodeUpdateListener bounds callback methodpublic float getSize()
public void setHorizontalJustification(int justify)
throws InvalidWriteTimingException,
IllegalArgumentException
justify - One of the JUSTIFY_ valuesIllegalArgumentException - The value was not validInvalidWriteTimingException - An attempt was made to write outside
of the NodeUpdateListener bounds callback methodpublic float getHorizontalJustification()
public void setVerticalJustification(int justify)
throws InvalidWriteTimingException,
IllegalArgumentException
justify - One of the JUSTIFY_ valuesIllegalArgumentException - The value was not validInvalidWriteTimingException - An attempt was made to write outside
of the NodeUpdateListener bounds callback methodpublic float getVerticalJustification()
public int compareTo(Text2D txt)
txt - The argument instance to be comparedpublic boolean equals(Text2D txt)
txt - The Text2D instance to be compared
Copyright © 2001 - 2015 j3d.org