Package snap.text
Class RichText
java.lang.Object
snap.props.PropObject
snap.text.TextDoc
snap.text.RichText
- All Implemented Interfaces:
CharSequence
,Cloneable
,PropChange.DoChange
,CharSequenceX
,XMLArchiver.Archivable
This class represents a block of text (lines).
-
Field Summary
Fields inherited from class snap.text.TextDoc
_defaultLineStyle, _defaultTextStyle, _length, _lines, _parentTextStyle, _propChangeEnabled, _width, Chars_Prop, DefaultTextStyle_Prop, LineStyle_Prop, ParentTextStyle_Prop, Style_Prop, TextModified_Prop
Fields inherited from class snap.props.PropObject
_pcs, EMPTY_OBJECT
-
Constructor Summary
ConstructorDescriptionRichText()
Constructor.RichText
(CharSequence theChars, Object... theAttrs) Creates RichText initialized with given String and attributes (font, color). -
Method Summary
Modifier and TypeMethodDescriptionclone()
Standard clone implementation.copyForRange
(int aStart, int aEnd) Returns a copy of this text for given char range.protected TextLine
Creates a new TextLine for use in this text.fromXML
(XMLArchiver anArchiver, XMLElement anElement) XML unarchival.boolean
Override to indicate rich text supported.boolean
Returns whether text contains an underlined run.void
setLineStyle
(TextLineStyle aStyle, int aStart, int anEnd) Sets a given style to a given range.void
setLineStyleValue
(String aKey, Object aValue, int aStart, int anEnd) Sets a given style to a given range.void
Sets a given style to a given range.void
setStyleValue
(String aKey, Object aValue, int aStart, int anEnd) Sets a given attribute to a given value for a given range.toXML
(XMLArchiver anArchiver) XML archival.Methods inherited from class snap.text.TextDoc
addChars, addChars, addDefaultLine, addLine, addTextDoc, charAt, clear, createTokensForTextLine, getAlignX, getDefaultLineStyle, getDefaultStyle, getFontForCharIndex, getLine, getLineCount, getLineForCharIndex, getLineLast, getLineLongest, getLines, getLineStyleForCharIndex, getParentTextStyle, getPrefWidth, getPrefWidth, getRunForCharIndex, getRunForCharRange, getRunLast, getSourceFile, getSourceURL, getStartCharIndex, getString, getStyleForCharIndex, getStyleForCharRange, indexOf, isDefaultTextStyleSet, isPropChangeEnabled, isTextModified, length, newFromSource, readFromSourceURL, removeChars, removeLine, replaceChars, replaceChars, scaleFonts, setAlignX, setDefaultLineStyle, setDefaultStyle, setParentTextStyle, setPropChangeEnabled, setSourceURL, setString, setStyleValue, setStyleValue, setStyleValue, setTextModified, setUnderlined, subSequence, toStringProps, updateLines, writeToSourceFile
Methods inherited from class snap.props.PropObject
addDeepChangeListener, addPropChangeListener, addPropChangeListener, firePropChange, firePropChange, firePropChange, getPropDefault, getPropForName, getPropParent, getPropSet, getPropsForArchival, getPropsForArchivalExtra, getPropValue, initProps, isPropDefault, processPropChange, removeDeepChangeListener, removePropChangeListener, removePropChangeListener, setPropValue, toString
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty, toString
Methods inherited from interface snap.util.CharSequenceX
getIndentLength, getIndentString, getLastChar, indexAfterNewline, indexOfNewline, isAfterLineEnd, isLastCharNewline, isLineEnd, isLineEndChar, isWhiteSpace, lastIndexAfterNewline, lastIndexOfNewline, startsWith
-
Constructor Details
-
RichText
public RichText()Constructor. -
RichText
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 classTextDoc
-
createLine
Creates a new TextLine for use in this text.- Overrides:
createLine
in classTextDoc
-
setStyle
Sets a given style to a given range. -
setStyleValue
Sets a given attribute to a given value for a given range.- Overrides:
setStyleValue
in classTextDoc
-
setLineStyle
Sets a given style to a given range.- Overrides:
setLineStyle
in classTextDoc
-
setLineStyleValue
Sets a given style to a given range.- Overrides:
setLineStyleValue
in classTextDoc
-
isUnderlined
public boolean isUnderlined()Returns whether text contains an underlined run.- Overrides:
isUnderlined
in classTextDoc
-
copyForRange
Returns a copy of this text for given char range. -
clone
Standard clone implementation. -
toXML
XML archival.- Specified by:
toXML
in interfaceXMLArchiver.Archivable
-
fromXML
XML unarchival.- Specified by:
fromXML
in interfaceXMLArchiver.Archivable
-