Package com.reportmill.shape
Class RMText
java.lang.Object
com.reportmill.base.RMObject
com.reportmill.shape.RMShape
com.reportmill.shape.RMRectangle
com.reportmill.shape.RMText
- All Implemented Interfaces:
- RMArchiver.Archiving,- Cloneable
- Direct Known Subclasses:
- RBText,- RMCell,- RMLinkedText
This class is an RMShape subclass for handling rich text. Text is probably the most common and useful element in a
 ReportMill template. You might use this class to programatically build or modify a template, like this:
 
   RMXString xstring = new RMXString("Hello world!", RMFont.getFont("Arial", 12), RMColor.red);
   RMText text = new RMText(xstring);
   template.getPage(0).addChild(text);
   text.setXY(36, 36);
   text.setSizeToFit();
 - 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final byteFields inherited from class com.reportmill.shape.RMShapeWRAP_TYPE_BOTH, WRAP_TYPE_NONE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionclone()Standard clone implementation.voidCopies attributes from given object.booleanStandard equals implementation.fromXML(RXArchiver anArchiver, RXElement anElement) XML unarchival.voidfromXMLFinish(RXArchiver anArchiver, RXElement anElement) XML reference unarchival - to unarchive linked text.bytegetAlign()Returns the alignment for char 0.Returns the alignment as a string, one of: "left", "center" or "right".byteReturns the vertical alignment.Returns the vertical alignment as a string, one of: "top", "middle" or "bottom".getBoundsFromTextBounds(RMRect aRect) Returns bounds from given text bounds, adjusted to account for text margins.floatReturns the char spacing at char 0.booleanReturns whether text should coalesce consecutive newlines in rpgClone.booleanReturns whether text should always draw at least a light gray border (useful when editing).getFont()Returns the font for char 0.floatReturns the scale to apply to all fonts in text's XString (defaults to 1).Returns the format for char 0.floatReturns the ideal height for this RMText.floatgetHeightToFit(boolean includeFinalEmptyLine) Returns the ideal height for this RMText.floatReturns the line gap at char 0.floatReturns the maximum line height at char 0.floatReturns the minimum line height at char 0.floatReturns the line spacing at char 0.Returns the linked text for this text (if any).floatReturns the bottom margin of the text (defaults to 0).floatReturns the left margin of the text (default to 2).floatReturns the right margin of the text (defaults to 2).floatReturns the top margin of the text (defaults to 1).Returns the outline for char 0.getPath()Returns the path for this shape.Overrides shape implementation to pass through getPathInBounds(inset).getPathInBounds(int inset) Returns the shape's path scaled to the shape's current bounds.Returns the shape that provides the path for this text to wrap text to.booleanReturns whether text should wrap around other shapes that cause wrap.getPolygonForFrag(RMTextFrag aFrag) Returns a polygon shape for the glyphs in a given text frag.getText()Returns the text associated with this RMText as a plain String.Returns the actual bounding rect of the text (currently just inset 2 pixels on either side).Returns the color of the first character of the xstring associated with this RMText.Returns a text layout configured for this text, with layout already performed.getTextLayout(boolean performLayout) Returns a text layout configured for this text, with an option to perform layout.Returns the point inside this text where the first character is placed.intReturns the last character index visible in this text.intReturns the first character index visible in this text.floatReturns the ideal width for this RMText.bytegetWraps()Returns the wrapping behavior for over-filled rpgCloned text (NONE, WRAP, SHRINK).Returns the XString associated with this RMText.initWithArchiver(RMArchiver anArchiver) Legacy unarchival.booleanReturns whether all characters can be visibly rendered in text bounds.booleanEditor method.booleanReturns if char 0 is underlined.intlength()Returns the length, in characters, of the XString associated with this RMText.voidpeerDidChange(RMShape aShape) This notification method is called when any peer is changed.voidresolvePageReferences(ReportMill aReportMill, Object userInfo) Re-does the RPG clone to resolve any @Page@ keys (assumed to be present in userInfo).rpgClone(ReportMill aReportMill) This method clones the RMText, performing subtition on the XString.voidrpgClonePreprocess(ReportMill aReportMill) This standard rpgClone hook allows texts set to wrap to perform the wrap.voidScales font sizes of all text in an RMText shape to fit in bounds.voidsetAlign(int align) Sets the align for all chars.voidsetAlignVertical(byte anAlignment) Sets the vertical alginment.voidsetCharSpacing(float aValue) Sets the char spacing for the text string.voidsetCoalesceNewlines(boolean aFlag) Sets whether text should coalesce consecutive newlines in rpgClone.voidsetDrawsSelectionRect(boolean aValue) Sets whether text should always draw at least a light-gray border (useful when editing).voidSets the font for all characters.voidsetFontScale(float aFactor) Sets the scale to apply to all fonts in text's XString.voidSets the format for all characters.voidsetHeight(double aValue) Overrides shape implementation to reset height to fit.voidsetHeightToFit(float aValue) Sets the text's height to fit (often called with -1 to force recalc).voidsetLineGap(float aHeight) Sets the line gap for all chars.voidsetLineHeightMax(float aHeight) Sets the maximum line height for all chars.voidsetLineHeightMin(float aHeight) Sets the minimum line height for all chars.voidsetLineSpacing(float aHeight) Sets the line spacing for all chars.voidsetLinkedText(RMLinkedText anLinkedText) Sets the linked text for this text (if any).voidEditor method - passes on repaints to linked text.voidsetOutline(RMXString.Outline anOutline) Sets the Outline for all characters.voidsetPathShape(RMShape aShape) Sets the shape that provides the path for this text to wrap text to.voidsetPerformsWrap(boolean aFlag) Sets whether text should wrap around other shapes that cause wrap.voidsetRadius(float aValue) Overrides rectangle implementation to potentially force text relayout.voidSets the XString associated with this RMText.voidReplaces the current text associated with this RMText with the given String.voidsetTextColor(RMColor aColor) Sets the color of the characters in the XString associated with this RMText.voidsetUnderlined(boolean aFlag) Sets all chars to be underlined.voidsetWraps(byte aValue) Sets the wrapping behavior for over-filled rpgCloned text (NONE, WRAP, SHRINK).voidSets the XString associated with this RMText.booleanEditor method - indicates that this shape can be super selected.toString()Standard toSring implementation.toXML(RXArchiver anArchiver) XML archival.turnToChars(boolean inPlace) Returns a group shape with an RMText shape for each glyph in the text.turnToPath(boolean inPlace) Returns an RMPolygon shape with the glyph path for the chars in this text.Methods inherited from class com.reportmill.shape.RMRectanglegetRadiusMethods inherited from class com.reportmill.shape.RMShapeacceptsChildren, acceptsDragKeys, acceptsFormat, acceptsMouse, addChild, addChild, addChildBelowLastChild, bounds, boundsChanged, boundsChanged, bringShapesToFront, canBeUngrouped, childrenSuperSelectImmediately, cloneDeep, contains, convertedPointFromShape, convertedPointToShape, convertedRectFromShape, convertedRectToShape, convertedSizeFromShape, convertedSizeToShape, convertedVectorFromShape, convertedVectorToShape, convertFromShape, convertPathFromShape, convertPathToShape, convertPointFromShape, convertPointToShape, convertRectFromShape, convertRectToShape, convertSizeFromShape, convertSizeToShape, convertToShape, convertVectorFromShape, convertVectorToShape, copyShape, delete, didChange, divideShapeFromEdge, divideShapeFromTop, dragExit, dragKeyAtPoint, dropKeyAtPoint, fromXMLDeep, get, getActionScript, getAnim, getAnim, getAnimator, getAnimator, getAutosizeHeight, getAutosizing, getBounds, getBoundsInside, getBoundsMarked, getBoundsOfChildren, getBoundsOfChildren, getBoundsSuperSelected, getCausesWrap, getCausesWrapType, getChild, getChildAnimator, getChildAnimator, getChildContaining, getChildCount, getChildLast, getChildren, getChildrenIntersecting, getChildrenWhoCauseWrap, getChildrenWhoDraw, getChildrenWhoHitTest, getChildSortedByX, getChildWithClass, getChildWithName, getColor, getCommonAncestor, getDocument, getFill, getFill, getFill, getFillCount, getFills, getFrame, getFrame, getFrameMaxX, getFrameMaxY, getFrameX, getFrameXY, getFrameY, getGroupShape, getHeight, getImageFill, getLineWidth, getListKey, getListKeyDeep, getListKeyShape, getMaxX, getMaxY, getName, getOpacity, getOpacityDeep, getPageCount, getPageShape, getParent, getParentCount, getParents, getPropertyKey, getPropertyKeyCount, getPropertyKeyName, getRoll, getRootShape, getScaleX, getScaleY, getShapesToAncestor, getShapesToDescendant, getShapesToShape, getSize, getSizeP, getSkewX, getSkewY, getStroke, getStrokeColor, getToolClassName, getTransform, getTransformFromShape, getTransformInverse, getTransformToShape, getUndoer, getUrl, getWidth, getX, getXY, getXYP, getY, groupShapes, hasPageBreaks, height, indexOf, indexOf, intersects, isAncestor, isDescendant, isLocked, isRoot, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, notRSS, offsetChildrenXY, offsetXY, page, pageBreakMax, pageBreakPageMax, pageMax, put, putPropertyKey, reclaimChildren, removeChild, removeChild, removeChildren, removeChildren, removeFromParent, rpgCloneBase, rpgCloneChildren, rpgCloneConclude, rpgCloneNotification, rpgClonePrepare, rpgCloneUrl, sendShapesToBack, setActionScript, setAnim, setAutosizeHeight, setAutosizing, setBounds, setBounds, setCausesWrapType, setChildren, setColor, setFill, setFrame, setFrame, setFrameSize, setFrameX, setFrameXY, setFrameXY, setFrameY, setHeightDeep, setHeightDeep, setHeightToFit, setLineWidth, setListKey, setLocked, setName, setNeedsRepaint, setOpacity, setParent, setRoll, setScaleX, setScaleXY, setScaleY, setSize, setSize, setSizeDeep, setSizeP, setSizeToFit, setSizeToFit, setSkewX, setSkewXY, setSkewY, setStroke, setStrokeColor, setTime, setUrl, setWidth, setWidthDeep, setWidthDeep, setWidthToFit, setX, setXY, setXY, setXYP, setY, sizesToFitChildren, undoClone, undoCopy, undoEquals, undoerAddDirtyObject, undoerDisable, undoerEnable, undoerSetUndoTitle, width, willChange, willChange, x, yMethods inherited from class com.reportmill.base.RMObjectdidUndo, getAnimAttribute, getClassNameShort
