Class RMTextEditor

java.lang.Object
com.reportmill.text.RMTextEditor
Direct Known Subclasses:
RMEditorTextEditor

public class RMTextEditor extends Object
This class provides all of the event and drawing code necessary to edit text in the form of an RMXString (separated from an actual UI Component).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Listener class so other objects can track changes to text editor.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static boolean
     
    static boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a plain text editor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a listener.
    void
    Copies the current selection onto the clipboard.
    void
    cut()
    Copies the current selection onto the clip board, then deletes the current selection.
    void
    Deletes the current selection.
    void
    Deletes the character in front of the insertion point.
    void
    Deletes the characters from the insertion point to the end of the line.
    byte
    Returns the alignment for current selection.
    Returns the bounds of the text editor.
    float
    Returns the character spacing of the current selection or cursor.
    Returns the color of the current selection or cursor.
    Returns the font of the current selection or cursor.
    float
    Returns the scale applied to text when editing.
    Returns the format of the current selection or cursor.
    float
    Returns the height needed to display all characters.
    Returns the map of attributes applied to any inputted characters.
    Returns the paragraph of the current selection or cursor position.
    float
    Returns the line gap for current selection.
    float
    Returns the maximum line height for a line of text (even if font size would dictate higher).
    float
    Returns the min line height for current selection.
    float
    Returns the line spacing for current selection.
    getListener(int anIndex)
    Return the listener at the given index.
    Returns whether current selection is outlined.
    getSelectionPath(RMTextEditor aTextEditor, RMTextLayout aTextLayout)
    Returns a path for the current selection.
    int
    Returns the character index of the end of the text selection.
    int
    Returns the character index of the start of the text selection.
    getSpellingPath(RMTextEditor aTextEditor, RMTextLayout aTextLayout)
    Returns a path for misspelled word underlining.
    Returns the plain string of the xstring being edited.
    Returns the configured text layout used to layout text.
    Returns the xstring that is being edited.
    boolean
    Returns whether current selection is underlined.
    void
    Moves the insertion point backward a character (or if a range is selected, moves to beginning of range).
    void
    Moves the insertion point down a line, trying preserve distance from beginning of line.
    void
    Moves the insertion point forward a character (or if a range is selected, moves to end of range).
    void
    Moves the insertion point up a line, trying to preserve distance from beginning of line.
    int
    Returns the number of characters in the text string.
    void
    Moves the insertion point to the end of line.
    void
    Moves the insertion point to the beginning of line.
    void
    Handles mouse dragged.
    void
    Handles mouse pressed.
    void
    Handles mouse released.
    static void
    paintLayout(RMTextEditor aTextEditor, RMTextLayout aTextLayout, Graphics2D g, float opacity)
    Paints a given layout in a given graphics.
    void
    paintLayout(Graphics2D g, float opacity)
    Paints the text editor (with an opacity value).
    void
    Pasts the current clipboard data over the current selection.
    void
    Handles key events.
    void
    Removes a listener.
    void
    replace(RMXString aString)
    Replaces the current selection with the given xstring.
    void
    replace(String aString)
    Replaces the current selection with the given string.
    void
    Selects all the characters in the text editor.
    void
    setAlign(int align)
    Sets the alignment for current selection.
    void
    setBounds(float x, float y, float w, float h)
    Set the bounds of the text editor.
    void
    setCharSpacing(float aValue)
    Returns the character spacing of the current selection or cursor.
    void
    Sets the color of the current selection or cursor.
    void
    Sets the font of the current selection or cursor.
    void
    setFontScale(float aScale)
    Sets the scale applied to text when editing.
    void
    Sets the format of the current selection or cursor, after trying to expand the selection to encompase currently selected, @-sign deliniated key.
    void
    Sets the attributes that are applied to current selection or newly typed chars.
    void
    Sets the paragraph of the current selection or cursor position.
    void
    setLineGap(float aHeight)
    Sets the line gap for current selection.
    void
    setLineHeightMax(float aHeight)
    Sets the maximum line height for a line of text (even if font size would dictate higher).
    void
    setLineHeightMin(float aHeight)
    Sets the min line height for current selection.
    void
    setLineSpacing(float aHeight)
    Sets the line spacing for current selection.
    void
    Tell the text editor listener that editor needs repaint.
    void
    Sets whether current selection is outlined.
    void
    setSelection(int newStartEnd)
    Sets the character index of the text cursor.
    void
    setSelection(int newStart, int newEnd)
    Sets the character index of the start and end of the text selection.
    void
    setSelEnd(int newEnd)
    Sets the character index of the end of the text selection.
    void
    setSelStart(int newStart)
    Sets the character index of the start of the text selection.
    void
    Sets current selection to subscript.
    void
    Sets current selection to superscript.
    void
    Sets the text layout for this text editor.
    void
    setUnderlined(boolean aFlag)
    Sets whether current selection is underlined.
    void
    Sets the xstring that is to be edited.
    This method returns the range of the @-sign delinated key closest to the current selection (or null if not found).
    void
    Called when characters where added, updated or deleted.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • isSpellChecking

      public static boolean isSpellChecking
    • isHyphenating

      public static boolean isHyphenating
  • Constructor Details

    • RMTextEditor

      public RMTextEditor()
      Creates a plain text editor.
  • Method Details

    • getXString

      public RMXString getXString()
      Returns the xstring that is being edited.
    • setXString

      public void setXString(RMXString aString)
      Sets the xstring that is to be edited.
    • getBounds

      public RMRect getBounds()
      Returns the bounds of the text editor.
    • setBounds

      public void setBounds(float x, float y, float w, float h)
      Set the bounds of the text editor.
    • length

      public int length()
      Returns the number of characters in the text string.
    • getSelStart

      public int getSelStart()
      Returns the character index of the start of the text selection.
    • setSelStart

      public void setSelStart(int newStart)
      Sets the character index of the start of the text selection.
    • getSelEnd

      public int getSelEnd()
      Returns the character index of the end of the text selection.
    • setSelEnd

      public void setSelEnd(int newEnd)
      Sets the character index of the end of the text selection.
    • setSelection

      public void setSelection(int newStartEnd)
      Sets the character index of the text cursor.
    • setSelection

      public void setSelection(int newStart, int newEnd)
      Sets the character index of the start and end of the text selection.
    • getFontScale

      public float getFontScale()
      Returns the scale applied to text when editing.
    • setFontScale

      public void setFontScale(float aScale)
      Sets the scale applied to text when editing.
    • getTextLayout

      public RMTextLayout getTextLayout()
      Returns the configured text layout used to layout text.
    • setTextLayout

      public void setTextLayout(RMTextLayout aLayout)
      Sets the text layout for this text editor.
    • getInputAttributes

      public Map getInputAttributes()
      Returns the map of attributes applied to any inputted characters.
    • setInputAttribute

      public void setInputAttribute(String aKey, Object aValue)
      Sets the attributes that are applied to current selection or newly typed chars.
    • getInputParagraph

      public RMParagraph getInputParagraph()
      Returns the paragraph of the current selection or cursor position.
    • setInputParagraph

      public void setInputParagraph(RMParagraph ps)
      Sets the paragraph of the current selection or cursor position.
    • getString

      public String getString()
      Returns the plain string of the xstring being edited.
    • getColor

      public RMColor getColor()
      Returns the color of the current selection or cursor.
    • setColor

      public void setColor(RMColor color)
      Sets the color of the current selection or cursor.
    • getFont

      public RMFont getFont()
      Returns the font of the current selection or cursor.
    • setFont

      public void setFont(RMFont font)
      Sets the font of the current selection or cursor.
    • getFormat

      public RMFormat getFormat()
      Returns the format of the current selection or cursor.
    • setFormat

      public void setFormat(RMFormat aFormat)
      Sets the format of the current selection or cursor, after trying to expand the selection to encompase currently selected, @-sign deliniated key.
    • smartFindFormatRange

      public RMRange smartFindFormatRange()
      This method returns the range of the @-sign delinated key closest to the current selection (or null if not found).
    • isUnderlined

      public boolean isUnderlined()
      Returns whether current selection is underlined.
    • setUnderlined

      public void setUnderlined(boolean aFlag)
      Sets whether current selection is underlined.
    • getOutline

      public RMXString.Outline getOutline()
      Returns whether current selection is outlined.
    • setOutline

      public void setOutline(RMXString.Outline anOutline)
      Sets whether current selection is outlined.
    • setSuperscript

      public void setSuperscript()
      Sets current selection to superscript.
    • setSubscript

      public void setSubscript()
      Sets current selection to subscript.
    • getAlign

      public byte getAlign()
      Returns the alignment for current selection.
    • setAlign

      public void setAlign(int align)
      Sets the alignment for current selection.
    • getCharSpacing

      public float getCharSpacing()
      Returns the character spacing of the current selection or cursor.
    • setCharSpacing

      public void setCharSpacing(float aValue)
      Returns the character spacing of the current selection or cursor.
    • getLineSpacing

      public float getLineSpacing()
      Returns the line spacing for current selection.
    • setLineSpacing

      public void setLineSpacing(float aHeight)
      Sets the line spacing for current selection.
    • getLineGap

      public float getLineGap()
      Returns the line gap for current selection.
    • setLineGap

      public void setLineGap(float aHeight)
      Sets the line gap for current selection.
    • getLineHeightMin

      public float getLineHeightMin()
      Returns the min line height for current selection.
    • setLineHeightMin

      public void setLineHeightMin(float aHeight)
      Sets the min line height for current selection.
    • getLineHeightMax

      public float getLineHeightMax()
      Returns the maximum line height for a line of text (even if font size would dictate higher).
    • setLineHeightMax

      public void setLineHeightMax(float aHeight)
      Sets the maximum line height for a line of text (even if font size would dictate higher).
    • getListener

      public RMTextEditor.Listener getListener(int anIndex)
      Return the listener at the given index.
    • addListener

      public void addListener(RMTextEditor.Listener aTEL)
      Adds a listener.
    • removeListener

      public void removeListener(RMTextEditor.Listener aTEL)
      Removes a listener.
    • textDidChange

      public void textDidChange()
      Called when characters where added, updated or deleted.
    • setNeedsRepaint

      public void setNeedsRepaint()
      Tell the text editor listener that editor needs repaint.
    • replace

      public void replace(String aString)
      Replaces the current selection with the given string.
    • replace

      public void replace(RMXString aString)
      Replaces the current selection with the given xstring.
    • cut

      public void cut()
      Copies the current selection onto the clip board, then deletes the current selection.
    • copy

      public void copy()
      Copies the current selection onto the clipboard.
    • paste

      public void paste()
      Pasts the current clipboard data over the current selection.
    • delete

      public void delete()
      Deletes the current selection.
    • selectAll

      public void selectAll()
      Selects all the characters in the text editor.
    • keyForward

      public void keyForward()
      Moves the insertion point forward a character (or if a range is selected, moves to end of range).
    • keyBackward

      public void keyBackward()
      Moves the insertion point backward a character (or if a range is selected, moves to beginning of range).
    • keyUp

      public void keyUp()
      Moves the insertion point up a line, trying to preserve distance from beginning of line.
    • keyDown

      public void keyDown()
      Moves the insertion point down a line, trying preserve distance from beginning of line.
    • lineStart

      public void lineStart()
      Moves the insertion point to the beginning of line.
    • lineEnd

      public void lineEnd()
      Moves the insertion point to the end of line.
    • deleteForward

      public void deleteForward()
      Deletes the character in front of the insertion point.
    • deleteToLineEnd

      public void deleteToLineEnd()
      Deletes the characters from the insertion point to the end of the line.
    • getHeightToFit

      public float getHeightToFit()
      Returns the height needed to display all characters.
    • processKeyEvent

      public void processKeyEvent(KeyEvent e)
      Handles key events.
    • mousePressed

      public void mousePressed(MouseEvent e, RMPoint location)
      Handles mouse pressed.
    • mouseDragged

      public void mouseDragged(MouseEvent e, RMPoint location)
      Handles mouse dragged.
    • mouseReleased

      public void mouseReleased(MouseEvent e, RMPoint location)
      Handles mouse released.
    • paintLayout

      public void paintLayout(Graphics2D g, float opacity)
      Paints the text editor (with an opacity value).
    • paintLayout

      public static void paintLayout(RMTextEditor aTextEditor, RMTextLayout aTextLayout, Graphics2D g, float opacity)
      Paints a given layout in a given graphics.
    • getSelectionPath

      public static GeneralPath getSelectionPath(RMTextEditor aTextEditor, RMTextLayout aTextLayout)
      Returns a path for the current selection.
    • getSpellingPath

      public static GeneralPath getSpellingPath(RMTextEditor aTextEditor, RMTextLayout aTextLayout)
      Returns a path for misspelled word underlining.