Class RMTextArea

All Implemented Interfaces:
DropTargetListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Scrollable

public class RMTextArea extends JComponent implements Scrollable, DropTargetListener, PropertyChangeListener
A text editor subclass for editing text in a Swing component.
See Also:
  • Constructor Details

    • RMTextArea

      public RMTextArea()
      Creates a new text area.
  • Method Details

    • getMargin

      public Insets getMargin()
      Returns the text margins.
    • setMargin

      public void setMargin(Insets theInsets)
      Sets the text margins.
    • getTextBounds

      public Rectangle2D getTextBounds()
      Returns the text rect.
    • getLineWrap

      public boolean getLineWrap()
      Returns whether to wrap lines to pane width.
    • setLineWrap

      public void setLineWrap(boolean aValue)
      Sets whether to wrap lines to pane width.
    • getTextEditor

      public RMTextEditor getTextEditor()
      Returns the text editor associated with this text area.
    • setTextEditor

      public void setTextEditor(RMTextEditor aTE)
      Sets the text editor associated with this text area.
    • createTextEditor

      public RMTextEditor createTextEditor()
      Creates a new text editor.
    • getText

      public String getText()
      Returns text string of text editor.
    • setText

      public void setText(String aString)
      Set text string of text editor.
    • append

      public void append(String aString)
      Append Text.
    • appendln

      public void appendln(String aString)
      Append Text.
    • append

      public void append(RMXString anXString)
      Appends an XString.
    • length

      public int length()
      Returns the text length.
    • getXString

      public RMXString getXString()
      Convenience - returns text editor string.
    • setXString

      public void setXString(RMXString aString)
      Convenience - sets text editor string.
    • getNumberFormat

      @Nonnull public RMNumberFormat getNumberFormat()
    • getDateFormat

      @Nonnull public RMDateFormat getDateFormat()
    • setDateFormat

      public void setDateFormat(RMDateFormat format)
    • setNumberFormat

      public void setNumberFormat(RMNumberFormat format)
    • getFontScale

      public double getFontScale()
      Convenience - returns text editor font scale.
    • setFontScale

      public void setFontScale(double aScale)
      Convenience - sets text editor font scale.
    • propertyChange

      public void propertyChange(PropertyChangeEvent anEvent)
      When text editor changes Selection or XString changes Runs or XStringRuns change Chars/Attribute, repaint.
      Specified by:
      propertyChange in interface PropertyChangeListener
    • processComponentKeyEvent

      protected void processComponentKeyEvent(KeyEvent anEvent)
      Overrides JComponent to forward key event to text editor.
      Overrides:
      processComponentKeyEvent in class JComponent
    • processMouseEvent

      public void processMouseEvent(MouseEvent anEvent)
      Overrides JComponent method to forward mouse pressed/released to text editor.
      Overrides:
      processMouseEvent in class JComponent
    • processFocusEvent

      protected void processFocusEvent(FocusEvent e)
      Override to show hidden cursor.
      Overrides:
      processFocusEvent in class Component
    • processMouseMotionEvent

      public void processMouseMotionEvent(MouseEvent anEvent)
      Overrides JComponent method to forward mouse drags to text editor.
      Overrides:
      processMouseMotionEvent in class JComponent
    • showCursor

      public void showCursor()
      Shows the cursor.
    • hideCursor

      public void hideCursor()
      Hides the cursor.
    • isManagingFocus

      public boolean isManagingFocus()
      Overrides JComponent method so we get VK_TAB events.
      Overrides:
      isManagingFocus in class JComponent
    • paintComponent

      public void paintComponent(Graphics g)
      Overrides JComponent to paint text editor text.
      Overrides:
      paintComponent in class JComponent
    • paintText

      protected void paintText(Graphics2D aGraphics)
      Paints the layout in a given graphics.
    • paintTextRun

      protected void paintTextRun(Graphics2D g, RMTextRun aRun)
      Paints the layout in a given graphics.
    • paintTextEditor

      public void paintTextEditor(Graphics2D g)
      Paints a given layout in a given graphics.
    • paintBackground

      protected void paintBackground(Graphics2D aGraphics)
      Paints background.
    • setRenderingHints

      protected void setRenderingHints(Graphics2D aGraphics)
      Sets rendering hints for text render.
    • getMinimumSize

      public Dimension getMinimumSize()
      Overrides JComponent method to declare minimum size to be current size.
      Overrides:
      getMinimumSize in class JComponent
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides JComponent method to declare preferred size to be text editor's optimal height.
      Overrides:
      getPreferredSize in class JComponent
    • setBounds

      public void setBounds(int x, int y, int w, int h)
      Overrides JComponent method to tell text editor the bounds.
      Overrides:
      setBounds in class Component
    • getPreferredScrollableViewportSize

      public Dimension getPreferredScrollableViewportSize()
      Scrollable method.
      Specified by:
      getPreferredScrollableViewportSize in interface Scrollable
    • getScrollableTracksViewportWidth

      public boolean getScrollableTracksViewportWidth()
      Scrollable method.
      Specified by:
      getScrollableTracksViewportWidth in interface Scrollable
    • getScrollableTracksViewportHeight

      public boolean getScrollableTracksViewportHeight()
      Scrollable method.
      Specified by:
      getScrollableTracksViewportHeight in interface Scrollable
    • getScrollableBlockIncrement

      public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
      Scrollable method.
      Specified by:
      getScrollableBlockIncrement in interface Scrollable
    • getScrollableUnitIncrement

      public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
      Scrollable method.
      Specified by:
      getScrollableUnitIncrement in interface Scrollable
    • dragEnter

      public void dragEnter(DropTargetDragEvent dtde)
      DropTargetListener method.
      Specified by:
      dragEnter in interface DropTargetListener
    • dragExit

      public void dragExit(DropTargetEvent dte)
      DropTargetListener method.
      Specified by:
      dragExit in interface DropTargetListener
    • dragOver

      public void dragOver(DropTargetDragEvent dtde)
      DropTargetListener method.
      Specified by:
      dragOver in interface DropTargetListener
    • drop

      public void drop(DropTargetDropEvent dtde)
      DropTargetListener method.
      Specified by:
      drop in interface DropTargetListener
    • dropActionChanged

      public void dropActionChanged(DropTargetDragEvent dtde)
      DropTargetListener method.
      Specified by:
      dropActionChanged in interface DropTargetListener
    • setSel

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

      public void setSel(int aStart, int anEnd)
      Sets the character index of the start and end of the text selection.
    • getSelStart

      public int getSelStart()
      Returns the selection start.
    • getSelEnd

      public int getSelEnd()
      Returns the selection end.
    • getSelAnchor

      public int getSelAnchor()
      Returns the selection anchor.
    • getCharIndex

      public int getCharIndex(Point2D aPoint)
      Returns the char index for given point in text coordinate space.
    • getFont

      public Font getFont()
      Return AWT Font for current selection.
      Specified by:
      getFont in interface MenuContainer
      Overrides:
      getFont in class Component
    • setFont

      public void setFont(Font aFont)
      Set AWT Font for current selection.
      Overrides:
      setFont in class JComponent