- 
Field Details- 
ALIGN_LEFTpublic static final byte ALIGN_LEFT- See Also:
 
- 
ALIGN_CENTERpublic static final byte ALIGN_CENTER- See Also:
 
- 
ALIGN_RIGHTpublic static final byte ALIGN_RIGHT- See Also:
 
- 
ALIGN_FULLpublic static final byte ALIGN_FULL- See Also:
 
- 
ALIGN_TOPpublic static final byte ALIGN_TOP- See Also:
 
- 
ALIGN_MIDDLEpublic static final byte ALIGN_MIDDLE- See Also:
 
- 
ALIGN_BOTTOMpublic static final byte ALIGN_BOTTOM- See Also:
 
- 
WRAP_NONEpublic static final byte WRAP_NONE- See Also:
 
- 
WRAP_BASICpublic static final byte WRAP_BASIC- See Also:
 
- 
WRAP_SCALEpublic static final byte WRAP_SCALE- See Also:
 
 
- 
- 
Constructor Details- 
RMTextpublic RMText()Creates an empty text instance.
- 
RMTextCreates a text instance initialized with the given RMXString.
- 
RMTextCreates a text instance initialized with the given plain text String.
 
- 
- 
Method Details- 
getXStringReturns the XString associated with this RMText.
- 
setXStringSets the XString associated with this RMText.
- 
lengthpublic int length()Returns the length, in characters, of the XString associated with this RMText.
- 
getTextReturns the text associated with this RMText as a plain String.
- 
setTextReplaces the current text associated with this RMText with the given String.
- 
setTextSets the XString associated with this RMText.
- 
getVisibleStartpublic int getVisibleStart()Returns the first character index visible in this text.
- 
getVisibleEndpublic int getVisibleEnd()Returns the last character index visible in this text.
- 
isAllTextVisiblepublic boolean isAllTextVisible()Returns whether all characters can be visibly rendered in text bounds.
- 
getFontReturns the font for char 0.
- 
setFontSets the font for all characters.
- 
getFormatReturns the format for char 0.
- 
setFormatSets the format for all characters.
- 
getTextColorReturns the color of the first character of the xstring associated with this RMText.- Overrides:
- getTextColorin class- RMShape
 
