jview
Class DragCursor

java.lang.Object
  extended by java.awt.Cursor
      extended by jview.CanvasCursor
          extended by jview.CrossCursor
              extended by jview.DragCursor
All Implemented Interfaces:
MouseListener, MouseMotionListener, Serializable, EventListener, MouseInputListener, Initializable, PropertyAware, PropertyComposed
Direct Known Subclasses:
JCameraCanvas.CameraCursor, SelectCursor, ZoomCursor

public abstract class DragCursor
extends CrossCursor

A cursor-like application that supplies a cross-hair above the entire drawable area of a JShapeCanvas. If persitant marking is enabled with the CrossCursor.KEY_PERSISTENT key, then clicking on the canvas adds a cross-hair on the location clicked to the shape canvas.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jview.CrossCursor
CrossCursor.Draw
 
Field Summary
private  String angle
          The angle string.
private  Point anglepos
          The position to draw the angle indicator.
private  String coorupleft
          The string at the starting point.
private static int DEFANGLESIZE
          The half size of the bounding rectangle of the angle arc.
private static boolean DEFSHOWANGLE
          The default angle marking.
private static boolean DEFSHOWDELTAX
          The default x-distance marking.
private static boolean DEFSHOWDELTAY
          The default y-distance marking.
private static boolean DEFSHOWDISTANCE
          The default total distance marking.
private static boolean DEFSHOWSTART
          The default start position marking.
private  String deltax
          The delta-x string.
private  Point deltaxcoor
          The position to draw the delta-x indicator.
private  String deltay
          The delta-y string.
private  Point deltaycoor
          The position to draw the delta-y indicator.
private  String distance
          The distance string.
private  Point distpos
          The position to draw the distance indicator.
static String KEY_ANGLESIZE
          The half size of the bounding rectangle of the angle arc.
static String KEY_SHOWANGLE
          If true, the angle is marked.
static String KEY_SHOWDELTAX
          If true, the distance in x is marked.
static String KEY_SHOWDELTAY
          If true, the distance in y is marked.
static String KEY_SHOWDISTANCE
          If true, the total distance is marked.
static String KEY_SHOWSTART
          If true, the starting point of the rectangle is marked.
private  Rectangle lastrec
          The last rectangle drawn.
private  Point upleft
          The starting point of a drag.
 
Fields inherited from class jview.CrossCursor
cursorcolor, KEY_ALLOWDRAG, KEY_PERSISTENT, KEY_SHOWCOORDINATE, KEY_SINGLEPERSIST, KEY_XSHIFT, KEY_YSHIFT, lastcenter, lastposition, xformat, yformat
 
Fields inherited from class jview.CanvasCursor
canvas, DEFCURSORCOLOR, KEY_COORDINATES, KEY_CURSORCOLOR, KEY_CURSORNAME, KEY_CURSORSIZE, NORMALIZED, NORMALIZEDACTION, SCREEN, SCREENACTION, USER, USERACTION
 
Fields inherited from class java.awt.Cursor
CROSSHAIR_CURSOR, CUSTOM_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, MOVE_CURSOR, N_RESIZE_CURSOR, name, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, predefined, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Constructor Summary
protected DragCursor(PropertySupplying prop)
          Constructs a new cross cursor from properties.
 
Method Summary
protected  void clearOnRepaint(Graphics2D g)
          Updates the canvas in its own thread.
private  void deleteOldDrag(Graphics onto)
          Deletes old drag strings etc.
protected abstract  void dragSelect(Rectangle screen, int modifiers)
          Calles after the mouse has been released after a drag with the rectangular screen-rectangle that has been drawn.
private  void drawAngle(Graphics onto, Rectangle drag)
          Draws an arc using the bottom-right position of the rectangle and the angle deferred from the rectangle shape.
private  void drawDiagonal(Graphics onto, Rectangle drag)
          Draws the diagonal of the dragging rectangle.
private  void drawRectangle(Graphics onto, Rectangle drag)
          Draws a dragging rectangle.
 void mouseDragged(MouseEvent me)
          If mouse dragging is enabled, we draw a rectangle instead of a cursor cross.
 void mouseEntered(MouseEvent me)
          When the mouse enters, we delete the old drag, if mous is not down
 void mousePressed(MouseEvent me)
          If mouse dragging is allowed, we record the starting point.
 void mouseReleased(MouseEvent me)
          We erease the active rectangle and everything else.
 void setComposedProperties(PropertySupplying info)
          Compose with a PropertySupplying as we need subclassing Cursor.
 
Methods inherited from class jview.CrossCursor
drawCross, drawPosition, getCoordinateLabel, getCoordinates, getCoordinatesPair, mouseExited, mouseMoved, setCoordinateFormat, setCoordinateLabel
 
Methods inherited from class jview.CanvasCursor
disableCanvas, enableCanvas, getActions, getComposedProperties, getCursorName, getCursorShape, getCustomized, getNormalizedAction, getScreenAction, getUserAction, init, isConsider, isMe, isWithin, repaintCanvas, setCursorName, setCursorShape
 
