Class RMTextArea

  • All Implemented Interfaces:
    java.awt.dnd.DropTargetListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.swing.Scrollable

    public class RMTextArea
    extends javax.swing.JComponent
    implements javax.swing.Scrollable, java.awt.dnd.DropTargetListener, java.beans.PropertyChangeListener
    A text editor subclass for editing text in a Swing component.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      • Fields inherited from class javax.swing.JComponent

        listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
      • Fields inherited from class java.awt.Component

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Constructor Description
      RMTextArea()
      Creates a new text area.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void append​(RMXString anXString)
      Appends an XString.
      void append​(java.lang.String aString)
      Append Text.
      void appendln​(java.lang.String aString)
      Append Text.
      RMTextEditor createTextEditor()
      Creates a new text editor.
      void dragEnter​(java.awt.dnd.DropTargetDragEvent dtde)
      DropTargetListener method.
      void dragExit​(java.awt.dnd.DropTargetEvent dte)
      DropTargetListener method.
      void dragOver​(java.awt.dnd.DropTargetDragEvent dtde)
      DropTargetListener method.
      void drop​(java.awt.dnd.DropTargetDropEvent dtde)
      DropTargetListener method.
      void dropActionChanged​(java.awt.dnd.DropTargetDragEvent dtde)
      DropTargetListener method.
      int getCharIndex​(java.awt.geom.Point2D aPoint)
      Returns the char index for given point in text coordinate space.
      RMDateFormat getDateFormat()  
      java.awt.Font getFont()
      Return AWT Font for current selection.
      double getFontScale()
      Convenience - returns text editor font scale.
      boolean getLineWrap()
      Returns whether to wrap lines to pane width.
      java.awt.Insets getMargin()
      Returns the text margins.
      java.awt.Dimension getMinimumSize()
      Overrides JComponent method to declare minimum size to be current size.
      RMNumberFormat getNumberFormat()  
      java.awt.Dimension getPreferredScrollableViewportSize()
      Scrollable method.
      java.awt.Dimension getPreferredSize()
      Overrides JComponent method to declare preferred size to be text editor's optimal height.
      int getScrollableBlockIncrement​(java.awt.Rectangle visibleRect, int orientation, int direction)
      Scrollable method.
      boolean getScrollableTracksViewportHeight()
      Scrollable method.
      boolean getScrollableTracksViewportWidth()
      Scrollable method.
      int getScrollableUnitIncrement​(java.awt.Rectangle visibleRect, int orientation, int direction)
      Scrollable method.
      int getSelAnchor()
      Returns the selection anchor.
      int getSelEnd()
      Returns the selection end.
      int getSelStart()
      Returns the selection start.
      java.lang.String getText()
      Returns text string of text editor.
      java.awt.geom.Rectangle2D getTextBounds()
      Returns the text rect.
      RMTextEditor getTextEditor()
      Returns the text editor associated with this text area.
      RMXString getXString()
      Convenience - returns text editor string.
      void hideCursor()
      Hides the cursor.
      boolean isManagingFocus()
      Overrides JComponent method so we get VK_TAB events.
      int length()
      Returns the text length.
      protected void paintBackground​(java.awt.Graphics2D aGraphics)
      Paints background.
      void paintComponent​(java.awt.Graphics g)
      Overrides JComponent to paint text editor text.
      protected void paintText​(java.awt.Graphics2D aGraphics)
      Paints the layout in a given graphics.
      void paintTextEditor​(java.awt.Graphics2D g)
      Paints a given layout in a given graphics.
      protected void paintTextRun​(java.awt.Graphics2D g, RMTextRun aRun)
      Paints the layout in a given graphics.
      protected void processComponentKeyEvent​(java.awt.event.KeyEvent anEvent)
      Overrides JComponent to forward key event to text editor.
      protected void processFocusEvent​(java.awt.event.FocusEvent e)
      Override to show hidden cursor.
      void processMouseEvent​(java.awt.event.MouseEvent anEvent)
      Overrides JComponent method to forward mouse pressed/released to text editor.
      void processMouseMotionEvent​(java.awt.event.MouseEvent anEvent)
      Overrides JComponent method to forward mouse drags to text editor.
      void propertyChange​(java.beans.PropertyChangeEvent anEvent)
      When text editor changes Selection or XString changes Runs or XStringRuns change Chars/Attribute, repaint.
      void setBounds​(int x, int y, int w, int h)
      Overrides JComponent method to tell text editor the bounds.
      void setDateFormat​(RMDateFormat format)  
      void setFont​(java.awt.Font aFont)
      Set AWT Font for current selection.
      void setFontScale​(double aScale)
      Convenience - sets text editor font scale.
      void setLineWrap​(boolean aValue)
      Sets whether to wrap lines to pane width.
      void setMargin​(java.awt.Insets theInsets)
      Sets the text margins.
      void setNumberFormat​(RMNumberFormat format)  
      protected void setRenderingHints​(java.awt.Graphics2D aGraphics)
      Sets rendering hints for text render.
      void setSel​(int newStartEnd)
      Sets the character index of the text cursor.
      void setSel​(int aStart, int anEnd)
      Sets the character index of the start and end of the text selection.
      void setText​(java.lang.String aString)
      Set text string of text editor.
      void setTextEditor​(RMTextEditor aTE)
      Sets the text editor associated with this text area.
      void setXString​(RMXString aString)
      Convenience - sets text editor string.
      void showCursor()
      Shows the cursor.
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processKeyBinding, processKeyEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RMTextArea

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

      • getMargin

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

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

        public java.awt.geom.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 java.lang.String getText()
        Returns text string of text editor.
      • setText

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

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

        public void appendln​(java.lang.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.
      • 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​(java.beans.PropertyChangeEvent anEvent)
        When text editor changes Selection or XString changes Runs or XStringRuns change Chars/Attribute, repaint.
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
      • processComponentKeyEvent

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

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

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

        public void processMouseMotionEvent​(java.awt.event.MouseEvent anEvent)
        Overrides JComponent method to forward mouse drags to text editor.
        Overrides:
        processMouseMotionEvent in class javax.swing.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 javax.swing.JComponent
      • paintComponent

        public void paintComponent​(java.awt.Graphics g)
        Overrides JComponent to paint text editor text.
        Overrides:
        paintComponent in class javax.swing.JComponent
      • paintText

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

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

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

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

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

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

        public java.awt.Dimension getPreferredSize()
        Overrides JComponent method to declare preferred size to be text editor's optimal height.
        Overrides:
        getPreferredSize in class javax.swing.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 java.awt.Component
      • getPreferredScrollableViewportSize

        public java.awt.Dimension getPreferredScrollableViewportSize()
        Scrollable method.
        Specified by:
        getPreferredScrollableViewportSize in interface javax.swing.Scrollable
      • getScrollableTracksViewportWidth

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

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

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

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

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

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

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

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

        public void dropActionChanged​(java.awt.dnd.DropTargetDragEvent dtde)
        DropTargetListener method.
        Specified by:
        dropActionChanged in interface java.awt.dnd.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​(java.awt.geom.Point2D aPoint)
        Returns the char index for given point in text coordinate space.
      • getFont

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

        public void setFont​(java.awt.Font aFont)
        Set AWT Font for current selection.
        Overrides:
        setFont in class javax.swing.JComponent