Class Text

    • Constructor Detail

      • Text

        public Text()
        Creates a new text.
      • Text

        public Text​(java.lang.CharSequence theChars)
        Creates a Text initialized with the given String and no attributes.
    • Method Detail

      • setSource

        public void setSource​(java.lang.Object aSource)
        Loads the text from the given source.
      • getSourceURL

        public WebURL getSourceURL()
        Returns the source URL.
      • setSourceURL

        public void setSourceURL​(WebURL aURL)
        Sets the source URL.
      • getSourceFile

        public WebFile getSourceFile()
        Returns the source file.
      • length

        public int length()
        Returns the number of characters in the text.
        Specified by:
        length in interface java.lang.CharSequence
      • charAt

        public char charAt​(int anIndex)
        Returns the char value at the specified index.
        Specified by:
        charAt in interface java.lang.CharSequence
      • subSequence

        public java.lang.CharSequence subSequence​(int aStart,
                                                  int anEnd)
        Returns a new char sequence that is a subsequence of this sequence.
        Specified by:
        subSequence in interface java.lang.CharSequence
      • getString

        public java.lang.String getString()
        Returns the string for the text.
      • setString

        public void setString​(java.lang.String aString)
        Sets the text to the given string.
      • getFont

        public SnapFont getFont()
        Returns the font for this line.
      • setFont

        public void setFont​(SnapFont aFont)
        Sets the font for this line.
      • getDefaultFont

        public SnapFont getDefaultFont()
        Returns the default font for this string.
      • getFontScale

        public double getFontScale()
        Returns the font scale of the text layout.
      • setFontScale

        public void setFontScale​(double aValue)
        Sets the font scale of the text layout.
      • getUseFractionalMetrics

        public boolean getUseFractionalMetrics()
        Returns whether to use fractional character metrics.
      • setUseFractionalMetrics

        public void setUseFractionalMetrics​(boolean aFlag)
        Sets whether to use fractional character metrics.
      • getColor

        public SnapColor getColor()
        Returns the color for this line.
      • setColor

        public void setColor​(SnapColor aColor)
        Sets the color for this line.
      • getDefaultColor

        public SnapColor getDefaultColor()
        Returns the default color for this string.
      • getDefaultAttribute

        public java.lang.Object getDefaultAttribute​(java.lang.Object aKey)
        Returns the default for a given key.
      • isMonofont

        public boolean isMonofont()
        Whether this text only allows a single font, color, etc. (defaults to false).
      • setMonofont

        public void setMonofont​(boolean aValue)
        Sets whether this text only allows a single font, color, etc.
      • addChars

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

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

        public void replaceChars​(java.lang.CharSequence theChars,
                                 TextStyle theStyle,
                                 int aStart,
                                 int anEnd)
        Replaces chars in given range, with given String, using the given attributes.
      • setAttribute

        public void setAttribute​(java.lang.String aKey,
                                 java.lang.Object aValue,
                                 int aStart,
                                 int anEnd)
        Sets a given attribute to a given value for a given range.
      • getLineCount

        public int getLineCount()
        Returns the number of lines in this text.
      • getLine

        public TextLine getLine​(int anIndex)
        Returns the individual text line in this text.
      • getLines

        public java.util.List<TextLine> getLines()
        Returns the list of lines.
      • createLine

        protected TextLine createLine()
        Creates a new line for use in this text.
      • addLine

        protected TextLine addLine​(int anIndex)
        Adds a line at given index.
      • addLine

        public void addLine​(TextLine aLine,
                            int anIndex)
        Adds a line at given index.
      • removeLine

        public TextLine removeLine​(int anIndex)
        Removes the line at given index.
      • removeLine

        public int removeLine​(TextLine aLine)
        Removes the given line.
      • updateLines

        protected void updateLines​(int anIndex)
        Updates lines from index.
      • getLineAt

        public TextLine getLineAt​(int anIndex)
        Returns the TextLine at the given char index.
      • getLineFor

        public TextLine getLineFor​(int anIndex)
        Returns the TextLine at the given char index or the last line if at end.
      • getLineLast

        public TextLine getLineLast()
        Returns the last line.
      • getLineLongest

        public TextLine getLineLongest()
        Returns the longest line.
      • getTokenAt

        public TextToken getTokenAt​(int anIndex)
        Returns the token at given index.
      • getRunAt

        public TextRun getRunAt​(int anIndex)
        Returns the TextRun that contains the given index.
      • getRunFor

        public TextRun getRunFor​(int anIndex)
        Returns the TextRun that contains the given index or the last line last run if at end.
      • getStyleAt

        public TextStyle getStyleAt​(int anIndex)
        Returns the TextStyle for the run at the given character index.
      • getLineForY

        public TextLine getLineForY​(double aY)
        Returns the line for the given y value.
      • getCharIndex

        public int getCharIndex​(double anX,
                                double aY)
        Returns the character index for the given x/y point.
      • invalidate

        public void invalidate()
        Invalidates text.
      • getPrefWidth

        public double getPrefWidth()
        Returns the preferred width.
      • getPrefHeight

        public double getPrefHeight()
        Returns the preferred height.
      • computePrefWidth

        protected double computePrefWidth()
        Compute the preferred width.
      • computePrefHeight

        protected double computePrefHeight()
        Returns the preferred height.
      • isPropertyChangeEnabled

        public boolean isPropertyChangeEnabled()
        Returns whether property change is enabled.
      • setPropertyChangeEnabled

        public void setPropertyChangeEnabled​(boolean aValue)
        Sets whether property change is enabled.
      • sendPropertyChange

        protected void sendPropertyChange​(java.beans.PropertyChangeEvent anEvent)
        Implement so package can use protected method.
        Overrides:
        sendPropertyChange in class RMObject
      • toString

        public java.lang.String toString()
        Standard toString implementation.
        Specified by:
        toString in interface java.lang.CharSequence
        Overrides:
        toString in class RMObject