|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.piccolo.PNode
edu.umd.cs.piccolo.nodes.PText
public class PText
PText is a multi-line text node. The text will flow to base on the width of the node's bounds.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class edu.umd.cs.piccolo.PNode |
---|
PNode.PSceneGraphDelegate |
Field Summary | |
---|---|
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 ). |
Fields inherited from interface java.awt.print.Printable |
---|
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary | |
---|---|
PText()
Create a new text node with no text ( "" ). |
|
PText(String text)
Create a new text node with the specified text. |
Method Summary | |
---|---|
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. |
float |
getJustification()
Deprecated. by getHorizontalAlignment() |
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 |
setJustification(float justification)
Deprecated. by setHorizontalAlignment(float) |
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 . |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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 Font DEFAULT_FONT
"SansSerif"
. Will be made final in
version 2.0.
public static 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
Constructor Detail |
---|
public PText()
""
).
public PText(String text)
text
- text for this text nodeMethod Detail |
---|
public float getJustification()
getHorizontalAlignment()
public void setJustification(float justification)
setHorizontalAlignment(float)
justification
- horizontal alignment value to assign to this 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 width 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 offset
protected void paintGreek(PPaintContext paintContext)
paintContext
- paint contextprotected void paintText(PPaintContext paintContext)
paintContext
- paint contextprotected void paint(PPaintContext paintContext)
paint
in class PNode
paintContext
- the paint context to use for painting the nodeprotected 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 bounds
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |