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 Summary
Nested ClassesModifier and TypeClassDescriptionclass
A class to act as text selection.Nested classes/interfaces inherited from interface com.inductiveautomation.rm.text.RMTextTypes
RMTextTypes.TabType
Nested classes/interfaces inherited from interface com.inductiveautomation.rm.base.RMTypes
RMTypes.Align, RMTypes.AlignX, RMTypes.AlignY
-
Field Summary
FieldsFields inherited from interface com.inductiveautomation.rm.text.RMTextTypes
TEXT_CHAR_SPACING, TEXT_COLOR, TEXT_EMBEDDED_SHAPE, TEXT_FONT, TEXT_FORMAT, TEXT_OUTLINE, TEXT_PARAGRAPH, TEXT_SCRIPTING, TEXT_UNDERLINE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt
(int anIndex) Returns the individual character at given index.void
copy()
Copies the current selection onto the clipboard.Creates a configured text layout used to layout text.void
cut()
Copies the current selection onto the clip board, then deletes the current selection.void
delete()
Deletes the current selection.void
delete
(int aStart, int anEnd, boolean doUpdateSelection) Deletes the given range of chars.void
Deletes the character in front of the insertion point.void
Deletes the characters from the insertion point to the end of the line.Returns the alignment for current selection.Returns the text editor bounds.int
getCharIndex
(Point2D aPoint) Returns the char index for given point in text coordinate space.float
Returns 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.double
Returns the scale applied to text when editing.Returns the format of the current selection or cursor.double
Returns the bounds height.float
Returns 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.int
Returns the number of lines.getLineForChar
(int anIndex) Returns the line index for the given character index.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.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.int
Returns the character index of the last explicitly selected char (confined to the bounds of the selection).int
Returns the character index of the end of the text selection.Returns the path for the current selection.int
Returns 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 Object
Returns a selection object for undoer.double
getWidth()
Returns the bounds width.float
Returns the width needed to display all characters.double
getX()
Returns the bounds x.Returns the xstring that is being edited.double
getY()
Returns the bounds y.boolean
Returns whether editor tries to hyphenate wrapped words.boolean
Returns whether the selection is empty.boolean
Returns whether editor is doing check-as-you-type spelling.boolean
Returns whether current selection is underlined.void
keyBackward
(boolean isShiftDown) Moves the insertion point backward a character (or if a range is selected, moves to beginning of range).void
keyDown
(boolean shiftDown) Moves the insertion point down a line, trying preserve distance from beginning of line.void
keyForward
(boolean isShiftDown) Moves the insertion point forward a character (or if a range is selected, moves to end of range).protected void
keyPressed
(KeyEvent anEvent) Handle keyPressed.protected void
Handle keyTyped.void
keyUp
(boolean shiftDown) Moves the insertion point up a line, trying to preserve distance from beginning of line.int
length()
Returns the number of characters in the text string.void
mouseDragged
(MouseEvent anEvent) Handles mouse dragged.void
mousePressed
(MouseEvent anEvent) Handles mouse pressed.void
mouseReleased
(MouseEvent anEvent) Handles mouse released.void
paint
(Graphics2D g) Paints a given layout in a given graphics.void
paste()
Pasts the current clipboard data over the current selection.void
processKeyEvent
(KeyEvent anEvent) Handles key events.void
propertyChange
(PropertyChangeEvent anEvent) Called when characters where added, updated or deleted.void
redo()
Called to redo the last undo operation in the editor.void
relayout()
Tells editor to rebuild layout.void
Replaces the current selection with the given xstring.void
Replaces the current selection with the given xstring.void
Replaces the current selection with the given string.void
Replaces the current selection with the given string.void
replace
(String aString, RMTextStyle aStyle, int aStart, int anEnd, boolean doUpdateSelection) Replaces the current selection with the given string.void
Replaces the current selection with the given string.void
Selects all the characters in the text editor.void
Moves the insertion point to next newline or text end.void
Moves the insertion point to the beginning of line.void
setAlignmentX
(RMTypes.AlignX anAlignmentX) Sets the alignment for current selection.void
setBounds
(double anX, double aY, double aWidth, double aHeight) Sets the text editor bounds.void
setBounds
(Rectangle2D aRect) Sets the text editor bounds.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
(double 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 encompass currently selected, @-sign delineated key.void
setInputAttribute
(String aKey, Object aValue) 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
setOutline
(RMXString.Outline anOutline) Sets whether current selection is outlined.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
setSel
(int aStart, int anEnd, int anAnchor) Sets the character index of the start and end of the text selection.void
Sets current selection to subscript.void
Sets current selection to superscript.void
setUnderlined
(boolean aFlag) Sets whether current selection is underlined.void
setXString
(RMXString aString) Sets the xstring that is to be edited.subSequence
(int aStart, int anEnd) Returns a newCharSequence
that is a subsequence of this sequence.void
undo()
Called to undo the last edit operation in the editor.protected void
Adds a property change to undoer.protected void
Saves changes to undoer.Methods inherited from class com.inductiveautomation.rm.base.RMObject
addPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener, sendPropertyChange, toString
Methods inherited from class com.inductiveautomation.rm.base.RMListenerList
addListener, clone, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, hasListeners, removeListener
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty, toString
-
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
Returns the xstring that is being edited. -
setXString
Sets the xstring that is to be edited. -
getBounds
Returns the text editor bounds. -
setBounds
Sets the text editor bounds. -
setBounds
public void setBounds(double anX, double aY, double aWidth, double aHeight) Sets the text editor bounds. -
getX
public double getX()Returns the bounds x. -
getY
public double getY()Returns the bounds y. -
getWidth
public double getWidth()Returns the bounds width. -
getHeight
public double getHeight()Returns the bounds height. -
length
public int length()Returns the number of characters in the text string.- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int anIndex) Returns the individual character at given index.- Specified by:
charAt
in interfaceCharSequence
-
subSequence
Returns a newCharSequence
that is a subsequence of this sequence.- Specified by:
subSequence
in interfaceCharSequence
-
isSpellChecking
public boolean isSpellChecking()Returns whether editor is doing check-as-you-type spelling. -
isHyphenating
public boolean isHyphenating()Returns whether editor tries to hyphenate wrapped words. -
isSelEmpty
public boolean isSelEmpty()Returns whether the selection is empty. -
getSel
Returns the text editor selection. -
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. -
setSel
public void setSel(int aStart, int anEnd, int anAnchor) Sets the character index of the start and end of the text selection. -
getSelStart
public int getSelStart()Returns 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. -
getSelAnchor
public int getSelAnchor()Returns the character index of the last explicitly selected char (confined to the bounds of the selection). -
selectAll
public void selectAll()Selects all the characters in the text editor. -
getSel
Returns the selected range that would result from the given two points. -
getLineCount
public int getLineCount()Returns the number of lines. -
getLine
Returns the individual line at given index. -
getLineForChar
Returns the line index for the given character index. -
getSelStartLine
Returns the line at selection start. -
getFontScale
public double getFontScale()Returns the scale applied to text when editing. -
setFontScale
public void setFontScale(double aScale) Sets the scale applied to text when editing. -
getLayout
Returns the configured text layout used to layout text. -
createLayout
Creates a configured text layout used to layout text. -
relayout
public void relayout()Tells editor to rebuild layout. -
getCharIndex
Returns the char index for given point in text coordinate space. -
getInputStyle
Returns the text style applied to any input characters. -
setInputAttribute
Sets the attributes that are applied to current selection or newly typed chars. -
getInputParagraph
Returns the paragraph of the current selection or cursor position. -
setInputParagraph
Sets the paragraph of the current selection or cursor position. -
getString
Returns the plain string of the xstring being edited. -
getColor
Returns the color of the current selection or cursor. -
setColor
Sets the color of the current selection or cursor. -
getFont
Returns the font of the current selection or cursor. -
setFont
Sets the font of the current selection or cursor. -
getFormat
Returns the format of the current selection or cursor. -
setFormat
Sets the format of the current selection or cursor, after trying to expand the selection to encompass currently selected, @-sign delineated key. -
isUnderlined
public boolean isUnderlined()Returns whether current selection is underlined. -
setUnderlined
public void setUnderlined(boolean aFlag) Sets whether current selection is underlined. -
getOutline
Returns whether current selection is outlined. -
setOutline
Sets whether current selection is outlined. -
setSuperscript
public void setSuperscript()Sets current selection to superscript. -
setSubscript
public void setSubscript()Sets current selection to subscript. -
getAlignmentX
Returns the alignment for current selection. -
setAlignmentX
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). -
delete
public void delete()Deletes the current selection. -
delete
public void delete(int aStart, int anEnd, boolean doUpdateSelection) Deletes the given range of chars. -
replace
Replaces the current selection with the given string. -
replace
Replaces the current selection with the given string. -
replace
public void replace(@Nonnull String aString, Map theAttrs, int aStart, int anEnd, boolean doUpdateSelection) Replaces the current selection with the given string. -
replace
public void replace(@Nonnull String aString, RMTextStyle aStyle, int aStart, int anEnd, boolean doUpdateSelection) Replaces the current selection with the given string. -
replace
Replaces the current selection with the given xstring. -
replace
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. -
getUndoer
Returns the undoer. -
undo
public void undo()Called to undo the last edit operation in the editor. -
redo
public void redo()Called to redo the last undo operation in the editor. -
propertyChange
Called when characters where added, updated or deleted.- Specified by:
propertyChange
in interfacePropertyChangeListener
-
undoerAddPropertyChange
Adds a property change to undoer. -
undoerSaveChanges
protected void undoerSaveChanges()Saves changes to undoer. -
getUndoSelection
Returns a selection object for undoer. -
keyForward
public void keyForward(boolean isShiftDown) Moves the insertion point forward a character (or if a range is selected, moves to end of range). -
keyBackward
public void keyBackward(boolean isShiftDown) Moves the insertion point backward a character (or if a range is selected, moves to beginning of range). -
keyUp
public void keyUp(boolean shiftDown) Moves the insertion point up a line, trying to preserve distance from beginning of line. -
keyDown
public void keyDown(boolean shiftDown) Moves the insertion point down a line, trying preserve distance from beginning of line. -
selectLineStart
public void selectLineStart()Moves the insertion point to the beginning of line. -
selectLineEnd
public void selectLineEnd()Moves the insertion point to next newline or text end. -
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. -
getWidthToFit
public float getWidthToFit()Returns the width needed to display all characters. -
getHeightToFit
public float getHeightToFit()Returns the height needed to display all characters. -
processKeyEvent
Handles key events. -
keyPressed
Handle keyPressed. -
keyTyped
Handle keyTyped. -
mousePressed
Handles mouse pressed. -
mouseDragged
Handles mouse dragged. -
mouseReleased
Handles mouse released. -
paint
Paints a given layout in a given graphics. -
getSelPath
Returns the path for the current selection. -
getSpellingPath
Returns a path for misspelled word underlining.
-