| java.awt.Rectangle org.netbeans.modules.visualweb.text.DesignerCaret
DesignerCaret | class DesignerCaret extends Rectangle implements FocusListener,MouseListener,MouseMotionListener(Code) | | Caret to use in flow mode editing in the designer.
Derived from Swing's DesignerCaret code but changed integer dot/mark
based code to use DOM Range objects, changed document update semantics,
and mouse operations since we can't blindly listen for mouse clicks
we have to take directions from the SelectionManager.
author: Timothy Prinzing author: Tor Norbye |
Inner Class :class SafeScroller implements Runnable | |
Constructor Summary | |
public | DesignerCaret() Constructs a default caret. |
async | boolean async(Code) | | flag to indicate if async updates should move the caret.
|
selectionVisible | boolean selectionVisible(Code) | | |
DesignerCaret | public DesignerCaret()(Code) | | Constructs a default caret.
|
adjustVisibility | protected void adjustVisibility(Rectangle nloc)(Code) | | Scrolls the associated view (if necessary) to make the caret visible. Since how this should
be done is somewhat of a policy, this method can be reimplemented to change the behavior. By
default the scrollRectToVisible method is called on the associated component.
Parameters: nloc - the new position to scroll to |
changeCaretPosition | void changeCaretPosition(DomPosition dot)(Code) | | Sets the caret position (dot) to a new location. This causes the old and new location to be
repainted. It also makes sure that the caret is within the visible region of the view, if the
view is scrollable.
|
damage | protected synchronized void damage(Rectangle r)(Code) | | Damages the area surrounding the caret to cause it to be repainted in a new location. If
paint() is reimplemented, this method should also be reimplemented. This method should update
the caret bounds (x, y, width, and height).
Parameters: r - the current location of the caret See Also: DesignerCaret.paint |
deinstall | public void deinstall(DesignerPaneBase c)(Code) | | Called when the UI is being removed from the interface of a JTextComponent. This is used to
unregister any listeners that were attached.
Parameters: c - the component |
detachDom | public void detachDom()(Code) | | Notify caret that the range it is attached to is no longer valid
|
equals | public boolean equals(Object obj)(Code) | | Compares this object to the specified object. The superclass behavior of comparing rectangles
is not desired, so this is changed to the Object behavior.
Parameters: obj - the object to compare this font with true if the objects are equal; false otherwise |
focusGained | public void focusGained(FocusEvent e)(Code) | | Called when the component containing the caret gains focus. This is implemented to set the
caret to visible if the component is editable.
Parameters: e - the focus event See Also: FocusListener.focusGained |
focusLost | public void focusLost(FocusEvent e)(Code) | | Called when the component containing the caret loses focus. This is implemented to set the
caret to visibility to false.
Parameters: e - the focus event See Also: FocusListener.focusLost |
getAsynchronousMovement | boolean getAsynchronousMovement()(Code) | | Get the flag that determines whether or not asynchronous updates will move the caret.
Normally the caret is moved by events from the event thread such as mouse or keyboard events.
Changes from another thread might be used to load a file, or show changes from another user.
This flag determines whether those changes will move the caret.
|
getBlinkRate | public int getBlinkRate()(Code) | | Gets the caret blink rate.
the delay in milliseconds. If this is zero the caret will not blink. |
getComponent | final protected DesignerPaneBase getComponent()(Code) | | Gets the text editor component that this caret is is bound to.
the component |
getDot | public DomPosition getDot()(Code) | | Fetches the current position of the caret.
The caret dot position is always a source position.
the position >= 0 |
getFirstPosition | public DomPosition getFirstPosition()(Code) | | Return the first endpoint of the range in the document.
This is always a source position.
|
getLastPosition | public DomPosition getLastPosition()(Code) | | Return the second/last endpoint of the range in the document.
This is always a source position.
|
getMagicCaretPosition | public Point getMagicCaretPosition()(Code) | | Gets the saved caret position.
the position see #setMagicCaretPosition |
getMark | public DomPosition getMark()(Code) | | Fetches the current position of the mark. If there is a selection, the dot and mark will not
be the same.
The caret mark position is always a source position.
the position >= 0 |
getRange | public DomRange getRange()(Code) | | |
handleMoveDot | void handleMoveDot(DomPosition dot)(Code) | | |
handleSetDot | void handleSetDot(DomPosition dot)(Code) | | |
hasSelection | public boolean hasSelection()(Code) | | Return true iff we have a selection - or put differently, if the dot is at a different
location than the mark.
|
install | public void install(DesignerPaneBase c)(Code) | | Called when the UI is being installed into the interface of a JTextComponent. This can be
used to gain access to the model that is being navigated by the implementation of this
interface. Sets the dot and mark to 0, and establishes document, property change, focus,
mouse, and mouse motion listeners.
Parameters: c - the component |
isReadOnlyRegion | public boolean isReadOnlyRegion()(Code) | | Return true iff the caret is within a read only region
|
isSelectionVisible | public boolean isSelectionVisible()(Code) | | Checks whether the current selection is visible.
true if the selection is visible |
isVisible | public boolean isVisible()(Code) | | Determines if the caret is currently visible.
true if visible else false |
mouseClicked | public void mouseClicked(MouseEvent e)(Code) | | Called when the mouse is clicked. If the click was generated from button1, a double click
selects a word, and a triple click the current line.
Parameters: e - the mouse event See Also: MouseListener.mouseClicked |
mouseDragged | public void mouseDragged(MouseEvent e)(Code) | | Moves the caret position according to the mouse pointer's current location. This effectively
extends the selection. By default, this is only done for mouse button 1.
Parameters: e - the mouse event See Also: MouseMotionListener.mouseDragged |
mousePressed | public void mousePressed(MouseEvent e)(Code) | | If button 1 is pressed, this is implemented to request focus on the associated text
component, and to set the caret position. If the shift key is held down, the caret will be
moved, potentially resulting in a selection, otherwise the caret position will be set to the
new location. If the component is not enabled, there will be no request for focus.
Parameters: e - the mouse event See Also: MouseListener.mousePressed |
moveDot | public void moveDot(DomPosition dot)(Code) | | Moves the caret position to some other position.
Parameters: dot - the position >= 0 |
paint | public void paint(Graphics g)(Code) | | Renders the caret as a vertical line. If this is reimplemented the damage method should also
be reimplemented as it assumes the shape of the caret is a vertical line. Sets the caret
color to the value returned by getCaretColor().
Parameters: g - the graphics context See Also: DesignerCaret.damage |
removeNextChar | public boolean removeNextChar()(Code) | | |
removePreviousChar | public boolean removePreviousChar()(Code) | | |
removeSelection | void removeSelection()(Code) | | |
repaint | final protected synchronized void repaint()(Code) | | Cause the caret to be painted. The repaint area is the bounding box of the caret (i.e. the
caret rectangle or this).
This method is thread safe, although most Swing methods are not. Please see Threads and Swing
for more information.
|
repaintNewCaret | void repaintNewCaret()(Code) | | Repaints the new caret position, with the assumption that this is happening on the event
thread so that calling modelToView is safe.
|
repaintSelection | final protected synchronized void repaintSelection()(Code) | | Cause the selection region to be painted.
|
replaceSelection | boolean replaceSelection(String content)(Code) | | |
setAsynchronousMovement | void setAsynchronousMovement(boolean m)(Code) | | Set the flag that determines whether or not asynchronous updates will move the caret.
Normally the caret is moved by events from the event thread such as mouse or keyboard events.
Changes from another thread might be used to load a file, or show changes from another user.
This flag determines whether those changes will move the caret.
Parameters: m - move the caret on asynchronous updates if true. |
setBlinkRate | public void setBlinkRate(int rate)(Code) | | Sets the caret blink rate.
Parameters: rate - the rate in milliseconds, 0 to stop blinking |
setDot | public void setDot(DomPosition dot)(Code) | | Sets the caret position and mark to some position. This implicitly sets the selection range
to zero.
Parameters: dot - the position >= 0 |
setMagicCaretPosition | public void setMagicCaretPosition(Point p)(Code) | | Saves the current caret position. This is used when caret up/down actions occur, moving
between lines that have uneven end positions.
Parameters: p - the position See Also: DesignerCaret.getMagicCaretPosition |
setSelectionVisible | public void setSelectionVisible(boolean vis)(Code) | | Changes the selection visibility.
Parameters: vis - the new visibility |
setVisible | public void setVisible(boolean e)(Code) | | Sets the caret visibility, and repaints the caret.
Parameters: e - the visibility specifier |
Methods inherited from java.awt.Rectangle | public void add(int newx, int newy)(Code)(Java Doc) public void add(Point pt)(Code)(Java Doc) public void add(Rectangle r)(Code)(Java Doc) public boolean contains(Point p)(Code)(Java Doc) public boolean contains(int x, int y)(Code)(Java Doc) public boolean contains(Rectangle r)(Code)(Java Doc) public boolean contains(int X, int Y, int W, int H)(Code)(Java Doc) public Rectangle2D createIntersection(Rectangle2D r)(Code)(Java Doc) public Rectangle2D createUnion(Rectangle2D r)(Code)(Java Doc) public boolean equals(Object obj)(Code)(Java Doc) public Rectangle getBounds()(Code)(Java Doc) public Rectangle2D getBounds2D()(Code)(Java Doc) public double getHeight()(Code)(Java Doc) public Point getLocation()(Code)(Java Doc) public Dimension getSize()(Code)(Java Doc) public double getWidth()(Code)(Java Doc) public double getX()(Code)(Java Doc) public double getY()(Code)(Java Doc) public void grow(int h, int v)(Code)(Java Doc) public boolean inside(int X, int Y)(Code)(Java Doc) public Rectangle intersection(Rectangle r)(Code)(Java Doc) public boolean intersects(Rectangle r)(Code)(Java Doc) public boolean isEmpty()(Code)(Java Doc) public void move(int x, int y)(Code)(Java Doc) public int outcode(double x, double y)(Code)(Java Doc) public void reshape(int x, int y, int width, int height)(Code)(Java Doc) public void resize(int width, int height)(Code)(Java Doc) public void setBounds(Rectangle r)(Code)(Java Doc) public void setBounds(int x, int y, int width, int height)(Code)(Java Doc) public void setLocation(Point p)(Code)(Java Doc) public void setLocation(int x, int y)(Code)(Java Doc) public void setRect(double x, double y, double width, double height)(Code)(Java Doc) public void setSize(Dimension d)(Code)(Java Doc) public void setSize(int width, int height)(Code)(Java Doc) public String toString()(Code)(Java Doc) public void translate(int dx, int dy)(Code)(Java Doc) public Rectangle union(Rectangle r)(Code)(Java Doc)
|
|
|