ReportMill 7.0 API

com.reportmill.shape
Class RMText

java.lang.Object
  extended bycom.reportmill.foundation.RMObject
      extended bycom.reportmill.shape.RMShape
          extended bycom.reportmill.shape.RMRectangle
              extended bycom.reportmill.shape.RMText
All Implemented Interfaces:
java.lang.Cloneable, com.reportmill.foundation.RMArchiver.Archiving

public class RMText
extends RMRectangle

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 Summary
static byte ALIGN_BOTTOM
           
static byte ALIGN_CENTER
           
static byte ALIGN_LEFT
           
static byte ALIGN_MIDDLE
           
static byte ALIGN_RIGHT
           
static byte ALIGN_TOP
           
static int BREAK_GLYPH
           
static int BREAK_LINE
           
static int BREAK_WORD
           
static byte WRAP_BASIC
           
static byte WRAP_NONE
           
static byte WRAP_SCALE
           
 
Fields inherited from class com.reportmill.shape.RMRectangle
_radius
 
Fields inherited from class com.reportmill.shape.RMShape
HandleMaxXMaxY, HandleMaxXMidY, HandleMaxXMinY, HandleMidXMaxY, HandleMidXMinY, HandleMinXMaxY, HandleMinXMidY, HandleMinXMinY, HandleWidth
 
Constructor Summary
RMText()
          Creates an empty text instance.
RMText(RMXString string)
          Creates a text instance initialized with the given RMXString.
RMText(java.lang.String plainText)
          Creates a text instance initialized with the given plain text String.
 
