edu.umd.cs.piccolo.nodes
Class PText

java.lang.Object
  extended byedu.umd.cs.piccolo.PNode
      extended byedu.umd.cs.piccolo.nodes.PText
All Implemented Interfaces:
java.lang.Cloneable, java.awt.print.Printable, java.io.Serializable

public class PText
extends PNode

PText is a multi-line text node. The text will flow to base on the width of the node's bounds.

Version:
1.1
Author:
Jesse Grosjean
See Also:
Serialized Form

Field Summary
static java.awt.Font DEFAULT_FONT
           
static double DEFAULT_GREEK_THRESHOLD
           
protected  double greekThreshold
           
static java.lang.String PROPERTY_FONT
          The property name that identifies a change of this node's font (see getFont).
static java.lang.String PROPERTY_TEXT
          The property name that identifies a change of this node's text (see getText).
 
Fields inherited from class edu.umd.cs.piccolo.PNode
PROPERTY_BOUNDS, PROPERTY_CHILDREN, PROPERTY_CHILDREN_PICKABLE, PROPERTY_CLIENT_PROPERTIES, PROPERTY_FULL_BOUNDS, PROPERTY_PAINT, PROPERTY_PARENT, PROPERTY_PICKABLE, PROPERTY_TRANSFORM, PROPERTY_TRANSPARENCY, PROPERTY_VISIBLE
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
PText()
           
PText(java.lang.String aText)
           
 
Method Summary
protected  java.awt.font.TextLayout computeNextLayout(java.awt.font.LineBreakMeasurer measurer, float availibleWidth, int nextLineBreakOffset)
           
 java.awt.Font getFont()
          Returns the font of this PText.
 double getGreekThreshold()
          Returns the current greek threshold.
 float getJustification()
          Return the justificaiton of the text in the bounds.
 java.lang.String getText()
           
 java.awt.Paint getTextPaint()
          Get the paint used to paint this nodes 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()
           
 boolean isConstrainWidthToTextWidth()
           
protected  void paint(PPaintContext paintContext)
          Paint this node behind any of its children nodes.
protected  java.lang.String paramString()
          Returns a string representing the state of this node.
 void recomputeLayout()
          Compute the bounds of the text wrapped by this node.
 void setConstrainHeightToTextHeight(boolean constrainHeightToTextHeight)
          Controls whether this node changes its height to fit the height of its text.
 void setConstrainWidthToTextWidth(boolean constrainWidthToTextWidth)
          Controls whether this node changes its width to fit the width of its text.
 void setFont(java.awt.Font aFont)
          Set the font of this PText.
 void setGreekThreshold(double threshold)
          Sets the current greek threshold.
 void setJustification(float just)
          Sets the justificaiton of the text in the bounds.
 void setText(java.lang.String aText)
          Set the text for this node.
 void setTextPaint(java.awt.Paint textPaint)
          Set the paint used to paint this node's text background.
 
Methods inherited from class edu.umd.cs.piccolo.PNode
addActivity, addChild, addChild, addChildren, addClientProperty, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToTransform, animateToTransparency, centerBoundsOnPoint, centerFullBoundsOnPoint, clone, computeFullBounds, endResizeBounds, findIntersectingNodes, firePropertyChange, fullIntersects, fullPaint, fullPick, getAllNodes, getAllNodes, getBounds, getBoundsChanged, getBoundsReference, getBoundsVolatile, getChild, getChildBoundsInvalid, getChildBoundsVolatile, getChildPaintInvalid, getChildrenCount, getChildrenIterator, getChildrenPickable, getChildrenReference, getClientProperty, getClientPropertyKeysIterator, getFullBounds, getFullBoundsInvalid, getFullBoundsReference, getGlobalBounds, getGlobalFullBounds, getGlobalRotation, getGlobalScale, getGlobalToLocalTransform, getGlobalTranslation, getHeight, getInverseTransform, getListenerList, getLocalToGlobalTransform, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, 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, moveInBackOf, moveInFrontOf, moveToBack, moveToFront, offset, paintAfterChildren, parentBoundsChanged, parentToLocal, parentToLocal, parentToLocal, pick, pickAfterChildren, position, print, print, 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, setOccluded, setOffset, setOffset, setPaint, setPaintInvalid, setParent, setPickable, setRotation, setScale, setTransform, setTransparency, setVisible, setWidth, setX, setY, signalBoundsChanged, startResizeBounds, toImage, toImage, toString, transformBy, translate, validateFullBounds, validateFullPaint
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_TEXT