- 
setTextColorSets the color of the characters in the XString associated with this RMText.- Overrides:
- setTextColorin class- RMShape
 
- 
isUnderlinedpublic boolean isUnderlined()Returns if char 0 is underlined.- Overrides:
- isUnderlinedin class- RMShape
 
- 
setUnderlinedpublic void setUnderlined(boolean aFlag) Sets all chars to be underlined.- Overrides:
- setUnderlinedin class- RMShape
 
- 
getOutlineReturns the outline for char 0.- Overrides:
- getOutlinein class- RMShape
 
- 
setOutlineSets the Outline for all characters.- Overrides:
- setOutlinein class- RMShape
 
- 
getAlignpublic byte getAlign()Returns the alignment for char 0.
- 
setAlignpublic void setAlign(int align) Sets the align for all chars.
- 
getAlignStringReturns the alignment as a string, one of: "left", "center" or "right".
- 
getAlignVerticalpublic byte getAlignVertical()Returns the vertical alignment.
- 
setAlignVerticalpublic void setAlignVertical(byte anAlignment) Sets the vertical alginment.
- 
getAlignVerticalStringReturns the vertical alignment as a string, one of: "top", "middle" or "bottom".
- 
getWrapspublic byte getWraps()Returns the wrapping behavior for over-filled rpgCloned text (NONE, WRAP, SHRINK).
- 
setWrapspublic void setWraps(byte aValue) Sets the wrapping behavior for over-filled rpgCloned text (NONE, WRAP, SHRINK).
- 
getPerformsWrappublic boolean getPerformsWrap()Returns whether text should wrap around other shapes that cause wrap.
- 
setPerformsWrappublic void setPerformsWrap(boolean aFlag) Sets whether text should wrap around other shapes that cause wrap.
- 
getCoalesceNewlinespublic boolean getCoalesceNewlines()Returns whether text should coalesce consecutive newlines in rpgClone.
- 
setCoalesceNewlinespublic void setCoalesceNewlines(boolean aFlag) Sets whether text should coalesce consecutive newlines in rpgClone.
- 
getDrawsSelectionRectpublic boolean getDrawsSelectionRect()Returns whether text should always draw at least a light gray border (useful when editing).
- 
setDrawsSelectionRectpublic void setDrawsSelectionRect(boolean aValue) Sets whether text should always draw at least a light-gray border (useful when editing).
- 
getCharSpacingpublic float getCharSpacing()Returns the char spacing at char 0.
- 
setCharSpacingpublic void setCharSpacing(float aValue) Sets the char spacing for the text string.
- 
getLineSpacingpublic float getLineSpacing()Returns the line spacing at char 0.
- 
setLineSpacingpublic void setLineSpacing(float aHeight) Sets the line spacing for all chars.
- 
getLineGappublic float getLineGap()Returns the line gap at char 0.
- 
setLineGappublic void setLineGap(float aHeight) Sets the line gap for all chars.
- 
getLineHeightMinpublic float getLineHeightMin()Returns the minimum line height at char 0.
- 
setLineHeightMinpublic void setLineHeightMin(float aHeight) Sets the minimum line height for all chars.
- 
getLineHeightMaxpublic float getLineHeightMax()Returns the maximum line height at char 0.
- 
setLineHeightMaxpublic void setLineHeightMax(float aHeight) Sets the maximum line height for all chars.
- 
getTextOriginReturns the point inside this text where the first character is placed.
- 
getMarginLeftpublic float getMarginLeft()Returns the left margin of the text (default to 2).
- 
getMarginRightpublic float getMarginRight()Returns the right margin of the text (defaults to 2).
- 
getMarginToppublic float getMarginTop()Returns the top margin of the text (defaults to 1).
- 
getMarginBottompublic float getMarginBottom()Returns the bottom margin of the text (defaults to 0).
- 
getTextBoundsReturns the actual bounding rect of the text (currently just inset 2 pixels on either side).
- 
getBoundsFromTextBoundsReturns bounds from given text bounds, adjusted to account for text margins.
- 
getPathReturns the path for this shape.- Overrides:
- getPathin class- RMRectangle
 
