public class TextComponent extends javax.swing.JComponent implements java.beans.PropertyChangeListener, TextTypes, java.lang.CharSequence
Modifier and Type | Class and Description |
---|---|
class |
TextComponent.TextSelection
A class to act as text selection.
|
javax.swing.JComponent.AccessibleJComponent
java.awt.Container.AccessibleAWTContainer
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
TextTypes.TabType
RMTypes.Align, RMTypes.AlignX, RMTypes.AlignY
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
TEXT_CHAR_SPACING, TEXT_COLOR, TEXT_FONT, TEXT_FORMAT, TEXT_LINK, TEXT_OUTLINE, TEXT_SCRIPTING, TEXT_UNDERLINE
Constructor and Description |
---|
TextComponent()
Creates a new TextComponent.
|
Modifier and Type | Method and Description |
---|---|
protected double |
calcPrefHeight()
Returns the height needed to display all characters.
|
protected double |
calcPrefWidth()
Returns the width needed to display all characters.
|
char |
charAt(int anIndex)
Returns the individual character at given index.
|
void |
copy()
Copies the current selection onto the clipboard.
|
protected Text |
createText()
Creates a new 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 doUpdateSel)
Deletes the given range of chars.
|
void |
deleteBackward()
Deletes the character before of the insertion point.
|
void |
deleteForward()
Deletes the character after of the insertion point.
|
void |
deleteToLineEnd()
Deletes the characters from the insertion point to the end of the line.
|
RMTypes.AlignX |
getAlignX()
Returns the alignment for current selection.
|
int |
getCharIndex(double anX,
double aY)
Returns the char index for given point in text coordinate space.
|
int |
getCharIndex(java.awt.geom.Point2D aPoint)
Returns the char index for given point in text coordinate space.
|
double |
getCharSpacing()
Returns the character spacing of the current selection or cursor.
|
SnapColor |
getColor()
Returns the color of the current selection or cursor.
|
TextLine |
getInputLine()
Returns the line for the current selection start index.
|
TextStyle |
getInputStyle()
Returns the TextStyle applied to any input characters.
|
TextLine |
getLine(int anIndex)
Returns the individual line at given index.
|
TextLine |
getLineAt(int anIndex)
Returns the line for the given character index.
|
int |
getLineCount()
Returns the number of lines.
|
TextLine |
getLineFor(int anIndex)
Returns the line for the given character index or last line if at end.
|
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.
|
TextLine |
getLineLast()
Returns the last line.
|
float |
getLineSpacing()
Returns the line spacing for current selection.
|
java.awt.Insets |
getMargin()
Returns the text margins.
|
java.awt.geom.GeneralPath |
getPathForChars(int aStart,
int anEnd)
Returns a path for two char indexes - it will be a a simple box with extensions for first/last lines.
|
java.awt.Dimension |
getPreferredSize()
Overrides JComponent method to declare preferred size to be text's preferred size.
|
TextSel |
getSel()
Returns the selection.
|
int |
getSelAnchor()
Returns the character index of the last explicitly selected char (confined to the bounds of the selection).
|
java.awt.Color |
getSelColor()
Returns the selection color.
|
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 |
getSelSize()
Returns the number of chars in the selection.
|
int |
getSelStart()
Returns the character index of the start of the text selection.
|
java.lang.String |
getString()
Returns the plain string of the text being edited.
|
Text |
getText()
Returns the text that is being edited.
|
SnapFont |
getTextFont()
Returns the font of the current selection or cursor.
|
TextToken |
getTokenAt(int anIndex)
Returns the token for given character index.
|
RMUndoer |
getUndoer()
Returns the undoer.
|
protected java.lang.Object |
getUndoSelection()
Returns a selection object for undoer.
|
void |
hideCursor()
Hides the cursor.
|
boolean |
isSelEmpty()
Returns whether the selection is empty.
|
boolean |
isUnderlined()
Returns whether current selection is underlined.
|
protected void |
keyPressed(java.awt.event.KeyEvent anEvent)
Called when a key is pressed.
|
protected void |
keyReleased(java.awt.event.KeyEvent anEvent)
Called when a key is released.
|
protected void |
keyTyped(java.awt.event.KeyEvent anEvent)
Called when a key is typed.
|
int |
length()
Returns the number of characters in the text string.
|
protected void |
mouseDragged(java.awt.event.MouseEvent anEvent)
Handles mouse dragged.
|
protected void |
mousePressed(java.awt.event.MouseEvent anEvent)
Handles mouse pressed.
|
protected void |
mouseReleased(java.awt.event.MouseEvent anEvent)
Handles mouse released.
|
protected void |
paintBackground(java.awt.Graphics2D aGraphics)
Paints background.
|
void |
paintComponent(java.awt.Graphics g)
Overrides JComponent to paint text editor text.
|
protected void |
paintLine(java.awt.Graphics2D aGraphics,
TextLine aLine,
double anX,
double aY)
Paints a TextLine.
|
protected void |
paintText(java.awt.Graphics2D aGraphics)
Paints text area lines.
|
protected void |
paintTextSelection(java.awt.Graphics2D aGraphics)
Paints text selection.
|
protected void |
paintToken(java.awt.Graphics2D aGraphics,
TextToken aToken,
double anX,
double aY)
Paints a TextToken.
|
void |
paste()
Pasts the current clipboard data over the current selection.
|
protected void |
processComponentKeyEvent(java.awt.event.KeyEvent anEvent)
Overrides JComponent to forward to keyPressed(), keyReleased(), keyTyped().
|
protected void |
processFocusEvent(java.awt.event.FocusEvent e)
Override to show hidden cursor.
|
protected void |
processMouseEvent(java.awt.event.MouseEvent anEvent)
Overrides JComponent method to forward mouse pressed/released to text editor.
|
protected void |
processMouseMotionEvent(java.awt.event.MouseEvent anEvent)
Overrides JComponent method to forward mouse drags to text editor.
|
void |
propertyChange(java.beans.PropertyChangeEvent anEvent)
Called when characters where added, updated or deleted.
|
boolean |
redo()
Called to redo the last undo operation in the editor.
|
void |
replace(java.lang.String aString)
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 |
selectAll()
Selects all the characters in the text editor.
|
void |
selectBackward(boolean isShiftDown)
Moves the selection index backward a character (or if a range is selected, moves to beginning of range).
|
void |
selectDown()
Moves the selection index down a line, trying preserve distance from beginning of line.
|
void |
selectForward(boolean isShiftDown)
Moves the selection index forward a character (or if a range is selected, moves to end of range).
|
void |
selectLineEnd()
Moves the insertion point to next newline or text end.
|
void |
selectLineStart()
Moves the insertion point to the beginning of line.
|
void |
selectUp()
Moves the selection index up a line, trying to preserve distance from beginning of line.
|
void |
setAlignX(RMTypes.AlignX anAlignX)
Sets the alignment for current selection.
|
void |
setBounds(int x,
int y,
int w,
int h)
Overrides JComponent method to update TextEditor.Text bounds.
|
void |
setCharSpacing(float aValue)
Returns the character spacing of the current selection or cursor.
|
void |
setColor(SnapColor aColor)
Sets the color of the current selection or cursor.
|
void |
setFont(java.awt.Font aFont)
Set AWT Font for current selection.
|
void |
setInputAttribute(java.lang.String aKey,
java.lang.Object aValue)
Sets the attributes that are applied to current selection or newly typed chars.
|
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 |
setMargin(java.awt.Insets theInsets)
Sets the text margins.
|
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 |
setSel(int aStart,
int anEnd,
int anAnchor)
Sets the character index of the start and end of the text selection.
|
void |
setSource(java.lang.Object aSource)
Set the source for TextComponent text.
|
void |
setString(java.lang.String aString)
Set text string of text editor.
|
void |
setSubscript()
Sets current selection to subscript.
|
void |
setSuperscript()
Sets current selection to superscript.
|
void |
setText(Text aText)
Sets the text that is to be edited.
|
void |
setTextFont(SnapFont aFont)
Sets the font of the current selection or cursor.
|
protected void |
setTextRect()
Sets the Text.Rect from text area.
|
void |
setUnderlined(boolean aFlag)
Sets whether current selection is underlined.
|
void |
showCursor()
Shows the cursor.
|
java.lang.CharSequence |
subSequence(int aStart,
int anEnd)
Returns a new
CharSequence that is a subsequence of this sequence. |
boolean |
undo()
Called to undo the last edit operation in the editor.
|
protected void |
undoerAddPropertyChange(java.beans.PropertyChangeEvent anEvent)
Adds a property change to undoer.
|
void |
undoerSaveChanges()
Saves changes to undoer.
|
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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, 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
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
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, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, 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, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public void setSource(java.lang.Object aSource)
public Text getText()
public void setText(Text aText)
protected Text createText()
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 java.lang.String getString()
public void setString(java.lang.String aString)
public int getLineCount()
public TextLine getLine(int anIndex)
public TextLine getLineLast()
public TextLine getLineAt(int anIndex)
public TextLine getLineFor(int anIndex)
public TextToken getTokenAt(int anIndex)
public int getCharIndex(java.awt.geom.Point2D aPoint)
public int getCharIndex(double anX, double aY)
public java.awt.Insets getMargin()
public void setMargin(java.awt.Insets theInsets)
public boolean isSelEmpty()
public int getSelSize()
public int getSelStart()
public int getSelEnd()
public int getSelAnchor()
public TextSel getSel()
public void setSel(int newStartEnd)
public void setSel(int aStart, int anEnd)
public void setSel(int aStart, int anEnd, int anAnchor)
public void selectAll()
public void selectForward(boolean isShiftDown)
public void selectBackward(boolean isShiftDown)
public void selectUp()
public void selectDown()
public void selectLineStart()
public void selectLineEnd()
public void replace(java.lang.String aString)
public void replace(java.lang.String aString, java.util.Map theAttrs, int aStart, int anEnd, boolean doUpdateSelection)
public void delete()
public void delete(int aStart, int anEnd, boolean doUpdateSel)
public void deleteBackward()
public void deleteForward()
public void deleteToLineEnd()
public TextStyle getInputStyle()
public void setInputAttribute(java.lang.String aKey, java.lang.Object aValue)
public TextLine getInputLine()
public SnapColor getColor()
public void setColor(SnapColor aColor)
public SnapFont getTextFont()
public void setTextFont(SnapFont aFont)
public void setFont(java.awt.Font aFont)
setFont
in class javax.swing.JComponent
public boolean isUnderlined()
public void setUnderlined(boolean aFlag)
public void setSuperscript()
public void setSubscript()
public RMTypes.AlignX getAlignX()
public void setAlignX(RMTypes.AlignX anAlignX)
public double 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 setBounds(int x, int y, int w, int h)
setBounds
in class java.awt.Component
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
protected double calcPrefWidth()
protected double calcPrefHeight()
protected void setTextRect()
public java.awt.Color getSelColor()
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
protected void paintBackground(java.awt.Graphics2D aGraphics)
protected void paintTextSelection(java.awt.Graphics2D aGraphics)
protected void paintText(java.awt.Graphics2D aGraphics)
protected void paintLine(java.awt.Graphics2D aGraphics, TextLine aLine, double anX, double aY)
protected void paintToken(java.awt.Graphics2D aGraphics, TextToken aToken, double anX, double aY)
protected void setRenderingHints(java.awt.Graphics2D aGraphics)
public java.awt.geom.GeneralPath getSelPath()
public java.awt.geom.GeneralPath getPathForChars(int aStart, int anEnd)
protected void processMouseEvent(java.awt.event.MouseEvent anEvent)
processMouseEvent
in class javax.swing.JComponent
protected void processMouseMotionEvent(java.awt.event.MouseEvent anEvent)
processMouseMotionEvent
in class javax.swing.JComponent
protected void mousePressed(java.awt.event.MouseEvent anEvent)
protected void mouseDragged(java.awt.event.MouseEvent anEvent)
protected void mouseReleased(java.awt.event.MouseEvent anEvent)
protected void processComponentKeyEvent(java.awt.event.KeyEvent anEvent)
processComponentKeyEvent
in class javax.swing.JComponent
protected void keyTyped(java.awt.event.KeyEvent anEvent)
protected void keyPressed(java.awt.event.KeyEvent anEvent)
protected void keyReleased(java.awt.event.KeyEvent anEvent)
protected void processFocusEvent(java.awt.event.FocusEvent e)
processFocusEvent
in class java.awt.Component
public void showCursor()
public void hideCursor()
public void cut()
public void copy()
public void paste()
public RMUndoer getUndoer()
public boolean undo()
public boolean redo()
protected void undoerAddPropertyChange(java.beans.PropertyChangeEvent anEvent)
public void undoerSaveChanges()
protected java.lang.Object getUndoSelection()
public void propertyChange(java.beans.PropertyChangeEvent anEvent)
propertyChange
in interface java.beans.PropertyChangeListener