Methods inherited from class java.awt.Cursor
getDefaultCursor, getName, getPredefinedCursor, getSystemCustomCursor, getType, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.event.MouseListener
mouseClicked
 

Field Detail

KEY_SHOWSTART

public static final String KEY_SHOWSTART
If true, the starting point of the rectangle is marked.

See Also:
Constant Field Values

KEY_SHOWDELTAX

public static final String KEY_SHOWDELTAX
If true, the distance in x is marked.

See Also:
Constant Field Values

KEY_SHOWDELTAY

public static final String KEY_SHOWDELTAY
If true, the distance in y is marked.

See Also:
Constant Field Values

KEY_SHOWDISTANCE

public static final String KEY_SHOWDISTANCE
If true, the total distance is marked.

See Also:
Constant Field Values

KEY_SHOWANGLE

public static final String KEY_SHOWANGLE
If true, the angle is marked.

See Also:
Constant Field Values

KEY_ANGLESIZE

public static final String KEY_ANGLESIZE
The half size of the bounding rectangle of the angle arc.

See Also:
Constant Field Values

DEFSHOWSTART

private static final boolean DEFSHOWSTART
The default start position marking.

See Also:
Constant Field Values

DEFSHOWDELTAX

private static final boolean DEFSHOWDELTAX
The default x-distance marking.

See Also:
Constant Field Values

DEFSHOWDELTAY

private static final boolean DEFSHOWDELTAY
The default y-distance marking.

See Also:
Constant Field Values

DEFSHOWDISTANCE

private static final boolean DEFSHOWDISTANCE
The default total distance marking.

See Also:
Constant Field Values

DEFSHOWANGLE

private static final boolean DEFSHOWANGLE
The default angle marking.

See Also:
Constant Field Values

DEFANGLESIZE

private static final int DEFANGLESIZE
The half size of the bounding rectangle of the angle arc.

See Also:
Constant Field Values

upleft

private Point upleft
The starting point of a drag.


coorupleft

private String coorupleft
The string at the starting point.


lastrec

private Rectangle lastrec
The last rectangle drawn.


deltaxcoor

private Point deltaxcoor
The position to draw the delta-x indicator.


deltax

private String deltax
The delta-x string.


deltaycoor

private Point deltaycoor
The position to draw the delta-y indicator.


deltay

private String deltay
The delta-y string.


distpos

private Point distpos
The position to draw the distance indicator.


distance

private String distance
The distance string.


anglepos

private Point anglepos
The position to draw the angle indicator.


angle

private String angle
The angle string.

Constructor Detail

DragCursor

protected DragCursor(PropertySupplying prop)
Constructs a new cross cursor from properties. Needs to register the JShapeCanvas manually.

Method Detail

setComposedProperties

public void setComposedProperties(PropertySupplying info)
Compose with a PropertySupplying as we need subclassing Cursor.

Specified by:
setComposedProperties in interface PropertyAware
Overrides:
setComposedProperties in class CrossCursor

mousePressed

public void mousePressed(MouseEvent me)
If mouse dragging is allowed, we record the starting point.


mouseReleased

public void mouseReleased(MouseEvent me)
We erease the active rectangle and everything else.


mouseEntered

public void mouseEntered(MouseEvent me)
When the mouse enters, we delete the old drag, if mous is not down

Specified by:
mouseEntered in interface MouseListener
Overrides:
mouseEntered in class CrossCursor

mouseDragged

public void mouseDragged(MouseEvent me)
If mouse dragging is enabled, we draw a rectangle instead of a cursor cross.


dragSelect

protected abstract void dragSelect(Rectangle screen,
                                   int modifiers)
Calles after the mouse has been released after a drag with the rectangular screen-rectangle that has been drawn. For subclasses, if they want to grab the selected area. The drag cursor does not provide a body for that.

Parameters:
screen - The on-screen Rectangle of the drag, not normalized.
modifiers - The extended modifiers of the mouse event on drag end.

clearOnRepaint

protected void clearOnRepaint(Graphics2D g)
Updates the canvas in its own thread. Ereases any leftover from draws.

Overrides:
clearOnRepaint in class CrossCursor

drawRectangle

private void drawRectangle(Graphics onto,
                           Rectangle drag)
Draws a dragging rectangle. If this method is called, the active rectangle is always set.


drawDiagonal

private void drawDiagonal(Graphics onto,
                          Rectangle drag)
Draws the diagonal of the dragging rectangle. If this method is called, the active rectangle is always set.


drawAngle

private void drawAngle(Graphics onto,
                       Rectangle drag)
Draws an arc using the bottom-right position of the rectangle and the angle deferred from the rectangle shape. If this method is called, the active rectangle is always set.


deleteOldDrag

private void deleteOldDrag(Graphics onto)
Deletes old drag strings etc.