edu.umd.cs.piccolox.nodes
Class PStyledText
java.lang.Object
edu.umd.cs.piccolo.PNode
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 and computing the bounds of a line. |
protected static class |
PStyledText.RunInfo
Simple class to represent an range within the document. |
protected static class |
PStyledText.SegmentInfo
Encapsulates information about a particular LineSegment. |
Field Summary |
protected boolean |
constrainHeightToTextHeight
Whether width will be forced to match containing text's height. |
protected boolean |
constrainWidthToTextWidth
Whether width will be forced to match containing text's width. |
protected javax.swing.text.Document |
document
Underlying document used to handle the complexities involved with
arbitrary text and formatting. |
protected boolean |
editing
Whether this node is currently being edited. |
protected java.awt.Insets |
insets
Insets represent how far away from the bounding box text will be drawn. |
protected PStyledText.LineInfo[] |
lines
Tracks the information about line metrics within the document. |
protected static java.awt.geom.Line2D |
paintLine
Used while painting underlines. |
protected java.util.ArrayList |
stringContents
String contents of the document. |
protected static java.awt.font.FontRenderContext |
SWING_FRC
Font rendering context used for all PStyledText instances. |
Fields inherited from class edu.umd.cs.piccolo.PNode |
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 |
Fields inherited from interface java.awt.print.Printable |
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary |
PStyledText()
Constructs an empty PStyledText element. |
Method Summary |
void |
fullPaint(PPaintContext paintContext)
|
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()
Whether node is currently in editing state. |
protected void |
paint(PPaintContext paintContext)
|
void |
recomputeLayout()
Compute the bounds of the text wrapped by this node. |
boolean |
setBounds(double x,
double y,
double width,
double height)
|
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 node is current in editing mode. |
void |
setInsets(java.awt.Insets insets)
Set the insets of the text. |
void |
syncWithDocument()
Enforce that the current display matches the styling of the underlying
document as closely as possible. |
Methods inherited from class edu.umd.cs.piccolo.PNode |
addActivity, addAttribute, addChild, addChild, addChildren, addClientProperty, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToRelativePosition, 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, 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, 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, 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 |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SWING_FRC
protected static java.awt.font.FontRenderContext SWING_FRC
- Font rendering context used for all PStyledText instances.
paintLine
protected static java.awt.geom.Line2D paintLine
- Used while painting underlines.
document
protected javax.swing.text.Document document
- Underlying document used to handle the complexities involved with
arbitrary text and formatting.
stringContents
protected transient java.util.ArrayList stringContents
- String contents of the document.
lines
protected transient PStyledText.LineInfo[] lines
- Tracks the information about line metrics within the document.
editing
protected boolean editing
- Whether this node is currently being edited.
insets
protected java.awt.Insets insets
- Insets represent how far away from the bounding box text will be drawn.
constrainHeightToTextHeight
protected boolean constrainHeightToTextHeight
- Whether width will be forced to match containing text's height.
constrainWidthToTextWidth
protected boolean constrainWidthToTextWidth
- Whether width will be forced to match containing text's width.
PStyledText
public PStyledText()
- Constructs an empty PStyledText element.
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
- Parameters:
constrainWidthToTextWidth
- whether node's width should be
constrained to the width of its text
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
- Parameters:
constrainHeightToTextHeight
- whether node's height should be
constrained to the height of its text
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
- Returns:
- true if node is constrained to the width of its text
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
- Returns:
- true if node is constrained to the height of its text
getDocument
public javax.swing.text.Document getDocument()
- Get the document for this PStyledText. Document is used as the node's
model.
- Returns:
- internal document used as a model of this PStyledText
setDocument
public void setDocument(javax.swing.text.Document document)
- Set the document on this PStyledText. Document is used as the node's
model.
- Parameters:
document
- to be used as the model for this PStyledText
syncWithDocument
public void syncWithDocument()
- Enforce that the current display matches the styling of the underlying
document as closely as possible.
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.
- Returns:
- height of font at the start of the document.
paint
protected void paint(PPaintContext paintContext)
-
- Overrides:
paint
in class PNode
fullPaint
public void fullPaint(PPaintContext paintContext)
-
- Overrides:
fullPaint
in class PNode
setEditing
public void setEditing(boolean editing)
- Set whether this node is current in editing mode.
- Parameters:
editing
- value to set editing flag
isEditing
public boolean isEditing()
- Whether node is currently in editing state.
- Returns:
- true if node is currently editing
setInsets
public void setInsets(java.awt.Insets insets)
- Set the insets of the text.
- Parameters:
insets
- desired insets
getInsets
public java.awt.Insets getInsets()
- Get the insets of the text.
- Returns:
- current text insets
setBounds
public boolean setBounds(double x,
double y,
double width,
double height)
-
- Overrides:
setBounds
in class PNode
Copyright © 1995-2010 Piccolo2D. All Rights Reserved.