Method Summary
 boolean acceptsEvents()
          Editor method.
 boolean acceptsFirstEvent()
          Editor method.
 com.reportmill.text.RMTextLayout beginTextLayout()
          Returns an RMTextLayout, configured with the current RMText.
 java.lang.Object clone()
          Standard clone implementation.
 void copy(com.reportmill.foundation.RMObject anObj)
          Copies attributes from given object.
 int endIndex()
          Returns the last character index visible in this text.
 boolean equals(java.lang.Object anObj)
          Standard equals implementation.
 java.lang.Object fromXML(com.ribs.RXArchiver anArchiver, com.ribs.RXElement anElement)
          XML Unarchival.
 byte getAlign()
          Returns the alignment for char 0.
 java.lang.String getAlignString()
          Returns the alignment as a string, one of: "left", "center" or "right".
 RMRect getBoundsFromTextBounds(RMRect aRect)
          Returns bounds from given text bounds, adjusted to account for text margins.
 boolean getCoalesceNewlines()
          Returns whether text should coalesce consecutive newlines in rpgClone.
 boolean getDrawsSelectionRect()
          Returns whether text should always draw at least a light gray border (useful when editing).
 RMFont getFont()
          Returns the font for char 0.
 float getFontScale()
          Returns the scale to apply to all fonts in text's XString (defaults to 1).
 RMFormat getFormat()
          Returns the format for char 0.
 float getHeightToFit()
          Returns the ideal height for this RMText.
 float getHeightToFit(boolean includeFinalEmptyLine)
          Returns the ideal height for this RMText.
 void getHeightToFitReset()
          For efficiency, RMText's getHeightToFit() caches the results after calculating the ideal height.
 float getMarginBottom()
          Returns the bottom margin of the text (defaults to 0).
 float getMarginLeft()
          Returns the left margin of the text (default to 2).
 float getMarginRight()
          Returns the right margin of the text (defaults to 2).
 float getMarginTop()
          Returns the top margin of the text (defaults to 0).
 float getMaxLineHeight()
          Returns the maximum line height at char 0.
 float getMinLineHeight()
          Returns the minimum line height at char 0.
 RMXString.Outline getOutline()
          Returns the outline for char 0.
 RMPolygon getPolygonForFrag(com.reportmill.text.RMTextFrag aFrag)
           
 java.lang.String getText()
          Returns the text associated with this RMText as a plain String.
 RMRect getTextBounds()
          Returns the actual bounding rect of the text (currently just inset 2 pixels on either side).
 RMColor getTextColor()
          Returns the color of the first character of the xstring associated with this RMText.
 RMPoint getTextOrigin()
          Returns the point inside this text where the first character is placed.
 byte getVAlign()
          Returns the vertical alignment.
 java.lang.String getVAlignString()
          Returns the vertical alignment as a string, one of: "top", "middle" or "bottom".
 float getWidthToFit()
          Returns the ideal width for this RMText.
 byte getWraps()
          Returns the wrapping behavior for over-filled rpgCloned text (NONE, WRAP, SHRINK).
 RMXString getXString()
          Returns the XString associated with this RMText.
 RMXString getXString(boolean create)
          Returns the XString associated with this RMText, creating it if needed
 int handleCount()
          Editor method - returns handle count.
 RMRect handleRect(int handle, boolean isSuperSelected)
          Editor method - returns handle rect.
 java.lang.Object initWithArchiver(com.reportmill.foundation.RMArchiver anArchiver)
          Legacy unarchival.
 boolean isStructured()
          Editor method.
 boolean isUnderlined()
          Returns if char 0 is underlined.
 int length()
          Returns the length, in characters, of the XString associated with this RMText.
 boolean renderedAll()
          Returns whether all characters were rendered.
 void resolvePageReferences(com.reportmill.foundation.ReportMill reportMill, java.lang.Object userInfo)
          Re-does the RPG clone to resolve any @Page@ keys (assumed to be present in userInfo).
 RMShape rpgClone(com.reportmill.foundation.ReportMill reportMill)
          This method clones the RMText, performing subtition on the XString.
 void rpgClonePreprocess(com.reportmill.foundation.ReportMill reportMill)
          This standard rpgClone hook allows texts set to wrap to perform the wrap.
 void scaleTextToFit()
           
 void setAlign(int align)
          Sets the align for all chars.
 void setCoalesceNewlines(boolean aFlag)
          Sets whether text should coalesce consecutive newlines in rpgClone.
 void setDrawsSelectionRect(boolean aValue)
          Sets whether text should always draw at least a light-gray border (useful when editing).
 void setFont(RMFont font)
          Sets the font for all characters.
 void setFontScale(float aFactor)
          Sets the scale to apply to all fonts in text's XString.
 void setFormat(RMFormat f)
          Sets the format for all characters.
 void setMaxLineHeight(float aHeight)
          Sets the maximum line height for all chars.
 void setMinLineHeight(float aHeight)
          Sets the minimum line height for all chars.
 void setOutline(RMXString.Outline anOutline)
          Sets the Outline for all characters.
 void setText(RMXString s)
          Sets the XString associated with this RMText.
 void setText(java.lang.String aString)
          Replaces the current text associated with this RMText with the given String.
 void setTextColor(RMColor aColor)
          Sets the color of the characters in the XString associated with this RMText.
 void setUnderlined(boolean aFlag)
          Sets all chars to be underlined.
 void setVAlign(byte anAlignment)
          Sets the vertical alginment.
 void setWraps(byte aValue)
          Sets the wrapping behavior for over-filled rpgCloned text (NONE, WRAP, SHRINK).
 void setXString(RMXString s)
          Sets the XString associated with this RMText.
 int startIndex()
          Returns the first character index visible in this text.
 java.lang.String toString()
          Standard toSring implementation.
 com.ribs.RXElement toXML(com.ribs.RXArchiver anArchiver)
          XML Archival.
 RMShape turnToChars(boolean inPlace)
          Returns a group shape with an RMText shape for each glyph in the text.
 RMShape turnToPath(boolean inPlace)
          Returns an RMPolygon shape with the glyph path for the chars in this text.
 
Methods inherited from class com.reportmill.shape.RMRectangle
getPath, getRadius, setRadius
 
