Package com.reportmill.text
Class RMTextLayout
java.lang.Object
com.reportmill.base.RMObject
com.reportmill.text.RMTextLayout
- All Implemented Interfaces:
RMArchiver.Archiving
,Cloneable
This class lays out characters in an RMXString inside a bounding rect.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte
static final byte
static final byte
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddLine()
Adds an empty line to the layout.Returns the text bounds for the text layout.int
getCharForPoint
(float x, float y) Returns the character index for the given x/y point.static RMColor
Returns the color associated with the given attributes (or black by default).int
getEnd()
Returns the last character laid out.static RMFont
Returns the font associated with the attributes at the given character position for the given XString.static RMFont
Returns the font associated with the given attributes (Helvetica12 by default).static RMFont
Returns the font associated with the given attributes (Helvetica12 by default).float
Returns the height of the layout.float
Returns height required to show all text.float
getHitX
(float x, float y) Returns the x hit for the horizontal line from given point to positve infinity.getLine
(int anIndex) Returns the specific text line at the given index.int
Returns the number of lines in the layout.getLineForChar
(int index) Returns the line for the given character index.getLineForChar
(int index, RMPoint suggestedPoint) Returns the line for the given character index, with an optional point as a hint.getLineForPointY
(float y) Returns the line index for the given y value.float
getLineHeightForChar
(int index) Returns the height of the line at the given character index.float
getLineHeightForChars
(int start, int end) Returns the height of the line for the given range of characters.int
getLineIndexForChar
(int index) Returns the line index for the given character index.int
getLineIndexForChar
(int index, RMPoint suggestedPoint) Returns the line index for the given character index, with an optional point as a hint.Returns the last text line.float
getLineYForChar
(int pos) Returns the top of the line for the given character index.boolean
Returns whether a word was found that over-ran a whole line by itself.float
getMaxX()
Returns the max x of the layout.float
getMaxY()
Returns the max y of the layout.Returns the next frag in the layout (use this to iterate until it returns null).static RMXString.Outline
getOutline
(Map attrs) Returns the Outline record for the given attributes map (or null for none).static RMParagraph
getParagraph
(Map attrs) Returns the paragraph from the given attributes map.getPath()
Returns the path that the text should wrap to.getPointForChar
(int index) Returns the text origin for the given character index.getPointForChar
(int index, RMPoint suggestedPoint) Returns the text origin for the given character index.static int
getScripting
(Map attrs) Returns the "scripting" of the given attributes map (1==super, -1==sub, 0==none).int
getStart()
Returns the starting character index.static RMTextLayout
Returns the RMTextLayout shared by the current thread.static int
getUnderlineStyle
(Map attrs) Returns the underline style of the given attributes map.float
getWidth()
Returns the width of the layout.float
Returns the width required to show text without wrapping.float
getX()
Returns the x position of the layout.Returns the XString to be layed out.float
getY()
Returns the y position of the layout.boolean
Returns whether all text was rendered within text bounds or path.static boolean
isUnderlined
(Map attrs) Returns whether the attributes map contains an underline attribute.int
length()
Returns the length of the chars that the layout is working with.void
Removes all lines from the layout.void
Removes the last line from the layout.void
Re-lays out text for current string and attributes (if necessary).void
rebuild()
Rebuilds the lines and frags of the layout (defers until needed).void
setAlignVertical
(int anAlign) Sets the vertical alignment of text.void
Sets the text bounds for the text layout.void
setDrawFinalEmptyLine
(boolean aFlag) Sets whether the layout should include the last line even if it's just a newline.void
setFontScale
(float aValue) Sets the font scale of the text layout.void
setGrowHorizontal
(boolean aFlag) Sets whether text can grow horizontally.void
setGrowVertical
(boolean aFlag) Sets whether text can grow vertically.void
Sets the path that the text should wrap to.void
setStartIndex
(int anIndex) Sets the starting character index.void
setXString
(RMXString aString) Sets the XString to be layed out.Methods inherited from class com.reportmill.base.RMObject
clone, copy, didChange, didUndo, getAnimAttribute, getClassNameShort, initWithArchiver, undoClone, undoCopy, undoEquals
-
Field Details
-
ALIGN_TOP
public static final byte ALIGN_TOP- See Also:
-
ALIGN_MIDDLE
public static final byte ALIGN_MIDDLE- See Also:
-
ALIGN_BOTTOM
public static final byte ALIGN_BOTTOM- See Also:
-
-
Constructor Details
-
RMTextLayout
public RMTextLayout()
-
-
Method Details
-
getThreadInstance
Returns the RMTextLayout shared by the current thread. -
getXString
Returns the XString to be layed out. -
setXString
Sets the XString to be layed out. -
getX
public float getX()Returns the x position of the layout. -
getY
public float getY()Returns the y position of the layout. -
getWidth
public float getWidth()Returns the width of the layout. -
getHeight
public float getHeight()Returns the height of the layout. -
getMaxX
public float getMaxX()Returns the max x of the layout. -
getMaxY
public float getMaxY()Returns the max y of the layout. -
getBounds
Returns the text bounds for the text layout. -
setBounds
Sets the text bounds for the text layout. -
getWidthToFit
public float getWidthToFit()Returns the width required to show text without wrapping. -
getHeightToFit
public float getHeightToFit()Returns height required to show all text. -
getPath
Returns the path that the text should wrap to. -
setPath
Sets the path that the text should wrap to. -
setGrowVertical
public void setGrowVertical(boolean aFlag) Sets whether text can grow vertically. -
setGrowHorizontal
public void setGrowHorizontal(boolean aFlag) Sets whether text can grow horizontally. -
setAlignVertical
public void setAlignVertical(int anAlign) Sets the vertical alignment of text. -
setDrawFinalEmptyLine
public void setDrawFinalEmptyLine(boolean aFlag) Sets whether the layout should include the last line even if it's just a newline. -
setFontScale
public void setFontScale(float aValue) Sets the font scale of the text layout. -
length
public int length()Returns the length of the chars that the layout is working with. -
getStart
public int getStart()Returns the starting character index. -
setStartIndex
public void setStartIndex(int anIndex) Sets the starting character index. -
getEnd
public int getEnd()Returns the last character laid out. -
isAllTextVisible
public boolean isAllTextVisible()Returns whether all text was rendered within text bounds or path. -
rebuild
public void rebuild()Rebuilds the lines and frags of the layout (defers until needed). -
performLayout
public void performLayout()Re-lays out text for current string and attributes (if necessary). Called before enumerating frags. -
getNextFrag
Returns the next frag in the layout (use this to iterate until it returns null). -
getLineCount
public int getLineCount()Returns the number of lines in the layout. -
getLine
Returns the specific text line at the given index. -
getLineLast
Returns the last text line. -
addLine
Adds an empty line to the layout. -
linesRemoveAll
public void linesRemoveAll()Removes all lines from the layout. -
linesRemoveLast
public void linesRemoveLast()Removes the last line from the layout. -
getLineForChar
Returns the line for the given character index. -
getLineForChar
Returns the line for the given character index, with an optional point as a hint. -
getLineForPointY
Returns the line index for the given y value. -
getLineIndexForChar
public int getLineIndexForChar(int index) Returns the line index for the given character index. -
getLineIndexForChar
Returns the line index for the given character index, with an optional point as a hint. -
getPointForChar
Returns the text origin for the given character index. -
getPointForChar
Returns the text origin for the given character index. -
getCharForPoint
public int getCharForPoint(float x, float y) Returns the character index for the given x/y point. -
getLineHeightForChar
public float getLineHeightForChar(int index) Returns the height of the line at the given character index. -
getLineHeightForChars
public float getLineHeightForChars(int start, int end) Returns the height of the line for the given range of characters. -
getLineYForChar
public float getLineYForChar(int pos) Returns the top of the line for the given character index. -
getHitX
public float getHitX(float x, float y) Returns the x hit for the horizontal line from given point to positve infinity. -
getLongWordFound
public boolean getLongWordFound()Returns whether a word was found that over-ran a whole line by itself. -
getColor
Returns the color associated with the given attributes (or black by default). -
getFont
Returns the font associated with the given attributes (Helvetica12 by default). -
getFont
Returns the font associated with the given attributes (Helvetica12 by default). -
getFont
Returns the font associated with the attributes at the given character position for the given XString. -
getParagraph
Returns the paragraph from the given attributes map. -
isUnderlined
Returns whether the attributes map contains an underline attribute. -
getUnderlineStyle
Returns the underline style of the given attributes map. -
getOutline
Returns the Outline record for the given attributes map (or null for none). -
getScripting
Returns the "scripting" of the given attributes map (1==super, -1==sub, 0==none).
-