edu.umd.cs.piccolox.nodes
Class PStyledText

java.lang.Object
  extended by edu.umd.cs.piccolo.PNode
      extended by edu.umd.cs.piccolox.nodes.PStyledText
All Implemented Interfaces:
java.awt.print.Printable, java.io.Serializable, java.lang.Cloneable

public class PStyledText
extends PNode

Author:
Lance Good
See Also:
Serialized Form

Nested Class Summary
protected static class PStyledText.LineInfo
          The info for rendering a and computing the bounds of a line
protected static class PStyledText.MetricsRunInfo
          Class to represent an integer run and the font in that run
protected static class PStyledText.RunInfo
          Simple class to represent an integer run
protected static class PStyledText.SegmentInfo
           
 
Nested classes/interfaces inherited from class edu.umd.cs.piccolo.PNode
PNode.PSceneGraphDelegate
 
Field Summary
protected  boolean constrainHeightToTextHeight
           
protected  boolean constrainWidthToTextWidth
           
protected  javax.swing.text.Document document
           
protected  boolean editing
           
protected  java.awt.Insets insets
           
protected  PStyledText.LineInfo[] lines
           
protected static java.awt.geom.Line2D paintLine
           
protected  java.util.ArrayList stringContents
           
protected static java.awt.font.FontRenderContext SWING_FRC
           
 
Fields inherited from class edu.umd.cs.piccolo.PNode
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
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
PStyledText()
          Constructor for PStyledText.
 
Method Summary
 void fullPaint(PPaintContext paintContext)
          Paint this node and all of its descendents.
 boolean getConstrainHeightToTextHeight()
          Controls whether this node changes its height to fit the height of its text.
 boolean getConstrainWidthToTextWidth()
          Controls whether this node changes its width to fit the width of its text.
 javax.swing.text.Document getDocument()
          Get the document for this PStyledText
 double getInitialFontHeight()
          Get the height of the font at the beginning of the document
 java.awt.Insets getInsets()
          Get the insets of the text
 boolean isEditing()
          Is this document editing
protected  void paint(PPaintContext paintContext)
          Paint this node behind any of its children nodes.
 void recomputeLayout()
          Compute the bounds of the text wrapped by this node.
 boolean setBounds(double x, double y, double w, double h)
          Add a call to recompute the layout after each bounds change
 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 setDocument(javax.swing.text.Document document)
          Set the document on this PStyledText
 void setEditing(boolean editing)
          Set whether this text is editing
 void setInsets(java.awt.Insets insets)
          Set the insets of the text
 void syncWithDocument()
           
 
Methods inherited from class edu.umd.cs.piccolo.PNode
addActivity, addAttribute, addChild, addChild, addChildren, addClientProperty, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToTransform, animateToTransparency, animateTransformToBounds, centerBoundsOnPoint, centerFullBoundsOnPoint, clone, computeFullBounds, endResizeBounds, findIntersectingNodes, fireChildPropertyChange, firePropertyChange, fullIntersects, fullPick, getAllNodes, getAllNodes, getAttribute, getAttribute, getBooleanAttribute, getBounds, getBoundsChanged, getBoundsReference, getBoundsVolatile, getChild, getChildBoundsInvalid, getChildBoundsVolatile, getChildPaintInvalid, getChildrenCount, getChildrenIterator, getChildrenPickable, getChildrenReference, getClientProperties, getClientProperty, getClientPropertyKeysEnumeration, getClientPropertyKeysIterator, getDoubleAttribute, getFullBounds, getFullBoundsInvalid, getFullBoundsReference, getGlobalBounds, getGlobalFullBounds, getGlobalRotation, getGlobalScale, getGlobalToLocalTransform, getGlobalTranslation, getHeight, getIntegerAttribute, getInverseTransform, getListenerList, getLocalToGlobalTransform, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, getPropertyChangeParentMask, getRoot, getRotation, getScale, getTransform, getTransformReference, getTransparency, getUnionOfChildrenBounds, getVisible, getWidth, getX, getXOffset, getY, getYOffset, globalToLocal, globalToLocal, globalToLocal, indexOfChild, internalUpdateBounds, intersects, invalidateFullBounds, invalidateLayout, invalidatePaint, isAncestorOf, isDescendentOf, isDescendentOfRoot, isOpaque, layoutChildren, lerp, localToGlobal, localToGlobal, localToGlobal, localToParent, localToParent, localToParent, moveInBackOf, moveInFrontOf, moveToBack, moveToFront, offset, paintAfterChildren, paramString, 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, setBoundsChanged, setChildBoundsInvalid, setChildBoundsVolatile, setChildPaintInvalid, setChildrenPickable, setFullBoundsInvalid, setGlobalRotation, setGlobalScale, setGlobalTranslation, setHeight, setOccluded, setOffset, setOffset, setPaint, setPaintInvalid, setParent, setPickable, setPropertyChangeParentMask, setRotation, setScale, setTransform, setTransparency, setVisible, setWidth, setX, setY, signalBoundsChanged, startResizeBounds, toImage, 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

SWING_FRC

protected static java.awt.font.FontRenderContext SWING_FRC

paintLine

protected static java.awt.geom.Line2D paintLine

document

protected javax.swing.text.Document document

stringContents

protected transient java.util.ArrayList stringContents

lines

protected transient PStyledText.LineInfo[] lines

editing

protected boolean editing

insets

protected java.awt.Insets insets

constrainHeightToTextHeight

protected boolean constrainHeightToTextHeight

constrainWidthToTextWidth

protected boolean constrainWidthToTextWidth
Constructor Detail

PStyledText

public PStyledText()
Constructor for PStyledText.

Method Detail

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


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


getConstrainWidthToTextWidth

public boolean getConstrainWidthToTextWidth()
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


getConstrainHeightToTextHeight

public boolean getConstrainHeightToTextHeight()
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


getDocument

public javax.swing.text.Document getDocument()
Get the document for this PStyledText


setDocument

public void setDocument(javax.swing.text.Document document)
Set the document on this PStyledText


syncWithDocument

public void syncWithDocument()

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. If the shrinkBoundsToFit parameter is true then after the text has been laid out the bounds of this node are shrunk to fit around those text bounds.


getInitialFontHeight

public double getInitialFontHeight()
Get the height of the font at the beginning of the document


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

fullPaint

public void fullPaint(PPaintContext paintContext)
Description copied from class: PNode
Paint this node and all of its descendents. Most subclasses do not need to override this method, they should override paint or paintAfterChildren instead.

Overrides:
fullPaint in class PNode
Parameters:
paintContext - the paint context to use for painting this node and its children

setEditing

public void setEditing(boolean editing)
Set whether this text is editing


isEditing

public boolean isEditing()
Is this document editing


setInsets

public void setInsets(java.awt.Insets insets)
Set the insets of the text


getInsets

public java.awt.Insets getInsets()
Get the insets of the text


setBounds

public boolean setBounds(double x,
                         double y,
                         double w,
                         double h)
Add a call to recompute the layout after each bounds change

Overrides:
setBounds in class PNode
Returns:
true if the bounds changed.


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