com.raelity.jvi.swing
Class DefaultViCaret

java.lang.Object
  extended by java.awt.geom.RectangularShape
      extended by java.awt.geom.Rectangle2D
          extended by java.awt.Rectangle
              extended by javax.swing.text.DefaultCaret
                  extended by com.raelity.jvi.swing.DefaultViCaret
All Implemented Interfaces:
ViCaret, FocusListener, MouseListener, MouseMotionListener, Shape, Serializable, Cloneable, EventListener, Caret

public class DefaultViCaret
extends DefaultCaret
implements ViCaret

This extension of DefaultCaret draws the caret in different ways as defined by the cursor property. // NEEDSWORK: cache the current font metric, listen to font property changes

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D
Rectangle2D.Double, Rectangle2D.Float
 
Field Summary
 
Fields inherited from class javax.swing.text.DefaultCaret
ALWAYS_UPDATE, changeEvent, listenerList, NEVER_UPDATE, UPDATE_WHEN_ON_EDT
 
Fields inherited from class java.awt.Rectangle
height, width, x, y
 
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
 
Constructor Summary
DefaultViCaret()
           
 
Method Summary
protected  void adjustVisibility(Rectangle nloc)
           
protected  void damage(Rectangle r)
           
 ViCursor getCursor()
           
 JTextComponent getTextComponent()
           
 void mouseClicked(MouseEvent mouseEvent)
           
 void mouseDragged(MouseEvent mouseEvent)
           
 void mousePressed(MouseEvent mouseEvent)
           
 void mouseReleased(MouseEvent mouseEvent)
           
 void moveDot(int dot)
           
 void moveDot(int dot, Position.Bias dotBias)
           
 void paint(Graphics g)
          Render the caret as specified by the cursor.
 void setCursor(ViCursor cursor)
           
 void setDot(int dot)
          Tries to set the position of the caret from the coordinates of a mouse event, using viewToModel().
 void setDot(int dot, Position.Bias dotBias)
           
 
Methods inherited from class javax.swing.text.DefaultCaret
addChangeListener, deinstall, equals, fireStateChanged, focusGained, focusLost, getBlinkRate, getChangeListeners, getComponent, getDot, getListeners, getMagicCaretPosition, getMark, getSelectionPainter, getUpdatePolicy, install, isActive, isSelectionVisible, isVisible, mouseEntered, mouseExited, mouseMoved, moveCaret, positionCaret, removeChangeListener, repaint, setBlinkRate, setMagicCaretPosition, setSelectionVisible, setUpdatePolicy, setVisible, toString
 
Methods inherited from class java.awt.Rectangle
add, add, add, contains, contains, contains, contains, createIntersection, createUnion, getBounds, getBounds2D, getHeight, getLocation, getSize, getWidth, getX, getY, grow, inside, intersection, intersects, isEmpty, move, outcode, reshape, resize, setBounds, setBounds, setLocation, setLocation, setRect, setSize, setSize, translate, union
 
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, union
 
Methods inherited from class java.awt.geom.RectangularShape
clone, contains, contains, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.text.Caret
addChangeListener, deinstall, getBlinkRate, getDot, getMagicCaretPosition, getMark, install, isSelectionVisible, isVisible, removeChangeListener, setBlinkRate, setMagicCaretPosition, setSelectionVisible, setVisible
 
Methods inherited from interface java.awt.Shape
contains, contains, contains, contains, getPathIterator, getPathIterator, intersects, intersects
 

Constructor Detail

DefaultViCaret

public DefaultViCaret()
Method Detail

setCursor

public void setCursor(ViCursor cursor)
Specified by:
setCursor in interface ViCaret

getCursor

public ViCursor getCursor()
Specified by:
getCursor in interface ViCaret

damage

protected void damage(Rectangle r)
Overrides:
damage in class DefaultCaret

adjustVisibility

protected void adjustVisibility(Rectangle nloc)
Overrides:
adjustVisibility in class DefaultCaret

paint

public void paint(Graphics g)
Render the caret as specified by the cursor.
Note: might want to check editor manager, and if not vi then call super(paint), same for super(damage)

Specified by:
paint in interface Caret
Overrides:
paint in class DefaultCaret

getTextComponent

public JTextComponent getTextComponent()
Specified by:
getTextComponent in interface ViCaret

setDot

public void setDot(int dot)
Tries to set the position of the caret from the coordinates of a mouse event, using viewToModel(). Notifies vi that the most has been clicked in window and give vi a chance to adjust the position.

Specified by:
setDot in interface Caret
Overrides:
setDot in class DefaultCaret
Parameters:
e - the mouse event

setDot

public void setDot(int dot,
                   Position.Bias dotBias)

moveDot

public void moveDot(int dot)
Specified by:
moveDot in interface Caret
Overrides:
moveDot in class DefaultCaret

moveDot

public void moveDot(int dot,
                    Position.Bias dotBias)

mousePressed

public void mousePressed(MouseEvent mouseEvent)
Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class DefaultCaret

mouseReleased

public void mouseReleased(MouseEvent mouseEvent)
Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class DefaultCaret

mouseClicked

public void mouseClicked(MouseEvent mouseEvent)
Specified by:
mouseClicked in interface MouseListener
Overrides:
mouseClicked in class DefaultCaret

mouseDragged

public void mouseDragged(MouseEvent mouseEvent)
Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class DefaultCaret