- 
getPathInBoundsOverrides shape implementation to pass through getPathInBounds(inset).- Overrides:
- getPathInBoundsin class- RMShape
 
- 
getPathInBoundsReturns the shape's path scaled to the shape's current bounds.
- 
peerDidChangeThis notification method is called when any peer is changed.
- 
getPathShapeReturns the shape that provides the path for this text to wrap text to.
- 
setPathShapeSets the shape that provides the path for this text to wrap text to.
- 
setHeightpublic void setHeight(double aValue) Overrides shape implementation to reset height to fit.
- 
setRadiuspublic void setRadius(float aValue) Overrides rectangle implementation to potentially force text relayout.- Overrides:
- setRadiusin class- RMRectangle
 
- 
getLinkedTextReturns the linked text for this text (if any).
- 
setLinkedTextSets the linked text for this text (if any).
- 
getTextLayoutReturns a text layout configured for this text, with layout already performed.
- 
getTextLayoutReturns a text layout configured for this text, with an option to perform layout.
- 
getWidthToFitpublic float getWidthToFit()Returns the ideal width for this RMText.- Overrides:
- getWidthToFitin class- RMShape
 
- 
getHeightToFitpublic float getHeightToFit()Returns the ideal height for this RMText.- Overrides:
- getHeightToFitin class- RMShape
 
