Package com.inductiveautomation.rm.text
Class RMTextEditor
java.lang.Object
com.inductiveautomation.rm.base.RMListenerList
com.inductiveautomation.rm.base.RMObject
com.inductiveautomation.rm.text.RMTextEditor
- All Implemented Interfaces:
- RMPropertyChanger,- RMTypes,- RMTextTypes,- PropertyChangeListener,- CharSequence,- Cloneable,- EventListener
- Direct Known Subclasses:
- RMEditorTextEditor
public class RMTextEditor
extends RMObject
implements RMTextTypes, CharSequence, PropertyChangeListener
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 SummaryNested ClassesModifier and TypeClassDescriptionclassA class to act as text selection.Nested classes/interfaces inherited from interface com.inductiveautomation.rm.text.RMTextTypesRMTextTypes.TabTypeNested classes/interfaces inherited from interface com.inductiveautomation.rm.base.RMTypesRMTypes.Align, RMTypes.AlignX, RMTypes.AlignY
- 
Field SummaryFieldsFields inherited from interface com.inductiveautomation.rm.text.RMTextTypesTEXT_CHAR_SPACING, TEXT_COLOR, TEXT_EMBEDDED_SHAPE, TEXT_FONT, TEXT_FORMAT, TEXT_OUTLINE, TEXT_PARAGRAPH, TEXT_SCRIPTING, TEXT_UNDERLINE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptioncharcharAt(int anIndex) Returns the individual character at given index.voidcopy()Copies the current selection onto the clipboard.Creates a configured text layout used to layout text.voidcut()Copies the current selection onto the clip board, then deletes the current selection.voiddelete()Deletes the current selection.voiddelete(int aStart, int anEnd, boolean doUpdateSelection) Deletes the given range of chars.voidDeletes the character in front of the insertion point.voidDeletes the characters from the insertion point to the end of the line.Returns the alignment for current selection.Returns the text editor bounds.intgetCharIndex(Point2D aPoint) Returns the char index for given point in text coordinate space.floatReturns the character spacing of the current selection or cursor.getColor()Returns the color of the current selection or cursor.getFont()Returns the font of the current selection or cursor.doubleReturns the scale applied to text when editing.Returns the format of the current selection or cursor.doubleReturns the bounds height.floatReturns the height needed to display all characters.Returns the paragraph of the current selection or cursor position.Returns the text style applied to any input characters.Returns the configured text layout used to layout text.getLine(int anIndex) Returns the individual line at given index.intReturns the number of lines.getLineForChar(int anIndex) Returns the line index for the given character index.floatReturns the line gap for current selection.floatReturns the maximum line height for a line of text (even if font size would dictate higher).floatReturns the min line height for current selection.floatReturns the line spacing for current selection.Returns whether current selection is outlined.getSel()Returns the text editor selection.getSel(double p1x, double p1y, double p2x, double p2y) Returns the selected range that would result from the given two points.intReturns the character index of the last explicitly selected char (confined to the bounds of the selection).intReturns the character index of the end of the text selection.Returns the path for the current selection.intReturns the character index of the start of the text selection.Returns the line at selection start.Returns a path for misspelled word underlining.Returns the plain string of the xstring being edited.Returns the undoer.protected ObjectReturns a selection object for undoer.doublegetWidth()Returns the bounds width.floatReturns the width needed to display all characters.doublegetX()Returns the bounds x.Returns the xstring that is being edited.doublegetY()Returns the bounds y.booleanReturns whether editor tries to hyphenate wrapped words.booleanReturns whether the selection is empty.booleanReturns whether editor is doing check-as-you-type spelling.booleanReturns whether current selection is underlined.voidkeyBackward(boolean isShiftDown) Moves the insertion point backward a character (or if a range is selected, moves to beginning of range).voidkeyDown(boolean shiftDown) Moves the insertion point down a line, trying preserve distance from beginning of line.voidkeyForward(boolean isShiftDown) Moves the insertion point forward a character (or if a range is selected, moves to end of range).protected voidkeyPressed(KeyEvent anEvent) Handle keyPressed.protected voidHandle keyTyped.voidkeyUp(boolean shiftDown) Moves the insertion point up a line, trying to preserve distance from beginning of line.intlength()Returns the number of characters in the text string.voidmouseDragged(MouseEvent anEvent) Handles mouse dragged.voidmousePressed(MouseEvent anEvent) Handles mouse pressed.voidmouseReleased(MouseEvent anEvent) Handles mouse released.voidpaint(Graphics2D g) Paints a given layout in a given graphics.voidpaste()Pasts the current clipboard data over the current selection.voidprocessKeyEvent(KeyEvent anEvent) Handles key events.voidpropertyChange(PropertyChangeEvent anEvent) Called when characters where added, updated or deleted.voidredo()Called to redo the last undo operation in the editor.voidrelayout()Tells editor to rebuild layout.voidReplaces the current selection with the given xstring.voidReplaces the current selection with the given xstring.voidReplaces the current selection with the given string.voidReplaces the current selection with the given string.voidreplace(String aString, RMTextStyle aStyle, int aStart, int anEnd, boolean doUpdateSelection) Replaces the current selection with the given string.voidReplaces the current selection with the given string.voidSelects all the characters in the text editor.voidMoves the insertion point to next newline or text end.voidMoves the insertion point to the beginning of line.voidsetAlignmentX(RMTypes.AlignX anAlignmentX) Sets the alignment for current selection.voidsetBounds(double anX, double aY, double aWidth, double aHeight) Sets the text editor bounds.voidsetBounds(Rectangle2D aRect) Sets the text editor bounds.voidsetCharSpacing(float aValue) Returns the character spacing of the current selection or cursor.voidSets the color of the current selection or cursor.voidSets the font of the current selection or cursor.voidsetFontScale(double aScale) Sets the scale applied to text when editing.voidSets the format of the current selection or cursor, after trying to expand the selection to encompass currently selected, @-sign delineated key.voidsetInputAttribute(String aKey, Object aValue) Sets the attributes that are applied to current selection or newly typed chars.voidSets the paragraph of the current selection or cursor position.voidsetLineGap(float aHeight) Sets the line gap for current selection.voidsetLineHeightMax(float aHeight) Sets the maximum line height for a line of text (even if font size would dictate higher).voidsetLineHeightMin(float aHeight) Sets the min line height for current selection.voidsetLineSpacing(float aHeight) Sets the line spacing for current selection.voidsetOutline(RMXString.Outline anOutline) Sets whether current selection is outlined.voidsetSel(int newStartEnd) Sets the character index of the text cursor.voidsetSel(int aStart, int anEnd) Sets the character index of the start and end of the text selection.voidsetSel(int aStart, int anEnd, int anAnchor) Sets the character index of the start and end of the text selection.voidSets current selection to subscript.voidSets current selection to superscript.voidsetUnderlined(boolean aFlag) Sets whether current selection is underlined.voidsetXString(RMXString aString) Sets the xstring that is to be edited.subSequence(int aStart, int anEnd) Returns a newCharSequencethat is a subsequence of this sequence.voidundo()Called to undo the last edit operation in the editor.protected voidAdds a property change to undoer.protected voidSaves changes to undoer.Methods inherited from class com.inductiveautomation.rm.base.RMObjectaddPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener, sendPropertyChange, toStringMethods inherited from class com.inductiveautomation.rm.base.RMListenerListaddListener, clone, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, hasListeners, removeListenerMethods inherited from class java.lang.Objectequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequencechars, codePoints, isEmpty, toString
- 
Field Details- 
isSpellCheckingpublic static boolean isSpellChecking
- 
isHyphenatingpublic static boolean isHyphenating
 
