Class FrameResolver

java.lang.Object
com.mta.tehreer.layout.FrameResolver

public class FrameResolver extends Object
This class resolves text frames by using a typesetter object.
  • Constructor Details

    • FrameResolver

      public FrameResolver()
      Constructs a frame resolver object.
  • Method Details

    • getTypesetter

      public Typesetter getTypesetter()
      Returns the typesetter to use for resolving frames.
      Returns:
      The current typesetter object.
    • setTypesetter

      public void setTypesetter(@NonNull Typesetter typesetter)
      Sets the typesetter to use for resolving frames.
      Parameters:
      typesetter - A typesetter object.
    • getFrameBounds

      @NonNull public RectF getFrameBounds()
      Returns the rectangle specifying the frame bounds. The default value is an infinite rectangle at zero origin.
      Returns:
      The current frame rectangle.
    • setFrameBounds

      public void setFrameBounds(@NonNull RectF frameBounds)
      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 is false.
      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 is false.
      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 is false.
      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 is false.
      Parameters:
      fitsVertically - A boolean value specifying the vertical fitting state.
    • getTextAlignment

      @NonNull public TextAlignment getTextAlignment()
      Returns the text alignment to apply on each line of a frame. The default value is TextAlignment.LEADING.
      Returns:
      The current text alignment.
    • setTextAlignment

      public void setTextAlignment(@NonNull TextAlignment textAlignment)
      Sets the text alignment to apply on each line of a frame. The default value is TextAlignment.LEADING.
      Parameters:
      textAlignment - A value of TextAlignment.
    • getVerticalAlignment

      @NonNull public VerticalAlignment getVerticalAlignment()
      Returns the vertical alignment to apply on the contents of a frame. The default value is VerticalAlignment.TOP.
      Returns:
      The current vertical alignment.
    • setVerticalAlignment

      public void setVerticalAlignment(@NonNull VerticalAlignment verticalAlignment)
      Sets the vertical alignment to apply on the contents of a frame. The default value is VerticalAlignment.TOP.
      Parameters:
      verticalAlignment - A value of VerticalAlignment.
    • getTruncationMode

      @NonNull public BreakMode getTruncationMode()
      Returns the truncation mode to apply on the last line of a frame in case of overflow. The default value is BreakMode.LINE.
      Returns:
      The current truncation mode.
    • setTruncationMode

      public void setTruncationMode(@NonNull BreakMode truncationMode)
      Sets the truncation mode to apply on the last line of a frame in case of overflow. The default value is BreakMode.LINE.
      Parameters:
      truncationMode - A value of BreakMode.
    • getTruncationPlace

      public TruncationPlace getTruncationPlace()
      Returns the truncation place for the last line of a frame.
      Returns:
      The current truncation place.
    • setTruncationPlace

      public void setTruncationPlace(TruncationPlace truncationPlace)
      Sets the truncation place for the last line of a frame.

      The truncation is disabled if the value of truncationPlace is null.

      Parameters:
      truncationPlace - A value of TruncationPlace.
    • isJustificationEnabled

      public boolean isJustificationEnabled()
      Returns whether or not to justify the lines in a frame. The default value is false.
    • setJustificationEnabled

      public void setJustificationEnabled(boolean justificationEnabled)
      Sets whether or not to justify the lines in a frame. The default value is false.
      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 is 1.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 is 1.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

      @NonNull public ComposedFrame createFrame(int charStart, int charEnd)
      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 - if charStart is negative, or charEnd is greater than the length of source text, or charStart is greater than or equal to charEnd.