public class RMTextEditor extends SnapObject implements RMTextTypes, java.lang.CharSequence, java.beans.PropertyChangeListener
Modifier and Type | Class and Description |
---|---|
class |
RMTextEditor.TextSelection
A class to act as text selection.
|
RMTextTypes.TabType
RMTypes.Align, RMTypes.AlignX, RMTypes.AlignY
Modifier and Type | Field and Description |
---|---|
static boolean |
isHyphenating |
static boolean |
isSpellChecking |
TEXT_CHAR_SPACING, TEXT_COLOR, TEXT_EMBEDDED_SHAPE, TEXT_FONT, TEXT_FORMAT, TEXT_OUTLINE, TEXT_PARAGRAPH, TEXT_SCRIPTING, TEXT_UNDERLINE
Constructor and Description |
---|
RMTextEditor()
Creates a plain text editor.
|
Modifier and Type | Method and Description |
---|---|
char |
charAt(int anIndex)
Returns the individual character at given index.
|
void |
copy()
Copies the current selection onto the clipboard.
|
RMTextLayout |
createLayout()
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 |
deleteForward()
Deletes the character in front of the insertion point.
|
void |
deleteToLineEnd()
Deletes the characters from the insertion point to the end of the line.
|
RMTypes.AlignX |
getAlignmentX()
Returns the alignment for current selection.
|
java.awt.geom.Rectangle2D |
getBounds()
Returns the text editor bounds.
|
int |
getCharIndex(java.awt.geom.Point2D aPoint)
Returns the char index for given point in text coordinate space.
|
float |
getCharSpacing()
Returns the character spacing of the current selection or cursor.
|
RMColor |
getColor()
Returns the color of the current selection or cursor.
|
RMFont |
getFont()
Returns the font of the current selection or cursor.
|
double |
getFontScale()
Returns the scale applied to text when editing.
|
RMFormat |
getFormat()
Returns the format of the current selection or cursor.
|
double |
getHeight()
Returns the bounds height.
|
float |
getHeightToFit()
Returns the height needed to display all characters.
|
RMParagraph |
getInputParagraph()
Returns the paragraph of the current selection or cursor position.
|
RMTextStyle |
getInputStyle()
Returns the text style applied to any input characters.
|
RMTextLayout |
getLayout()
Returns the configured text layout used to layout text.
|
RMTextLine |
getLine(int anIndex)
Returns the individual line at given index.
|
int |
getLineCount()
Returns the number of lines.
|
RMTextLine |
getLineForChar(int anIndex)
Returns the line index for the given character index.
|
float |
getLineGap()
Returns the line gap for current selection.
|
float |
getLineHeightMax()
Returns the maximum line height for a line of text (even if font size would dictate higher).
|
float |
getLineHeightMin()
Returns the min line height for current selection.
|
float |
getLineSpacing()
Returns the line spacing for current selection.
|
RMXString.Outline |
getOutline()
Returns whether current selection is outlined.
|
RMTextSel |
getSel()
Returns the text editor selection.
|
RMTextSel |
getSel(double p1x,
double p1y,
double p2x,
double p2y)
Returns the selected range that would result from the given two points.
|
int |
getSelAnchor()
Returns the character index of the last explicitly selected char (confined to the bounds of the selection).
|
int |
getSelEnd()
Returns the character index of the end of the text selection.
|
java.awt.geom.GeneralPath |
getSelPath()
Returns the path for the current selection.
|
int |
getSelStart()
Returns the character index of the start of the text selection.
|
RMTextLine |
getSelStartLine()
Returns the line at selection start.
|
java.awt.geom.GeneralPath |
getSpellingPath()
Returns a path for misspelled word underlining.
|
java.lang.String |
getString()
Returns the plain string of the xstring being edited.
|
Undoer |
getUndoer()
Returns the undoer.
|
double |
getWidth()
Returns the bounds width.
|
float |
getWidthToFit()
Returns the width needed to display all characters.
|
double |
getX()
Returns the bounds x.
|
RMXString |
getXString()
Returns the xstring that is being edited.
|
double |
getY()
Returns the bounds y.
|
boolean |
isHyphenating()
Returns whether editor tries to hyphenate wrapped words.
|
boolean |
isSelEmpty()
Returns whether the selection is empty.
|
boolean |
isSpellChecking()
Returns whether editor is doing check-as-you-type spelling.
|
boolean |
isUnderlined()
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()
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).
|
void |
keyUp()
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(java.awt.event.MouseEvent anEvent)
Handles mouse dragged.
|
void |
mousePressed(java.awt.event.MouseEvent anEvent)
Handles mouse pressed.
|
void |
mouseReleased(java.awt.event.MouseEvent anEvent)
Handles mouse released.
|
void |
paint(java.awt.Graphics2D g)
Paints a given layout in a given graphics.
|
void |
paste()
Pasts the current clipboard data over the current selection.
|
void |
processKeyEvent(java.awt.event.KeyEvent anEvent)
Handles key events.
|
void |
propertyChange(java.beans.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 |
replace(RMXString anXString)
Replaces the current selection with the given xstring.
|
void |
replace(RMXString anXString,
int aStart,
int anEnd,
boolean doUpdateSelection)
Replaces the current selection with the given xstring.
|
void |
replace(java.lang.String aString)
Replaces the current selection with the given string.
|
void |
replace(java.lang.String aString,
int aStart,
int anEnd,
boolean doUpdateSelection)
Replaces the current selection with the given string.
|
void |
replace(java.lang.String aString,
java.util.Map theAttrs,
int aStart,
int anEnd,
boolean doUpdateSelection)
Replaces the current selection with the given string.
|
void |
replace(java.lang.String aString,
RMTextStyle aStyle,
int aStart,
int anEnd,
boolean doUpdateSelection)
Replaces the current selection with the given string.
|
void |
selectAll()
Selects all the characters in the text editor.
|
void |
selectLineEnd()
Moves the insertion point to next newline or text end.
|
void |
selectLineStart()
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(java.awt.geom.Rectangle2D aRect)
Sets the text editor bounds.
|
void |
setCharSpacing(float aValue)
Returns the character spacing of the current selection or cursor.
|
void |
setColor(RMColor color)
Sets the color of the current selection or cursor.
|
void |
setFont(RMFont font)
Sets the font of the current selection or cursor.
|
void |
setFontScale(double aScale)
Sets the scale applied to text when editing.
|
void |
setFormat(RMFormat aFormat)
Sets the format of the current selection or cursor, after trying to expand the selection to encompass currently
selected, @-sign delineated key.
|
void |
setInputAttribute(java.lang.String aKey,
java.lang.Object aValue)
Sets the attributes that are applied to current selection or newly typed chars.
|
void |
setInputParagraph(RMParagraph ps)
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 |
setSubscript()
Sets current selection to subscript.
|
void |
setSuperscript()
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.
|
java.lang.CharSequence |
subSequence(int aStart,
int anEnd)
Returns a new
CharSequence that is a subsequence of this sequence. |
void |
undo()
Called to undo the last edit operation in the editor.
|
public static boolean isSpellChecking
public static boolean isHyphenating
public RMXString getXString()
public void setXString(RMXString aString)
public java.awt.geom.Rectangle2D getBounds()
public void setBounds(java.awt.geom.Rectangle2D aRect)
public void setBounds(double anX, double aY, double aWidth, double aHeight)
public double getX()
public double getY()
public double getWidth()
public double getHeight()
public int length()
length
in interface java.lang.CharSequence
public char charAt(int anIndex)
charAt
in interface java.lang.CharSequence
public java.lang.CharSequence subSequence(int aStart, int anEnd)
CharSequence
that is a subsequence of this sequence.subSequence
in interface java.lang.CharSequence
public boolean isSpellChecking()
public boolean isHyphenating()
public boolean isSelEmpty()
public RMTextSel getSel()
public void setSel(int newStartEnd)
public void setSel(int aStart, int anEnd)
public void setSel(int aStart, int anEnd, int anAnchor)
public int getSelStart()
public int getSelEnd()
public int getSelAnchor()
public void selectAll()
public RMTextSel getSel(double p1x, double p1y, double p2x, double p2y)
public int getLineCount()
public RMTextLine getLine(int anIndex)
public RMTextLine getLineForChar(int anIndex)
public RMTextLine getSelStartLine()
public double getFontScale()
public void setFontScale(double aScale)
public RMTextLayout getLayout()
public RMTextLayout createLayout()
public void relayout()
public int getCharIndex(java.awt.geom.Point2D aPoint)
public RMTextStyle getInputStyle()
public void setInputAttribute(java.lang.String aKey, java.lang.Object aValue)
public RMParagraph getInputParagraph()
public void setInputParagraph(RMParagraph ps)
public java.lang.String getString()
public RMColor getColor()
public void setColor(RMColor color)
public RMFont getFont()
public void setFont(RMFont font)
public RMFormat getFormat()
public void setFormat(RMFormat aFormat)
public boolean isUnderlined()
public void setUnderlined(boolean aFlag)
public RMXString.Outline getOutline()
public void setOutline(RMXString.Outline anOutline)
public void setSuperscript()
public void setSubscript()
public RMTypes.AlignX getAlignmentX()
public void setAlignmentX(RMTypes.AlignX anAlignmentX)
public float getCharSpacing()
public void setCharSpacing(float aValue)
public float getLineSpacing()
public void setLineSpacing(float aHeight)
public float getLineGap()
public void setLineGap(float aHeight)
public float getLineHeightMin()
public void setLineHeightMin(float aHeight)
public float getLineHeightMax()
public void setLineHeightMax(float aHeight)
public void delete()
public void delete(int aStart, int anEnd, boolean doUpdateSelection)
public void replace(java.lang.String aString)
public void replace(java.lang.String aString, int aStart, int anEnd, boolean doUpdateSelection)
public void replace(java.lang.String aString, java.util.Map theAttrs, int aStart, int anEnd, boolean doUpdateSelection)
public void replace(java.lang.String aString, RMTextStyle aStyle, int aStart, int anEnd, boolean doUpdateSelection)
public void replace(RMXString anXString)
public void replace(RMXString anXString, int aStart, int anEnd, boolean doUpdateSelection)
public void cut()
public void copy()
public void paste()
public Undoer getUndoer()
public void undo()
public void redo()
public void propertyChange(java.beans.PropertyChangeEvent anEvent)
propertyChange
in interface java.beans.PropertyChangeListener
public void keyForward(boolean isShiftDown)
public void keyBackward(boolean isShiftDown)
public void keyUp()
public void keyDown()
public void selectLineStart()
public void selectLineEnd()
public void deleteForward()
public void deleteToLineEnd()
public float getWidthToFit()
public float getHeightToFit()
public void processKeyEvent(java.awt.event.KeyEvent anEvent)
public void mousePressed(java.awt.event.MouseEvent anEvent)
public void mouseDragged(java.awt.event.MouseEvent anEvent)
public void mouseReleased(java.awt.event.MouseEvent anEvent)
public void paint(java.awt.Graphics2D g)
public java.awt.geom.GeneralPath getSelPath()
public java.awt.geom.GeneralPath getSpellingPath()