Methods inherited from class com.reportmill.shape.RMShape
acceptsChildren, acceptsDragKeys, acceptsFormat, addChild, addChild, addChildBelowLastChild, boundsChanged, boundsChanged, bringShapesToFront, canBeUngrouped, childHitByPoint, childrenHitByPath, childrenSuperSelectImmediately, cloneDeep, convertedPointFromShape, convertedPointToShape, convertedRectFromShape, convertedRectToShape, convertedSizeFromShape, convertedSizeToShape, convertedVectorFromShape, convertedVectorToShape, convertFromShape, convertPathFromShape, convertPathToShape, convertPointFromShape, convertPointToShape, convertRectFromShape, convertRectToShape, convertSizeFromShape, convertSizeToShape, convertToShape, convertVectorFromShape, convertVectorToShape, copyShape, didChange, divideShapeFromEdge, divideShapeFromTop, dragExit, dragKeyAtPoint, drawChildren, drawsFill, drawsStroke, dropKeyAtPoint, fromXMLDeep, get, getActionScript, getAnim, getAnim, getAnimator, getAnimator, getAutosizeHeight, getAutosizing, getBounds, getBounds, getBoundsInside, getBoundsMarked, getBoundsOfChildren, getBoundsOfChildren, getBoundsOfPath, getBoundsOrigin, getBoundsSize, getBoundsSuperSelected, getChild, getChildAnimator, getChildAnimator, getChildCount, getChildLast, getChildren, getChildWithClass, getChildWithName, getColor, getCommonAncestor, getDocument, getFill, getGroupShape, getHeight, getImageData, getImageFill, getLineWidth, getListKey, getListKeyDeep, getListKeyShape, getName, getOpacity, getOpacityDeep, getOrigin, getPageCount, getPageShape, getParent, getParentCount, getParents, getPathInBounds, getRoll, getRootShape, getScaleX, getScaleY, getShapesToAncestor, getShapesToDescendant, getShapesToShape, getSize, getSkewX, getSkewY, getStroke, getStrokeColor, getTransform, getTransformFromShape, getTransformInverse, getTransformToShape, getUndoer, getUrl, getWidth, getX, getY, groupShapes, handleAtPoint, handlePoint, hasPageBreaks, height, hitByPath, hitByPoint, hitChildren, indexOf, indexOf, isAncestor, isDescendant, isLocked, isRoot, maxX, maxXInside, maxY, maxYInside, midX, midXInside, midY, midYInside, minX, minXInside, minY, minYInside, moveHandleToPoint, notRSS, offsetChildrenXY, offsetXY, opposingHandle, page, pageBreakMax, pageBreakPageMax, pageMax, put, reclaimChildren, removeChild, removeChild, removeChildren, removeChildren, removeFromParent, rpgCloneBase, rpgCloneChildren, rpgCloneConclude, rpgCloneNotification, rpgClonePrepare, rpgCloneUrl, sendShapesToBack, setActionScript, setAnim, setAutosizeHeight, setAutosizing, setBounds, setBounds, setBoundsOrigin, setBoundsOrigin, setBoundsOriginX, setBoundsOriginY, setBoundsSize, setBoundsSize, setChildAnimator, setChildren, setColor, setColor, setDrawsFill, setDrawsStroke, setEverythingStretches, setFill, setFill, setHeight, setHeightDeep, setHeightDeep, setHeightToFit, setLineWidth, setListKey, setLocked, setName, setNeedsRepaint, setNeedsRepaint, setOnlyBottomAndRightMarginStretches, setOnlyTopAndRightMarginStretches, setOnlyWidthAndHeightStretches, setOpacity, setOrigin, setOrigin, setParent, setRoll, setScaleX, setScaleXY, setScaleXY, setScaleY, setSize, setSize, setSizeDeep, setSizeDeep, setSizeToFit, setSizeToFit, setSkewX, setSkewXY, setSkewXY, setSkewY, setStroke, setStroke, setStrokeColor, setStrokeColor, setTime, setUrl, setWidth, setWidthDeep, setWidthDeep, setWidthToFit, setX, setXY, setXY, setXYWidthHeight, setY, sizesToFitChildren, superSelectable, superSelectImmediately, undoClone, undoCopy, undoEquals, undoerAddDirtyObject, undoerDisable, undoerEnable, undoerSetUndoTitle, width, willChange, willChange, x, y
 
Methods inherited from class com.reportmill.foundation.RMObject
archiverClassName, didUndo, getAnimAttribute, getClassNameShort
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALIGN_LEFT

public static final byte ALIGN_LEFT
See Also:
Constant Field Values

ALIGN_CENTER

public static final byte ALIGN_CENTER
See Also:
Constant Field Values

ALIGN_RIGHT

public static final byte ALIGN_RIGHT
See Also:
Constant Field Values

ALIGN_TOP

public static final byte ALIGN_TOP
See Also:
Constant Field Values

ALIGN_MIDDLE

public static final byte ALIGN_MIDDLE
See Also:
Constant Field Values

ALIGN_BOTTOM

public static final byte ALIGN_BOTTOM
See Also:
Constant Field Values

WRAP_NONE

public static final byte WRAP_NONE
See Also:
Constant Field Values

WRAP_BASIC

public static final byte WRAP_BASIC
See Also:
Constant Field Values

WRAP_SCALE

public static final byte WRAP_SCALE
See Also:
Constant Field Values

BREAK_GLYPH

public static final int BREAK_GLYPH
See Also:
Constant Field Values

BREAK_WORD

public static final int BREAK_WORD
See Also:
Constant Field Values

BREAK_LINE