- 
getHeightToFitpublic float getHeightToFit(boolean includeFinalEmptyLine) Returns the ideal height for this RMText. Provides an option to include the height of trailing newlines.
- 
setHeightToFitpublic void setHeightToFit(float aValue) Sets the text's height to fit (often called with -1 to force recalc).
- 
scaleTextToFitpublic void scaleTextToFit()Scales font sizes of all text in an RMText shape to fit in bounds. Caches font scale factor in xstring.
- 
getFontScalepublic float getFontScale()Returns the scale to apply to all fonts in text's XString (defaults to 1).
- 
setFontScalepublic void setFontScale(float aFactor) Sets the scale to apply to all fonts in text's XString.
- 
rpgCloneThis method clones the RMText, performing subtition on the XString.
- 
rpgClonePreprocessThis standard rpgClone hook allows texts set to wrap to perform the wrap.- Overrides:
- rpgClonePreprocessin class- RMShape
 
- 
resolvePageReferencesRe-does the RPG clone to resolve any @Page@ keys (assumed to be present in userInfo).- Overrides:
- resolvePageReferencesin class- RMShape
 
- 
toStringStandard toSring implementation.
- 
turnToCharsReturns a group shape with an RMText shape for each glyph in the text.
- 
turnToPathReturns an RMPolygon shape with the glyph path for the chars in this text. Assumes one frag.
- 
getPolygonForFragReturns a polygon shape for the glyphs in a given text frag.
- 
superSelectablepublic boolean superSelectable()Editor method - indicates that this shape can be super selected.- Overrides:
- superSelectablein class- RMShape
 
- 
isStructuredpublic boolean isStructured()Editor method.
- 
setNeedsRepaintpublic void setNeedsRepaint()Editor method - passes on repaints to linked text.- Overrides:
- setNeedsRepaintin class- RMShape
 
- 
cloneStandard clone implementation.
- 
equalsStandard equals implementation.- Overrides:
- equalsin class- RMRectangle
 
- 
copyCopies attributes from given object.- Overrides:
- copyin class- RMRectangle
 
- 
initWithArchiverLegacy unarchival.- Specified by:
- initWithArchiverin interface- RMArchiver.Archiving
- Overrides:
- initWithArchiverin class- RMRectangle
 
- 
toXMLXML archival.- Overrides:
- toXMLin class- RMRectangle
 
- 
fromXMLXML unarchival.- Overrides:
- fromXMLin class- RMRectangle
 
- 
fromXMLFinishXML reference unarchival - to unarchive linked text.
 
-