public static final java.lang.String PROPERTY_TEXT
The property name that identifies a change of this node's text (see getText). Both old and new value will be set in any property change event.

See Also:
Constant Field Values

PROPERTY_FONT

public static final java.lang.String PROPERTY_FONT
The property name that identifies a change of this node's font (see getFont). Both old and new value will be set in any property change event.

See Also:
Constant Field Values

DEFAULT_FONT

public static java.awt.Font DEFAULT_FONT

DEFAULT_GREEK_THRESHOLD

public static double DEFAULT_GREEK_THRESHOLD

greekThreshold

protected double greekThreshold
Constructor Detail

PText

public PText()

PText

public PText(java.lang.String aText)
Method Detail

getJustification

public float getJustification()
Return the justificaiton of the text in the bounds.

Returns:
float

setJustification

public void setJustification(float just)
Sets the justificaiton of the text in the bounds.

Parameters:
just -

getTextPaint

public java.awt.Paint getTextPaint()
Get the paint used to paint this nodes text.

Returns:
Paint

setTextPaint

public void setTextPaint(java.awt.Paint textPaint)
Set the paint used to paint this node's text background.

Parameters:
textPaint -

isConstrainWidthToTextWidth

public boolean isConstrainWidthToTextWidth()

setConstrainWidthToTextWidth

public void setConstrainWidthToTextWidth(boolean constrainWidthToTextWidth)
Controls whether this node changes its width to fit the width of its text. If flag is true it does; if flag is false it doesn't


isConstrainHeightToTextHeight

public boolean isConstrainHeightToTextHeight()

setConstrainHeightToTextHeight

public void setConstrainHeightToTextHeight(boolean constrainHeightToTextHeight)
Controls whether this node changes its height to fit the height of its text. If flag is true it does; if flag is false it doesn't


getGreekThreshold

public double getGreekThreshold()
Returns the current greek threshold. When the screen font size will be below this threshold the text is rendered as 'greek' instead of drawing the text glyphs.


setGreekThreshold

public void setGreekThreshold(double threshold)
Sets the current greek threshold. When the screen font size will be below this threshold the text is rendered as 'greek' instead of drawing the text glyphs.

Parameters:
threshold - minimum screen font size.

getText

public java.lang.String getText()

setText

public void setText(java.lang.String aText)
Set the text for this node. The text will be broken up into multiple lines based on the size of the text and the bounds width of this node.


getFont

public java.awt.Font getFont()
Returns the font of this PText.

Returns:
the font of this PText.

setFont

public void setFont(java.awt.Font aFont)
Set the font of this PText. 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.


recomputeLayout

public void recomputeLayout()
Compute the bounds of the text wrapped by this node. The text layout is wrapped based on the bounds of this node.


computeNextLayout

protected java.awt.font.TextLayout computeNextLayout(java.awt.font.LineBreakMeasurer measurer,
                                                     float availibleWidth,
                                                     int nextLineBreakOffset)

paint

protected void paint(PPaintContext paintContext)
Description copied from class: PNode
Paint this node behind any of its children nodes. Subclasses that define a different appearance should override this method and paint themselves there.

Overrides:
paint in class PNode
Parameters:
paintContext - the paint context to use for painting the node

internalUpdateBounds

protected void internalUpdateBounds(double x,
                                    double y,
                                    double width,
                                    double height)
Description copied from class: PNode
Gives nodes a chance to update their internal structure before bounds changed notifications are sent. When this message is recived the nodes bounds field will contain the new value. See PPath for an example that uses this method.

Overrides:
internalUpdateBounds in class PNode

paramString

protected java.lang.String paramString()
Returns a string representing the state of this node. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overrides:
paramString in class PNode
Returns:
a string representation of this node's state


Copyright 2004 by University of Maryland, College Park, MD 20742, USA All rights reserved.