public class PStyledText extends PNode
Modifier and Type | Class and Description |
---|---|
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.
|
PNode.PSceneGraphDelegate
Modifier and Type | Field and Description |
---|---|
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 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 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 Line2D |
paintLine
Used while painting underlines.
|
protected ArrayList |
stringContents
String contents of the document.
|
protected static FontRenderContext |
SWING_FRC
Font rendering context used for all PStyledText instances.
|
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 |
---|
PStyledText()
Constructs an empty PStyledText element.
|
Modifier and Type | Method and Description |
---|---|
void |
fullPaint(PPaintContext paintContext)
Paint this node and all of its descendants.
|
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.
|
Document |
getDocument()
Get the document for this PStyledText.
|
double |
getInitialFontHeight()
Get the height of the font at the beginning of the document.
|
Insets |
getInsets()
Get the insets of the text.
|
boolean |
isEditing()
Whether node is currently in editing state.
|
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 width,
double height)
Set the bounds of this node to the given position and size.
|
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(Document document)
Set the document on this PStyledText.
|
void |
setEditing(boolean editing)
Set whether this node is current in editing mode.
|
void |
setInsets(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.
|
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
protected static FontRenderContext SWING_FRC
protected static Line2D paintLine
protected Document document
protected transient ArrayList stringContents
protected transient PStyledText.LineInfo[] lines
protected boolean editing
protected Insets insets
protected boolean constrainHeightToTextHeight
protected boolean constrainWidthToTextWidth
public void setConstrainWidthToTextWidth(boolean constrainWidthToTextWidth)
constrainWidthToTextWidth
- whether node's width should be
constrained to the width of its textpublic void setConstrainHeightToTextHeight(boolean constrainHeightToTextHeight)
constrainHeightToTextHeight
- whether node's height should be
constrained to the height of its textpublic boolean getConstrainWidthToTextWidth()
public boolean getConstrainHeightToTextHeight()
public Document getDocument()
public void setDocument(Document document)
document
- to be used as the model for this PStyledTextpublic void syncWithDocument()
public void recomputeLayout()
public double getInitialFontHeight()
protected void paint(PPaintContext paintContext)
public void fullPaint(PPaintContext paintContext)
paint
or
paintAfterChildren
instead.public void setEditing(boolean editing)
editing
- value to set editing flagpublic boolean isEditing()
public void setInsets(Insets insets)
insets
- desired insetspublic Insets getInsets()
public boolean setBounds(double x, double y, double width, double height)
Copyright © 1995-2013 Piccolo2D. All Rights Reserved.