public static final int BREAK_LINE
See Also:
Constant Field Values
Constructor Detail

RMText

public RMText()
Creates an empty text instance.


RMText

public RMText(RMXString string)
Creates a text instance initialized with the given RMXString.


RMText

public RMText(java.lang.String plainText)
Creates a text instance initialized with the given plain text String.

Method Detail

getXString

public RMXString getXString()
Returns the XString associated with this RMText.


getXString

public RMXString getXString(boolean create)
Returns the XString associated with this RMText, creating it if needed


setXString

public void setXString(RMXString s)
Sets the XString associated with this RMText.


length

public int length()
Returns the length, in characters, of the XString associated with this RMText.


getText

public java.lang.String getText()
Returns the text associated with this RMText as a plain String.


setText

public void setText(java.lang.String aString)
Replaces the current text associated with this RMText with the given String.


setText

public void setText(RMXString s)
Sets the XString associated with this RMText.


getTextColor

public RMColor getTextColor()
Returns the color of the first character of the xstring associated with this RMText.

Overrides:
getTextColor in class RMShape

setTextColor

public void setTextColor(RMColor aColor)
Sets the color of the characters in the XString associated with this RMText.

Overrides:
setTextColor in class RMShape

getFont

public RMFont getFont()
Returns the font for char 0.

Overrides:
getFont in class RMShape

setFont

public void setFont(RMFont font)
Sets the font for all characters.

Overrides:
setFont in class RMShape

getFormat

public RMFormat getFormat()
Returns the format for char 0.

Overrides:
getFormat in class RMShape

setFormat

public void setFormat(RMFormat f)
Sets the format for all characters.

Overrides:
setFormat in class RMShape

isUnderlined

public boolean isUnderlined()
Returns if char 0 is underlined.

Overrides:
isUnderlined in class RMShape

setUnderlined

public void setUnderlined(boolean aFlag)
Sets all chars to be underlined.

Overrides:
setUnderlined in class RMShape

getOutline

public RMXString.Outline getOutline()
Returns the outline for char 0.

Overrides:
getOutline in class RMShape

setOutline

public void setOutline(RMXString.Outline anOutline)
Sets the Outline for all characters.

Overrides:
setOutline in class RMShape

getAlign

public byte getAlign()
Returns the alignment for char 0.


setAlign

public void setAlign(int align)
Sets the align for all chars.


getAlignString

public java.lang.String getAlignString()
Returns the alignment as a string, one of: "left", "center" or "right".


getVAlign

public byte getVAlign()
Returns the vertical alignment.


setVAlign

public void setVAlign(byte anAlignment)
Sets the vertical alginment.


getVAlignString

public java.lang.String getVAlignString()
Returns the vertical alignment as a string, one of: "top", "middle" or "bottom".


getDrawsSelectionRect

public boolean getDrawsSelectionRect()
Returns whether text should always draw at least a light gray border (useful when editing).


setDrawsSelectionRect

public void setDrawsSelectionRect(boolean aValue)
Sets whether text should always draw at least a light-gray border (useful when editing).


getCoalesceNewlines

public boolean getCoalesceNewlines()
Returns whether text should coalesce consecutive newlines in rpgClone.


setCoalesceNewlines

public void setCoalesceNewlines(boolean aFlag)
Sets whether text should coalesce consecutive newlines in rpgClone.


getWraps

public byte getWraps()
Returns the wrapping behavior for over-filled rpgCloned text (NONE, WRAP, SHRINK).


setWraps

public void setWraps(byte aValue)
Sets the wrapping behavior for over-filled rpgCloned text (NONE, WRAP, SHRINK).


getMinLineHeight

public float getMinLineHeight()
Returns the minimum line height at char 0.


setMinLineHeight

public void setMinLineHeight(float aHeight)
Sets the minimum line height for all chars.


getMaxLineHeight

public float getMaxLineHeight()
Returns the maximum line height at char 0.


setMaxLineHeight

public void setMaxLineHeight(float aHeight)
Sets the maximum line height for all chars.


getTextOrigin

public RMPoint getTextOrigin()
Returns the point inside this text where the first character is placed.


getMarginLeft

public float getMarginLeft()
Returns the left margin of the text (default to 2).


getMarginRight

public float getMarginRight()
Returns the right margin of the text (defaults to 2).


getMarginTop

public float getMarginTop()
Returns the top margin of the text (defaults to 0).


getMarginBottom

public float getMarginBottom()
Returns the bottom margin of the text (defaults to 0).


