Package com.inductiveautomation.rm.text
Class RMTextArea
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
com.inductiveautomation.rm.text.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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, 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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends an XString.void
Append Text.void
Append Text.Creates a new text editor.void
dragEnter
(DropTargetDragEvent dtde) DropTargetListener method.void
dragExit
(DropTargetEvent dte) DropTargetListener method.void
dragOver
(DropTargetDragEvent dtde) DropTargetListener method.void
drop
(DropTargetDropEvent dtde) DropTargetListener method.void
DropTargetListener method.int
getCharIndex
(Point2D aPoint) Returns the char index for given point in text coordinate space.getFont()
Return AWT Font for current selection.double
Convenience - returns text editor font scale.boolean
Returns whether to wrap lines to pane width.Returns the text margins.Overrides JComponent method to declare minimum size to be current size.Scrollable method.Overrides JComponent method to declare preferred size to be text editor's optimal height.int
getScrollableBlockIncrement
(Rectangle visibleRect, int orientation, int direction) Scrollable method.boolean
Scrollable method.boolean
Scrollable method.int
getScrollableUnitIncrement
(Rectangle visibleRect, int orientation, int direction) Scrollable method.int
Returns the selection anchor.int
Returns the selection end.int
Returns the selection start.getText()
Returns text string of text editor.Returns the text rect.Returns the text editor associated with this text area.Convenience - returns text editor string.void
Hides the cursor.boolean
Overrides JComponent method so we get VK_TAB events.int
length()
Returns the text length.protected void
paintBackground
(Graphics2D aGraphics) Paints background.void
Overrides JComponent to paint text editor text.protected void
paintText
(Graphics2D aGraphics) Paints the layout in a given graphics.void
Paints a given layout in a given graphics.protected void
paintTextRun
(Graphics2D g, RMTextRun aRun) Paints the layout in a given graphics.protected void
processComponentKeyEvent
(KeyEvent anEvent) Overrides JComponent to forward key event to text editor.protected void
Override to show hidden cursor.void
processMouseEvent
(MouseEvent anEvent) Overrides JComponent method to forward mouse pressed/released to text editor.void
processMouseMotionEvent
(MouseEvent anEvent) Overrides JComponent method to forward mouse drags to text editor.void
propertyChange
(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
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
Sets the text margins.void
setNumberFormat
(RMNumberFormat format) protected void
setRenderingHints
(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
Set text string of text editor.void
Sets the text editor associated with this text area.void
setXString
(RMXString aString) Convenience - sets text editor string.void
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
-
Constructor Details
-
RMTextArea
public RMTextArea()Creates a new text area.
-
-
Method Details
-
getMargin
Returns the text margins. -
setMargin
Sets the text margins. -
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
Returns the text editor associated with this text area. -
setTextEditor
Sets the text editor associated with this text area. -
createTextEditor
Creates a new text editor. -
getText
Returns text string of text editor. -
setText
Set text string of text editor. -
append
Append Text. -
appendln
Append Text. -
append
Appends an XString. -
length
public int length()Returns the text length. -
getXString
Convenience - returns text editor string. -
setXString
Convenience - sets text editor string. -
getNumberFormat
-
getDateFormat
-
setDateFormat
-
setNumberFormat
-
getFontScale
public double getFontScale()Convenience - returns text editor font scale. -
setFontScale
public void setFontScale(double aScale) Convenience - sets text editor font scale. -
propertyChange
When text editor changes Selection or XString changes Runs or XStringRuns change Chars/Attribute, repaint.- Specified by:
propertyChange
in interfacePropertyChangeListener
-
processComponentKeyEvent
Overrides JComponent to forward key event to text editor.- Overrides:
processComponentKeyEvent
in classJComponent
-
processMouseEvent
Overrides JComponent method to forward mouse pressed/released to text editor.- Overrides:
processMouseEvent
in classJComponent
-
processFocusEvent
Override to show hidden cursor.- Overrides:
processFocusEvent
in classComponent
-
processMouseMotionEvent
Overrides JComponent method to forward mouse drags to text editor.- Overrides:
processMouseMotionEvent
in classJComponent
-
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 classJComponent
-
paintComponent
Overrides JComponent to paint text editor text.- Overrides:
paintComponent
in classJComponent
-
paintText
Paints the layout in a given graphics. -
paintTextRun
Paints the layout in a given graphics. -
paintTextEditor
Paints a given layout in a given graphics. -
paintBackground
Paints background. -
setRenderingHints
Sets rendering hints for text render. -
getMinimumSize
Overrides JComponent method to declare minimum size to be current size.- Overrides:
getMinimumSize
in classJComponent
-
getPreferredSize
Overrides JComponent method to declare preferred size to be text editor's optimal height.- Overrides:
getPreferredSize
in classJComponent
-
setBounds
public void setBounds(int x, int y, int w, int h) Overrides JComponent method to tell text editor the bounds. -
getPreferredScrollableViewportSize
Scrollable method.- Specified by:
getPreferredScrollableViewportSize
in interfaceScrollable
-
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()Scrollable method.- Specified by:
getScrollableTracksViewportWidth
in interfaceScrollable
-
getScrollableTracksViewportHeight
public boolean getScrollableTracksViewportHeight()Scrollable method.- Specified by:
getScrollableTracksViewportHeight
in interfaceScrollable
-
getScrollableBlockIncrement
Scrollable method.- Specified by:
getScrollableBlockIncrement
in interfaceScrollable
-
getScrollableUnitIncrement
Scrollable method.- Specified by:
getScrollableUnitIncrement
in interfaceScrollable
-
dragEnter
DropTargetListener method.- Specified by:
dragEnter
in interfaceDropTargetListener
-
dragExit
DropTargetListener method.- Specified by:
dragExit
in interfaceDropTargetListener
-
dragOver
DropTargetListener method.- Specified by:
dragOver
in interfaceDropTargetListener
-
drop
DropTargetListener method.- Specified by:
drop
in interfaceDropTargetListener
-
dropActionChanged
DropTargetListener method.- Specified by:
dropActionChanged
in interfaceDropTargetListener
-
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
Returns the char index for given point in text coordinate space. -
getFont
Return AWT Font for current selection.- Specified by:
getFont
in interfaceMenuContainer
- Overrides:
getFont
in classComponent
-
setFont
Set AWT Font for current selection.- Overrides:
setFont
in classJComponent
-