public class PText extends PNode
PNode.PSceneGraphDelegate
Modifier and Type | Field and Description |
---|---|
static Font |
DEFAULT_FONT
Default font, 12 point
"SansSerif" . |
static double |
DEFAULT_GREEK_THRESHOLD
Default greek threshold,
5.5d . |
static float |
DEFAULT_HORIZONTAL_ALIGNMENT
Default horizontal alignment,
Component.LEFT_ALIGNMENT . |
static String |
DEFAULT_TEXT
Default text,
"" . |
static Paint |
DEFAULT_TEXT_PAINT
Default text paint,
Color.BLACK . |
protected double |
greekThreshold
Greek threshold in screen font size for this text node.
|
static int |
PROPERTY_CODE_FONT
The property code that identifies a change of this node's font (see
getFont ). |
static int |
PROPERTY_CODE_TEXT
The property code that identifies a change of this node's text (see
getText ). |
static int |
PROPERTY_CODE_TEXT_PAINT
The property code that identifies a change of this node's text paint (see
getTextPaint ). |
static String |
PROPERTY_FONT
The property name that identifies a change of this node's font (see
getFont ). |
static String |
PROPERTY_TEXT
The property name that identifies a change of this node's text (see
getText ). |
static String |
PROPERTY_TEXT_PAINT
The property name that identifies a change of this node's text paint (see
getTextPaint ). |
FILL_STRATEGY_ASPECT_COVER, FILL_STRATEGY_ASPECT_FIT, FILL_STRATEGY_EXACT_FIT, PROPERTY_BOUNDS, PROPERTY_CHILDREN, PROPERTY_CHILDREN_PICKABLE, PROPERTY_CLIENT_PROPERTIES, PROPERTY_CODE_BOUNDS, PROPERTY_CODE_CHILDREN, PROPERTY_CODE_CHILDREN_PICKABLE, PROPERTY_CODE_CLIENT_PROPERTIES, PROPERTY_CODE_FULL_BOUNDS, PROPERTY_CODE_PAINT, PROPERTY_CODE_PARENT, PROPERTY_CODE_PICKABLE, PROPERTY_CODE_TRANSFORM, PROPERTY_CODE_TRANSPARENCY, PROPERTY_CODE_VISIBLE, PROPERTY_FULL_BOUNDS, PROPERTY_PAINT, PROPERTY_PARENT, PROPERTY_PICKABLE, PROPERTY_TRANSFORM, PROPERTY_TRANSPARENCY, PROPERTY_VISIBLE, SCENE_GRAPH_DELEGATE
NO_SUCH_PAGE, PAGE_EXISTS
Constructor and Description |
---|
PText()
Create a new text node with no text (
"" ). |
PText(String text)
Create a new text node with the specified text.
|
Modifier and Type | Method and Description |
---|---|
protected TextLayout |
computeNextLayout(LineBreakMeasurer lineBreakMeasurer,
float availableWidth,
int nextLineBreakOffset)
Compute the next layout using the specified line break measurer,
available width, and next line break offset.
|
Font |
getFont()
Return the font for this text node.
|
double |
getGreekThreshold()
Return the greek threshold in screen font size.
|
float |
getHorizontalAlignment()
Return the horizontal alignment for this text node.
|
String |
getText()
Return the text for this text node.
|
Paint |
getTextPaint()
Return the paint used to paint this node's text.
|
protected void |
internalUpdateBounds(double x,
double y,
double width,
double height)
Gives nodes a chance to update their internal structure before bounds
changed notifications are sent.
|
boolean |
isConstrainHeightToTextHeight()
Return true if this text node should constrain its height to the height
of its text.
|
boolean |
isConstrainWidthToTextWidth()
Return true if this text node should constrain its width to the width of
its text.
|
protected void |
paint(PPaintContext paintContext)
Paint this node behind any of its children nodes.
|
protected void |
paintGreek(PPaintContext paintContext)
Paint greek with the specified paint context.
|
protected void |
paintText(PPaintContext paintContext)
Paint text with the specified paint context.
|
void |
recomputeLayout()
Compute the bounds of the text wrapped by this node.
|
void |
setConstrainHeightToTextHeight(boolean constrainHeightToTextHeight)
Set to
true if this text node should constrain its height to
the height of its text. |
void |
setConstrainWidthToTextWidth(boolean constrainWidthToTextWidth)
Set to
true if this text node should constrain its width to
the width of its text. |
void |
setFont(Font font)
Set the font for this text node to
font . |
void |
setGreekThreshold(double greekThreshold)
Set the greek threshold in screen font size to
greekThreshold . |
void |
setHorizontalAlignment(float horizontalAlignment)
Set the horizontal alignment for this text node to
horizontalAlignment . |
void |
setText(String newText)
Set the text for this node to
text . |
void |
setTextPaint(Paint textPaint)
Set the paint used to paint this node's text to
textPaint . |
addActivity, addAttribute, addChild, addChild, addChildren, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToRelativePosition, animateToTransform, animateToTransparency, animateTransformToBounds, centerBoundsOnPoint, centerFullBoundsOnPoint, clone, computeFullBounds, endResizeBounds, findIntersectingNodes, fireChildPropertyChange, firePropertyChange, fullIntersects, fullPaint, fullPick, getAllNodes, getAllNodes, getAttribute, getAttribute, getBooleanAttribute, getBounds, getBoundsChanged, getBoundsReference, getBoundsVolatile, getChild, getChildBoundsInvalid, getChildBoundsVolatile, getChildPaintInvalid, getChildrenCount, getChildrenIterator, getChildrenPickable, getChildrenReference, getClientProperties, getClientPropertyKeysEnumeration, getDoubleAttribute, getFullBounds, getFullBoundsInvalid, getFullBoundsReference, getGlobalBounds, getGlobalFullBounds, getGlobalRotation, getGlobalScale, getGlobalToLocalTransform, getGlobalTranslation, getHeight, getInputEventListeners, getIntegerAttribute, getInverseTransform, getListenerList, getLocalToGlobalTransform, getName, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, getPropertyChangeParentMask, getRoot, getRotation, getScale, getTransform, getTransformReference, getTransparency, getUnionOfChildrenBounds, getVisible, getWidth, getX, getXOffset, getY, getYOffset, globalToLocal, globalToLocal, globalToLocal, indexOfChild, intersects, invalidateFullBounds, invalidateLayout, invalidatePaint, isAncestorOf, isDescendentOf, isDescendentOfRoot, isOpaque, layoutChildren, lerp, localToGlobal, localToGlobal, localToGlobal, localToParent, localToParent, localToParent, lower, lower, lowerBelow, lowerToBottom, lowerToBottom, offset, paintAfterChildren, parentBoundsChanged, parentToLocal, parentToLocal, parentToLocal, pick, pickAfterChildren, print, print, raise, raise, raiseAbove, raiseToTop, raiseToTop, removeAllChildren, removeChild, removeChild, removeChildren, removeFromParent, removeInputEventListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaintFrom, reparent, replaceWith, resetBounds, rotate, rotateAboutPoint, rotateAboutPoint, rotateInPlace, scale, scaleAboutPoint, scaleAboutPoint, setBounds, setBounds, setBoundsChanged, setChildBoundsInvalid, setChildBoundsVolatile, setChildPaintInvalid, setChildrenPickable, setFullBoundsInvalid, setGlobalRotation, setGlobalScale, setGlobalTranslation, setHeight, setName, setOccluded, setOffset, setOffset, setPaint, setPaintInvalid, setParent, setPickable, setPropertyChangeParentMask, setRotation, setScale, setTransform, setTransparency, setVisible, setWidth, setX, setY, signalBoundsChanged, startResizeBounds, toImage, toImage, toImage, toImage, transformBy, translate, validateFullBounds, validateFullPaint
public static final String PROPERTY_TEXT
getText
). Both old and new value will be set in any
property change event.public static final int PROPERTY_CODE_TEXT
getText
). Both old and new value will be set in any
property change event.public static final String PROPERTY_FONT
getFont
). Both old and new value will be set in any
property change event.public static final int PROPERTY_CODE_FONT
getFont
). Both old and new value will be set in any
property change event.public static final String PROPERTY_TEXT_PAINT
getTextPaint
). Both old and new value will be set
in any property change event.public static final int PROPERTY_CODE_TEXT_PAINT
getTextPaint
). Both old and new value will be set
in any property change event.public static final Font DEFAULT_FONT
"SansSerif"
. Will be made final in
version 2.0.public static final double DEFAULT_GREEK_THRESHOLD
5.5d
. Will be made final in version
2.0.public static final float DEFAULT_HORIZONTAL_ALIGNMENT
Component.LEFT_ALIGNMENT
.public static final String DEFAULT_TEXT
""
.public static final Paint DEFAULT_TEXT_PAINT
Color.BLACK
.protected double greekThreshold
public PText()
""
).public PText(String text)
text
- text for this text nodepublic float getHorizontalAlignment()
Component.LEFT_ALIGNMENT
,
Component.CENTER_ALIGNMENT
, or
Component.RIGHT_ALIGNMENT
. Defaults to
DEFAULT_HORIZONTAL_ALIGNMENT
.public void setHorizontalAlignment(float horizontalAlignment)
horizontalAlignment
.horizontalAlignment
- horizontal alignment, must be one of
Component.LEFT_ALIGNMENT
,
Component.CENTER_ALIGNMENT
, or
Component.RIGHT_ALIGNMENT
public Paint getTextPaint()
public void setTextPaint(Paint textPaint)
textPaint
.
This is a bound property.
textPaint
- text paintpublic boolean isConstrainWidthToTextWidth()
true
.public void setConstrainWidthToTextWidth(boolean constrainWidthToTextWidth)
true
if this text node should constrain its width to
the width of its text.constrainWidthToTextWidth
- true if this text node should constrain
its width to the width of its textpublic boolean isConstrainHeightToTextHeight()
true
.public void setConstrainHeightToTextHeight(boolean constrainHeightToTextHeight)
true
if this text node should constrain its height to
the height of its text.constrainHeightToTextHeight
- true if this text node should
constrain its height to the height of its textpublic double getGreekThreshold()
DEFAULT_GREEK_THRESHOLD
.paintGreek(PPaintContext)
public void setGreekThreshold(double greekThreshold)
greekThreshold
. When the screen font size will be below this
threshold the text is rendered as 'greek' instead of drawing the text
glyphs.greekThreshold
- greek threshold in screen font sizepaintGreek(PPaintContext)
public String getText()
DEFAULT_TEXT
.public void setText(String newText)
text
. The text will be broken
up into multiple lines based on the size of the text and the bounds width
of this node.
This is a bound property.
newText
- text for this text nodepublic Font getFont()
DEFAULT_FONT
.public void setFont(Font font)
font
. Note that in
Piccolo if you want to change the size of a text object it's often a
better idea to scale the PText node instead of changing the font size to
get that same effect. Using very large font sizes can slow performance.
This is a bound property.
font
- font for this text nodepublic void recomputeLayout()
protected TextLayout computeNextLayout(LineBreakMeasurer lineBreakMeasurer, float availableWidth, int nextLineBreakOffset)
lineBreakMeasurer
- line break measureravailableWidth
- available widthnextLineBreakOffset
- next line break offsetprotected void paintGreek(PPaintContext paintContext)
paintContext
- paint contextprotected void paintText(PPaintContext paintContext)
paintContext
- paint contextprotected void paint(PPaintContext paintContext)
protected void internalUpdateBounds(double x, double y, double width, double height)
internalUpdateBounds
in class PNode
x
- x position of boundsy
- y position of boundswidth
- width to apply to the boundsheight
- height to apply to the boundsCopyright © 1995-2013 Piccolo2D. All Rights Reserved.