getTextBounds

public RMRect getTextBounds()
Returns the actual bounding rect of the text (currently just inset 2 pixels on either side).


getBoundsFromTextBounds

public RMRect getBoundsFromTextBounds(RMRect aRect)
Returns bounds from given text bounds, adjusted to account for text margins.


getWidthToFit

public float getWidthToFit()
Returns the ideal width for this RMText.

Overrides:
getWidthToFit in class RMShape

getHeightToFit

public float getHeightToFit()
Returns the ideal height for this RMText.

Overrides:
getHeightToFit in class RMShape

getHeightToFit

public float getHeightToFit(boolean includeFinalEmptyLine)
Returns the ideal height for this RMText. Provides an option to include the height of trailing newlines.


getHeightToFitReset

public void getHeightToFitReset()
For efficiency, RMText's getHeightToFit() caches the results after calculating the ideal height. This method resets that cached value, so it will be calculated from scratch the next time getHeightToFit() is called.


beginTextLayout

public com.reportmill.text.RMTextLayout beginTextLayout()
Returns an RMTextLayout, configured with the current RMText. Currently only used internally.


startIndex

public int startIndex()
Returns the first character index visible in this text.


endIndex

public int endIndex()
Returns the last character index visible in this text.


renderedAll

public boolean renderedAll()
Returns whether all characters were rendered.


scaleTextToFit

public void scaleTextToFit()

getFontScale

public float getFontScale()
Returns the scale to apply to all fonts in text's XString (defaults to 1).


setFontScale

public void setFontScale(float aFactor)
Sets the scale to apply to all fonts in text's XString.


rpgClone

public RMShape rpgClone(com.reportmill.foundation.ReportMill reportMill)
This method clones the RMText, performing subtition on the XString.

Overrides:
rpgClone in class RMShape

rpgClonePreprocess

public void rpgClonePreprocess(com.reportmill.foundation.ReportMill reportMill)
This standard rpgClone hook allows texts set to wrap to perform the wrap.

Overrides:
rpgClonePreprocess in class RMShape

resolvePageReferences

public void resolvePageReferences(com.reportmill.foundation.ReportMill reportMill,
                                  java.lang.Object userInfo)
Re-does the RPG clone to resolve any @Page@ keys (assumed to be present in userInfo).

Overrides:
resolvePageReferences in class RMShape

toString

public java.lang.String toString()
Standard toSring implementation.

Overrides:
toString in class RMShape

turnToChars

public RMShape turnToChars(boolean inPlace)
Returns a group shape with an RMText shape for each glyph in the text.


turnToPath

public RMShape turnToPath(boolean inPlace)
Returns an RMPolygon shape with the glyph path for the chars in this text. Assumes one frag.


getPolygonForFrag

public RMPolygon getPolygonForFrag(com.reportmill.text.RMTextFrag aFrag)

acceptsEvents

public boolean acceptsEvents()
Editor method.

Overrides:
acceptsEvents in class RMShape

acceptsFirstEvent

public boolean acceptsFirstEvent()
Editor method.

Overrides:
acceptsFirstEvent in class RMShape

isStructured

public boolean isStructured()
Editor method.


handleCount

public int handleCount()
Editor method - returns handle count.

Overrides:
handleCount in class RMShape

handleRect

public RMRect handleRect(int handle,
                         boolean isSuperSelected)
Editor method - returns handle rect.

Overrides:
handleRect in class RMShape

clone

public java.lang.Object clone()
Standard clone implementation.

Overrides:
clone in class RMShape

equals

public boolean equals(java.lang.Object anObj)
Standard equals implementation.

Overrides:
equals in class RMRectangle

copy

public void copy(com.reportmill.foundation.RMObject anObj)
Copies attributes from given object.

Overrides:
copy in class RMRectangle

initWithArchiver

public java.lang.Object initWithArchiver(com.reportmill.foundation.RMArchiver anArchiver)
Legacy unarchival.

Specified by:
initWithArchiver in interface com.reportmill.foundation.RMArchiver.Archiving
Overrides:
initWithArchiver in class RMRectangle

toXML

public com.ribs.RXElement toXML(com.ribs.RXArchiver anArchiver)
XML Archival.

Overrides:
toXML in class RMRectangle

fromXML

public java.lang.Object fromXML(com.ribs.RXArchiver anArchiver,
                                com.ribs.RXElement anElement)
XML Unarchival.

Overrides:
fromXML in class RMRectangle

ReportMill 7.0 API