Package snap.text

Class RichText

All Implemented Interfaces:
CharSequence, Cloneable, PropChange.DoChange, CharSequenceX, XMLArchiver.Archivable

public class RichText extends TextDoc implements XMLArchiver.Archivable
This class represents a block of text (lines).
  • Constructor Details

    • RichText

      public RichText()
      Constructor.
    • RichText

      public RichText(CharSequence theChars, Object... theAttrs)
      Creates RichText initialized with given String and attributes (font, color).
  • Method Details

    • isRichText

      public boolean isRichText()
      Override to indicate rich text supported.
      Overrides:
      isRichText in class TextDoc
    • createLine

      protected TextLine createLine()
      Creates a new TextLine for use in this text.
      Overrides:
      createLine in class TextDoc
    • setStyle

      public void setStyle(TextStyle aStyle, int aStart, int anEnd)
      Sets a given style to a given range.
      Overrides:
      setStyle in class TextDoc
    • setStyleValue

      public void setStyleValue(String aKey, Object aValue, int aStart, int anEnd)
      Sets a given attribute to a given value for a given range.
      Overrides:
      setStyleValue in class TextDoc
    • setLineStyle

      public void setLineStyle(TextLineStyle aStyle, int aStart, int anEnd)
      Sets a given style to a given range.
      Overrides:
      setLineStyle in class TextDoc
    • setLineStyleValue

      public void setLineStyleValue(String aKey, Object aValue, int aStart, int anEnd)
      Sets a given style to a given range.
      Overrides:
      setLineStyleValue in class TextDoc
    • isUnderlined

      public boolean isUnderlined()
      Returns whether text contains an underlined run.
      Overrides:
      isUnderlined in class TextDoc
    • copyForRange

      public RichText copyForRange(int aStart, int aEnd)
      Returns a copy of this text for given char range.
    • clone

      public RichText clone()
      Standard clone implementation.
      Overrides:
      clone in class TextDoc
    • toXML

      public XMLElement toXML(XMLArchiver anArchiver)
      XML archival.
      Specified by:
      toXML in interface XMLArchiver.Archivable
    • fromXML

      public Object fromXML(XMLArchiver anArchiver, XMLElement anElement)
      XML unarchival.
      Specified by:
      fromXML in interface XMLArchiver.Archivable