- 
- 
Constructor Details- 
RMTextEditorpublic RMTextEditor()Creates a plain text editor.
 
- 
- 
Method Details- 
getXStringReturns the xstring that is being edited.
- 
setXStringSets the xstring that is to be edited.
- 
getBoundsReturns the text editor bounds.
- 
setBoundsSets the text editor bounds.
- 
setBoundspublic void setBounds(double anX, double aY, double aWidth, double aHeight) Sets the text editor bounds.
- 
getXpublic double getX()Returns the bounds x.
- 
getYpublic double getY()Returns the bounds y.
- 
getWidthpublic double getWidth()Returns the bounds width.
- 
getHeightpublic double getHeight()Returns the bounds height.
- 
lengthpublic int length()Returns the number of characters in the text string.- Specified by:
- lengthin interface- CharSequence
 
- 
charAtpublic char charAt(int anIndex) Returns the individual character at given index.- Specified by:
- charAtin interface- CharSequence
 
- 
subSequenceReturns a newCharSequencethat is a subsequence of this sequence.- Specified by:
- subSequencein interface- CharSequence
 
- 
isSpellCheckingpublic boolean isSpellChecking()Returns whether editor is doing check-as-you-type spelling.
- 
isHyphenatingpublic boolean isHyphenating()Returns whether editor tries to hyphenate wrapped words.
- 
isSelEmptypublic boolean isSelEmpty()Returns whether the selection is empty.
- 
getSelReturns the text editor selection.
- 
setSelpublic void setSel(int newStartEnd) Sets the character index of the text cursor.
- 
setSelpublic void setSel(int aStart, int anEnd) Sets the character index of the start and end of the text selection.
- 
setSelpublic void setSel(int aStart, int anEnd, int anAnchor) Sets the character index of the start and end of the text selection.
- 
getSelStartpublic int getSelStart()Returns the character index of the start of the text selection.
- 
getSelEndpublic int getSelEnd()Returns the character index of the end of the text selection.
- 
getSelAnchorpublic int getSelAnchor()Returns the character index of the last explicitly selected char (confined to the bounds of the selection).
- 
selectAllpublic void selectAll()Selects all the characters in the text editor.
- 
getSelReturns the selected range that would result from the given two points.
- 
getLineCountpublic int getLineCount()Returns the number of lines.
- 
getLineReturns the individual line at given index.
- 
getLineForCharReturns the line index for the given character index.
- 
getSelStartLineReturns the line at selection start.
- 
getFontScalepublic double getFontScale()Returns the scale applied to text when editing.
- 
setFontScalepublic void setFontScale(double aScale) Sets the scale applied to text when editing.
- 
getLayoutReturns the configured text layout used to layout text.
- 
createLayoutCreates a configured text layout used to layout text.
- 
relayoutpublic void relayout()Tells editor to rebuild layout.
- 
getCharIndexReturns the char index for given point in text coordinate space.
- 
getInputStyleReturns the text style applied to any input characters.
- 
setInputAttributeSets the attributes that are applied to current selection or newly typed chars.
- 
getInputParagraphReturns the paragraph of the current selection or cursor position.
- 
setInputParagraphSets the paragraph of the current selection or cursor position.
- 
getStringReturns the plain string of the xstring being edited.
- 
getColorReturns the color of the current selection or cursor.
- 
setColorSets the color of the current selection or cursor.
- 
getFontReturns the font of the current selection or cursor.
- 
setFontSets the font of the current selection or cursor.
- 
getFormatReturns the format of the current selection or cursor.
- 
setFormatSets the format of the current selection or cursor, after trying to expand the selection to encompass currently selected, @-sign delineated key.
- 
isUnderlinedpublic boolean isUnderlined()Returns whether current selection is underlined.
- 
setUnderlinedpublic void setUnderlined(boolean aFlag) Sets whether current selection is underlined.
- 
getOutlineReturns whether current selection is outlined.
- 
setOutlineSets whether current selection is outlined.
- 
setSuperscriptpublic void setSuperscript()Sets current selection to superscript.
- 
setSubscriptpublic void setSubscript()Sets current selection to subscript.
- 
getAlignmentXReturns the alignment for current selection.
- 
setAlignmentXSets the alignment for current selection.
- 
getCharSpacingpublic float getCharSpacing()Returns the character spacing of the current selection or cursor.
- 
setCharSpacingpublic void setCharSpacing(float aValue) Returns the character spacing of the current selection or cursor.
- 
getLineSpacingpublic float getLineSpacing()Returns the line spacing for current selection.
- 
setLineSpacingpublic void setLineSpacing(float aHeight) Sets the line spacing for current selection.
- 
getLineGappublic float getLineGap()Returns the line gap for current selection.
- 
setLineGappublic void setLineGap(float aHeight) Sets the line gap for current selection.
- 
getLineHeightMinpublic float getLineHeightMin()Returns the min line height for current selection.
- 
setLineHeightMinpublic void setLineHeightMin(float aHeight) Sets the min line height for current selection.
- 
getLineHeightMaxpublic float getLineHeightMax()Returns the maximum line height for a line of text (even if font size would dictate higher).
- 
setLineHeightMaxpublic void setLineHeightMax(float aHeight) Sets the maximum line height for a line of text (even if font size would dictate higher).
- 
deletepublic void delete()Deletes the current selection.
- 
deletepublic void delete(int aStart, int anEnd, boolean doUpdateSelection) Deletes the given range of chars.
- 
replaceReplaces the current selection with the given string.
- 
replaceReplaces the current selection with the given string.
- 
replacepublic void replace(@Nonnull String aString, Map theAttrs, int aStart, int anEnd, boolean doUpdateSelection) Replaces the current selection with the given string.
- 
replacepublic void replace(@Nonnull String aString, RMTextStyle aStyle, int aStart, int anEnd, boolean doUpdateSelection) Replaces the current selection with the given string.
- 
replaceReplaces the current selection with the given xstring.
- 
replaceReplaces the current selection with the given xstring.
- 
cutpublic void cut()Copies the current selection onto the clip board, then deletes the current selection.
- 
copypublic void copy()Copies the current selection onto the clipboard.
- 
pastepublic void paste()Pasts the current clipboard data over the current selection.
- 
getUndoerReturns the undoer.
- 
undopublic void undo()Called to undo the last edit operation in the editor.
- 
redopublic void redo()Called to redo the last undo operation in the editor.
- 
propertyChangeCalled when characters where added, updated or deleted.- Specified by:
- propertyChangein interface- PropertyChangeListener
 
