Class TextRun

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

    public class TextRun
    extends java.lang.Object
    implements java.lang.Cloneable, TextTypes, java.lang.CharSequence
    The Run class represents a range of characters in an TextLine 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 Summary

      Constructors 
      Constructor Description
      TextRun()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addChars​(java.lang.CharSequence theChars, int anIndex)
      Adds characters with style to this line at given index.
      char charAt​(int anIndex)
      CharSequence method returning character at given index.
      TextRun clone()
      Returns a basic clone of this object.
      boolean equals​(java.lang.Object anObj)
      Returns whether this run is equal to the given object.
      protected void firePropertyChangeEvent​(java.lang.String aPropName, java.lang.Object oldVal, java.lang.Object newVal, int anIndex)
      Fires a property change event.
      double getCharAdvance​(char aChar)
      Returns the char advance for a given character.
      float getCharSpacing()
      Returns the char spacing.
      SnapColor getColor()
      Returns the color for this run.
      int getEnd()
      Returns the end character index for this run.
      SnapFont getFont()
      Returns the font for this run.
      int getIndex()
      Returns the run index.
      double getLeading()
      Returns the default distance between lines for this font.
      TextLine getLine()
      Returns the line that this run works for.
      double getMaxAscent()
      Returns the max distance above the baseline for this run font.
      double getMaxDescent()
      Returns the max distance below the baseline that this font goes.
      TextRun getNext()
      Returns the next run.
      int getScripting()
      Returns the scripting for this run (1=SuperScripting, -1=Subscripting, 0=none).
      int getStart()
      Returns the start character index for this run.
      java.lang.String getString()
      Returns the string for this run.
      TextStyle getStyle()
      Returns the run style.
      int getUnderlineStyle()
      Returns the underline style of this run.
      static int getUnderlineStyle​(java.util.Map attrs)
      Returns the underline style of this run.
      int hashCode()
      Standard hashCode implementation.
      boolean isUnderlined()
      Returns whether this run is underlined.
      int length()
      Returns the length in characters for this run.
      void removeChars​(int aStart, int anEnd)
      Removes characters in given range.
      protected void sendPropertyChange​(java.beans.PropertyChangeEvent anEvent)
      Sends a property change event.
      void setStyle​(TextStyle aStyle)
      Sets the run style.
      TextRun split​(int anIndex)
      Splits the run at the given index and returns a run containing the remaining characters (and identical attributes).
      java.lang.CharSequence subSequence​(int aStart, int anEnd)
      CharSequence method return character sequence for range.
      java.lang.String toString()
      Returns a string representation of this run.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.CharSequence

        chars, codePoints
    • Constructor Detail

      • TextRun

        public TextRun()
    • Method Detail

      • getLine

        public TextLine getLine()
        Returns the line that this run works for.
      • getIndex

        public int getIndex()
        Returns the run index.
      • getStart

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

        public int getEnd()
        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
      • getString

        public java.lang.String getString()
        Returns the string for this run.
      • addChars

        public void addChars​(java.lang.CharSequence theChars,
                             int anIndex)
        Adds characters with style to this line at given index.
      • removeChars

        public void removeChars​(int aStart,
                                int anEnd)
        Removes characters in given range.
      • getStyle

        public TextStyle getStyle()
        Returns the run style.
      • setStyle

        public void setStyle​(TextStyle aStyle)
        Sets the run style.
      • getFont

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

        public SnapColor getColor()
        Returns the color for this run.
      • isUnderlined

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

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

        public static int getUnderlineStyle​(java.util.Map attrs)
        Returns the underline style of this run.
      • getScripting

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

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

        public double getCharAdvance​(char aChar)
        Returns the char advance for a given character.
      • getMaxAscent

        public double getMaxAscent()
        Returns the max distance above the baseline for this run font.
      • getMaxDescent

        public double getMaxDescent()
        Returns the max distance below the baseline that this font goes.
      • getLeading

        public double getLeading()
        Returns the default distance between lines for this font.
      • getNext

        public TextRun getNext()
        Returns the next run.
      • split

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

        protected void firePropertyChangeEvent​(java.lang.String aPropName,
                                               java.lang.Object oldVal,
                                               java.lang.Object newVal,
                                               int anIndex)
        Fires a property change event.
      • sendPropertyChange

        protected void sendPropertyChange​(java.beans.PropertyChangeEvent anEvent)
        Sends a property change event.
      • 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
      • hashCode

        public int hashCode()
        Standard hashCode implementation.
        Overrides:
        hashCode in class java.lang.Object
      • clone

        @Nullable
        public TextRun clone()
        Returns a basic clone of this object.
        Overrides:
        clone in class java.lang.Object
      • 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