Package com.mta.tehreer.layout
Class FrameResolver
java.lang.Object
com.mta.tehreer.layout.FrameResolver
This class resolves text frames by using a typesetter object.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateFrame
(int charStart, int charEnd) Creates a frame representing specified string range in source text.float
Returns the extra spacing to add after each line of a frame.boolean
Returns whether or not to tightly fit the lines horizontally in a frame.boolean
Returns whether or not to tightly fit the lines vertically in a frame.Returns the rectangle specifying the frame bounds.float
Returns the justification level which can range from 0.0 to 1.0.float
Returns the height multiplier to apply on each line of a frame.int
Returns the maximum number of lines that a frame should consist of.Returns the text alignment to apply on each line of a frame.Returns the truncation mode to apply on the last line of a frame in case of overflow.Returns the truncation place for the last line of a frame.Returns the typesetter to use for resolving frames.Returns the vertical alignment to apply on the contents of a frame.boolean
Returns whether or not to justify the lines in a frame.void
setExtraLineSpacing
(float extraLineSpacing) Sets the extra spacing to add after each line of a frame.void
setFitsHorizontally
(boolean fitsHorizontally) Sets whether or not to tightly fit the lines horizontally in a frame.void
setFitsVertically
(boolean fitsVertically) Sets whether or not to tightly fit the lines vertically in a frame.void
setFrameBounds
(RectF frameBounds) Sets the rectangle specifying the frame bounds.void
setJustificationEnabled
(boolean justificationEnabled) Sets whether or not to justify the lines in a frame.void
setJustificationLevel
(float justificationLevel) Sets the justification level which can range from 0.0 to 1.0.void
setLineHeightMultiplier
(float lineHeightMultiplier) Sets the height multiplier to apply on each line of a frame.void
setMaxLines
(int maxLines) Sets the maximum number of lines that a frame should consist of.void
setTextAlignment
(TextAlignment textAlignment) Sets the text alignment to apply on each line of a frame.void
setTruncationMode
(BreakMode truncationMode) Sets the truncation mode to apply on the last line of a frame in case of overflow.void
setTruncationPlace
(TruncationPlace truncationPlace) Sets the truncation place for the last line of a frame.void
setTypesetter
(Typesetter typesetter) Sets the typesetter to use for resolving frames.void
setVerticalAlignment
(VerticalAlignment verticalAlignment) Sets the vertical alignment to apply on the contents of a frame.
-
Constructor Details
-
FrameResolver
public FrameResolver()Constructs a frame resolver object.
-
-
Method Details
-
getTypesetter
Returns the typesetter to use for resolving frames.- Returns:
- The current typesetter object.
-
setTypesetter
Sets the typesetter to use for resolving frames.- Parameters:
typesetter
- A typesetter object.
-
getFrameBounds
Returns the rectangle specifying the frame bounds. The default value is an infinite rectangle at zero origin.- Returns:
- The current frame rectangle.
-
setFrameBounds
Sets the rectangle specifying the frame bounds. The default value is an infinite rectangle at zero origin.- Parameters:
frameBounds
- A rectangle specifying the frame bounds.
-
getFitsHorizontally
public boolean getFitsHorizontally()Returns whether or not to tightly fit the lines horizontally in a frame. The default value isfalse
.- Returns:
true
if horizontal fitting is enabled;false
otherwise.
-
setFitsHorizontally
public void setFitsHorizontally(boolean fitsHorizontally) Sets whether or not to tightly fit the lines horizontally in a frame. If enabled, the resulting frame will have a minimum width that tightly encloses all the lines of specified text. The default value isfalse
.- Parameters:
fitsHorizontally
- A boolean value specifying the horizontal fitting state.
-
getFitsVertically
public boolean getFitsVertically()Returns whether or not to tightly fit the lines vertically in a frame. The default value isfalse
.- Returns:
true
if vertical fitting is enabled;false
otherwise.
-
setFitsVertically
public void setFitsVertically(boolean fitsVertically) Sets whether or not to tightly fit the lines vertically in a frame. If enabled, the resulting frame will have a minimum height that tightly encloses all the lines of specified text. The default value isfalse
.- Parameters:
fitsVertically
- A boolean value specifying the vertical fitting state.
-
getTextAlignment
Returns the text alignment to apply on each line of a frame. The default value isTextAlignment.LEADING
.- Returns:
- The current text alignment.
-
setTextAlignment
Sets the text alignment to apply on each line of a frame. The default value isTextAlignment.LEADING
.- Parameters:
textAlignment
- A value ofTextAlignment
.
-
getVerticalAlignment
Returns the vertical alignment to apply on the contents of a frame. The default value isVerticalAlignment.TOP
.- Returns:
- The current vertical alignment.
-
setVerticalAlignment
Sets the vertical alignment to apply on the contents of a frame. The default value isVerticalAlignment.TOP
.- Parameters:
verticalAlignment
- A value ofVerticalAlignment
.
-
getTruncationMode
Returns the truncation mode to apply on the last line of a frame in case of overflow. The default value isBreakMode.LINE
.- Returns:
- The current truncation mode.
-
setTruncationMode
Sets the truncation mode to apply on the last line of a frame in case of overflow. The default value isBreakMode.LINE
.- Parameters:
truncationMode
- A value ofBreakMode
.
-
getTruncationPlace
Returns the truncation place for the last line of a frame.- Returns:
- The current truncation place.
-
setTruncationPlace
Sets the truncation place for the last line of a frame.The truncation is disabled if the value of
truncationPlace
isnull
.- Parameters:
truncationPlace
- A value ofTruncationPlace
.
-
isJustificationEnabled
public boolean isJustificationEnabled()Returns whether or not to justify the lines in a frame. The default value isfalse
. -
setJustificationEnabled
public void setJustificationEnabled(boolean justificationEnabled) Sets whether or not to justify the lines in a frame. The default value isfalse
.- Parameters:
justificationEnabled
- A boolean value specifying the justification enabled state.
-
getJustificationLevel
@FloatRange(from=0.0, to=1.0) public float getJustificationLevel()Returns the justification level which can range from 0.0 to 1.0. A lower value increases the tightness between words while a higher value decreases it. The default value is1.0f
.- Returns:
- The current justification level.
-
setJustificationLevel
public void setJustificationLevel(@FloatRange(from=0.0,to=1.0) float justificationLevel) Sets the justification level which can range from 0.0 to 1.0. A lower value increases the tightness between words while a higher value decreases it. The default value is1.0f
.- Parameters:
justificationLevel
- Justification level.
-
getMaxLines
public int getMaxLines()Returns the maximum number of lines that a frame should consist of.- Returns:
- The current max lines.
-
setMaxLines
public void setMaxLines(int maxLines) Sets the maximum number of lines that a frame should consist of.- Parameters:
maxLines
- Maximum number of lines.
-
getExtraLineSpacing
public float getExtraLineSpacing()Returns the extra spacing to add after each line of a frame. It is resolved before line height multiplier. The default value is zero.- Returns:
- The current extra line spacing.
- See Also:
-
setExtraLineSpacing
public void setExtraLineSpacing(float extraLineSpacing) Sets the extra spacing to add after each line of a frame. It is resolved before line height multiplier. The default value is zero.The extra spacing is added in the leading of each line soon after it is composed.
- Parameters:
extraLineSpacing
- The extra line spacing in pixels.- See Also:
-
getLineHeightMultiplier
public float getLineHeightMultiplier()Returns the height multiplier to apply on each line of a frame. It is resolved after extra line spacing. The default value is one.- Returns:
- The current line height multiplier.
- See Also:
-
setLineHeightMultiplier
public void setLineHeightMultiplier(float lineHeightMultiplier) Sets the height multiplier to apply on each line of a frame. It is resolved after extra line spacing. The default value is one.The additional spacing is adjusted in such a way that text remains in the middle of the line.
- Parameters:
lineHeightMultiplier
- The multiplication factor.- See Also:
-
createFrame
Creates a frame representing specified string range in source text.The resolver keeps on filling the frame until it either runs out of text or it finds that text no longer fits in frame bounds. The resulting frame consists of at least one line even if frame bounds are smaller.
- Parameters:
charStart
- The index to first character of the frame in source text.charEnd
- The index after the last character of the line in source text.- Returns:
- A new composed frame.
- Throws:
IllegalArgumentException
- ifcharStart
is negative, orcharEnd
is greater than the length of source text, orcharStart
is greater than or equal tocharEnd
.
-