- 
undoerAddPropertyChangeAdds a property change to undoer.
- 
undoerSaveChangesprotected void undoerSaveChanges()Saves changes to undoer.
- 
getUndoSelectionReturns a selection object for undoer.
- 
keyForwardpublic void keyForward(boolean isShiftDown) Moves the insertion point forward a character (or if a range is selected, moves to end of range).
- 
keyBackwardpublic void keyBackward(boolean isShiftDown) Moves the insertion point backward a character (or if a range is selected, moves to beginning of range).
- 
keyUppublic void keyUp(boolean shiftDown) Moves the insertion point up a line, trying to preserve distance from beginning of line.
- 
keyDownpublic void keyDown(boolean shiftDown) Moves the insertion point down a line, trying preserve distance from beginning of line.
- 
selectLineStartpublic void selectLineStart()Moves the insertion point to the beginning of line.
- 
selectLineEndpublic void selectLineEnd()Moves the insertion point to next newline or text end.
- 
deleteForwardpublic void deleteForward()Deletes the character in front of the insertion point.
- 
deleteToLineEndpublic void deleteToLineEnd()Deletes the characters from the insertion point to the end of the line.
- 
getWidthToFitpublic float getWidthToFit()Returns the width needed to display all characters.
- 
getHeightToFitpublic float getHeightToFit()Returns the height needed to display all characters.
- 
processKeyEventHandles key events.
- 
keyPressedHandle keyPressed.
- 
keyTypedHandle keyTyped.
- 
mousePressedHandles mouse pressed.
- 
mouseDraggedHandles mouse dragged.
- 
mouseReleasedHandles mouse released.
- 
paintPaints a given layout in a given graphics.
- 
getSelPathReturns the path for the current selection.
- 
getSpellingPathReturns a path for misspelled word underlining.
 
-