Class RMXStringRun

  • All Implemented Interfaces:
    RMTypes, RMTextTypes, java.lang.CharSequence, java.lang.Cloneable

    public class RMXStringRun
    extends java.lang.Object
    implements RMTextTypes, java.lang.Cloneable, java.lang.CharSequence
    The Run class represents a range of characters in an xstring that share common attributes.

    This class makes a point to treat its attributes map as read-only so they can be shared among multiple runs.

    • Constructor Detail

      • RMXStringRun

        public RMXStringRun​(RMXString anXString)
        Creates a new run.
    • Method Detail

      • start

        public int start()
        Returns the start character index for this run.
      • end

        public int end()
        Returns the end character index for this run.
      • length

        public int length()
        Returns the length in characters for this run.
        Specified by:
        length in interface java.lang.CharSequence
      • charAt

        public char charAt​(int anIndex)
        CharSequence method returning character at given index.
        Specified by:
        charAt in interface java.lang.CharSequence
      • subSequence

        public java.lang.CharSequence subSequence​(int aStart,
                                                  int anEnd)
        CharSequence method return character sequence for range.
        Specified by:
        subSequence in interface java.lang.CharSequence
      • getStyle

        public RMTextStyle getStyle()
        Returns the text style.
      • setStyle

        protected void setStyle​(RMTextStyle aStyle)
        Sets the text style.
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String aKey)
        Returns a specific attribute for the given key.
      • getFont

        public RMFont getFont()
        Returns the font for this run.
      • getColor

        public RMColor getColor()
        Returns the color for this run.
      • getParagraph

        public RMParagraph getParagraph()
        Returns the paragraph for this run.
      • isUnderlined

        public boolean isUnderlined()
        Returns whether this run is underlined.
      • getUnderlineStyle

        public int getUnderlineStyle()
        Returns the underline style of this run.
      • getOutline

        public RMXString.Outline getOutline()
        Returns the outline info for this run (null for none).
      • getOutline

        public static RMXString.Outline getOutline​(java.util.Map attrs)
        Returns the Outline record for the given attributes map (or null for none).
      • getFormat

        public RMFormat getFormat()
        Returns the format for this run.
      • getDateFormat

        @Nonnull
        public RMDateFormat getDateFormat()
      • getScripting

        public int getScripting()
        Returns the scripting for this run (1=SuperScripting, -1=Subscripting, 0=none).
      • getCharSpacing

        public float getCharSpacing()
        Returns the char spacing.
      • getRunCount

        public int getRunCount()
        Returns the run count.
      • getRun

        public RMXStringRun getRun​(int anIndex)
        Returns the run at given index.
      • getRunLast

        public RMXStringRun getRunLast()
        Returns the last run.
      • getRunAt

        public RMXStringRun getRunAt​(int anIndex,
                                     boolean isInclusive)
        Returns the XString run that contains or ends (if given option is true) at given index.
      • addLength

        public void addLength​(int aLength,
                              int anIndex)
        Adds length to run for char index.
      • removeLength

        public void removeLength​(int aLength,
                                 int anIndex)
        Removes a length from run(s) for char index.
      • shift

        public void shift​(int anAmount)
        Shifts run by given amound.
      • split

        public RMXStringRun split​(int anIndex)
        Splits the run at the given index and returns a run containing the remaining characters (and identical attributes).
      • equals

        public boolean equals​(java.lang.Object anObj)
        Returns whether this run is equal to the given object.
        Overrides:
        equals in class java.lang.Object
      • clone

        @Nullable
        public RMXStringRun clone()
        Returns a basic clone of this object.
        Overrides:
        clone in class java.lang.Object
      • cloneDeep

        public RMXStringRun cloneDeep​(RMXString anXString)
        Returns a clone of this run, including a clone of the next run(s) if present.
      • toString

        public java.lang.String toString()
        Returns a string representation of this run.
        Specified by:
        toString in interface java.lang.CharSequence
        Overrides:
        toString in class java.lang.Object