jview
Class CanvasCursor

java.lang.Object
  extended by java.awt.Cursor
      extended by jview.CanvasCursor
All Implemented Interfaces:
Serializable, Initializable, PropertyAware, PropertyComposed
Direct Known Subclasses:
CrossCursor

public abstract class CanvasCursor
extends Cursor
implements PropertyComposed, Initializable

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

See Also:
Serialized Form

Field Summary
protected  JNormalizedCanvas canvas
          The pointer to the underlying JShapeCanvas.
private  Shape cursorshape
          The shape from which the customized cursor is generated.
private  Cursor customized
          If we have a customized cursor.
private static int DEFCOORDINATES
          The default coordinates to display.
protected static Color DEFCURSORCOLOR
          The default cursor cross color.
private static Dimension DEFCURSORSIZE
          The default cursor position marking.
private  PropertySupplying info
          My composed properties.
static String KEY_COORDINATES
          The integer specifying display of screen, normalized or user coor.
static String KEY_CURSORCOLOR
          The color of the cursor cross.
static String KEY_CURSORNAME
          The name of this cursor, if customized.
static String KEY_CURSORSIZE
          The preferred pixel size of the cursor image, if customized.
static int NORMALIZED
          The integer for showing normalized coordinates.
static String NORMALIZEDACTION
          The label on the action for switching to normalized coor.
private  Action normalizedcor
          An action for switch to display of normalized corrdinates.
static int SCREEN
          The integer for showing screen coordinates.
static String SCREENACTION
          The label on the action for switching to screen coordinate display.
private  Action screencor
          An action for switch to display of screen corrdinates.
static int USER
          The integer for showing user coordinates.
static String USERACTION
          The label on the action for switching to user coordinate display.
private  Action usercor
          An action for switch to display of user coordinates.
 
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 CanvasCursor(PropertySupplying prop)
          Constructs a new cross cursor from properties.
 
Method Summary
protected  void clearOnRepaint(Graphics2D g2d)
          Clears leftovers before redrawing.
 void disableCanvas()
          Removes the canvas from this cursor.
 void enableCanvas(JNormalizedCanvas root)
          Assigns the JShapeCanvas to the cursor.
 Map<String,Action> getActions()
          Returns all actions.
 PropertySupplying getComposedProperties()
          Returns the PropertySupplyings this canvas refers to.
 String getCursorName()
          Returns the cursor name.
protected  Shape getCursorShape()
          If a shape is returned here, we create a custom cursor image out of that, hot point is center of shape.
 Cursor getCustomized()
          If we have a special non-default customized cursor.
 Action getNormalizedAction()
          Returns the action that switches to normalized coordinate display.
 Action getScreenAction()
          Returns the action that switches to screen coordinate display.
 Action getUserAction()
          Returns the action that switches to user coordinate display.
 void init()
          Initializes the zoom cursor.
protected  boolean isConsider(MouseEvent me)
          Checks if the mouse event is triggered by a left mouse click and if it occured within the active area.
protected  boolean isMe(MouseEvent me)
          Checks, if this mouse event applies to me, i.e.
protected  boolean isWithin(MouseEvent me)
          Checks if the mouse event is triggered by a left mouse click and if it occured within the component, which is normally bigger than the active area.
protected  void repaintCanvas()
          Updates the canvas in its own thread.
 void setComposedProperties(PropertySupplying prop)
          Compose with a PropertySupplying as we need subclassing Cursor.
protected  void setCursorName(String toname)
          Returns the cursor name.
protected  void setCursorShape(Shape cs)
          Sets a cursor shape for drawing.
 
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
 

Field Detail

USER

public static final int USER
The integer for showing user coordinates.

See Also:
Constant Field Values

NORMALIZED

public static final int NORMALIZED
The integer for showing normalized coordinates.

See Also:
Constant Field Values

SCREEN

public static final int SCREEN
The integer for showing screen coordinates.

See Also:
Constant Field Values

SCREENACTION

public static final String SCREENACTION
The label on the action for switching to screen coordinate display.

See Also:
Constant Field Values

NORMALIZEDACTION

public static final String NORMALIZEDACTION
The label on the action for switching to normalized coor. display.

See Also:
Constant Field Values

USERACTION

public static final String USERACTION
The label on the action for switching to user coordinate display.

See Also:
Constant Field Values

KEY_CURSORCOLOR

public static final String KEY_CURSORCOLOR
The color of the cursor cross.

See Also:
Constant Field Values

KEY_CURSORSIZE

public static final String KEY_CURSORSIZE
The preferred pixel size of the cursor image, if customized.

See Also:
Constant Field Values

KEY_CURSORNAME

public static final String KEY_CURSORNAME
The name of this cursor, if customized.

See Also:
Constant Field Values

KEY_COORDINATES

public static final String KEY_COORDINATES
The integer specifying display of screen, normalized or user coor.

See Also:
Constant Field Values

DEFCURSORCOLOR

protected static final Color DEFCURSORCOLOR
The default cursor cross color.


DEFCURSORSIZE

private static final Dimension DEFCURSORSIZE
The default cursor position marking.


DEFCOORDINATES

private static final int DEFCOORDINATES
The default coordinates to display.

See Also:
Constant Field Values

canvas

protected JNormalizedCanvas canvas
The pointer to the underlying JShapeCanvas.


info

private PropertySupplying info
My composed properties.


cursorshape

private Shape cursorshape
The shape from which the customized cursor is generated.


customized

private Cursor customized
If we have a customized cursor.


screencor

private Action screencor
An action for switch to display of screen corrdinates.


normalizedcor

private Action normalizedcor
An action for switch to display of normalized corrdinates.


usercor

private Action usercor
An action for switch to display of user coordinates.

Constructor Detail

CanvasCursor

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

Method Detail

init

public void init()
Initializes the zoom cursor. Here, the pop-up menu and the undo-zoom list is generated.

Specified by:
init in interface Initializable

setComposedProperties

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

Specified by:
setComposedProperties in interface PropertyAware

getCursorName

public String getCursorName()
Returns the cursor name.


setCursorName

protected void setCursorName(String toname)
Returns the cursor name.


getComposedProperties

public PropertySupplying getComposedProperties()
Returns the PropertySupplyings this canvas refers to.

Specified by:
getComposedProperties in interface PropertyComposed

getActions

public Map<String,Action> getActions()
Returns all actions. Some special, commonly used action may be retrieved also individually.

Returns:
A mapping of action names to concrete actions.

getScreenAction

public Action getScreenAction()
Returns the action that switches to screen coordinate display.


getNormalizedAction

public Action getNormalizedAction()
Returns the action that switches to normalized coordinate display.


getUserAction

public Action getUserAction()
Returns the action that switches to user coordinate display.


enableCanvas

public void enableCanvas(JNormalizedCanvas root)
Assigns the JShapeCanvas to the cursor. This method must always be called prior to activation of the cursor, i.e. adding it as a mouse listener. If the #getCursotShape method returns a non-null shape, we set a custom cursor on the parent component, otherwise a cross-cursor is used.


disableCanvas

public void disableCanvas()
Removes the canvas from this cursor. Re-activate by calling enableCanvas(jview.JNormalizedCanvas). Always call this method to stop receiving events from the canvas.


getCustomized

public Cursor getCustomized()
If we have a special non-default customized cursor. Only available after a call to enableCanvas(jview.JNormalizedCanvas), because the cursor shape depends on the component it is assigned to.


getCursorShape

protected Shape getCursorShape()
If a shape is returned here, we create a custom cursor image out of that, hot point is center of shape.


setCursorShape

protected void setCursorShape(Shape cs)
Sets a cursor shape for drawing. Call with null to disable customized cursor drawing.


isMe

protected boolean isMe(MouseEvent me)
Checks, if this mouse event applies to me, i.e. if the cursor of the mouse component is me or my custom cursor.


isWithin

protected boolean isWithin(MouseEvent me)
Checks if the mouse event is triggered by a left mouse click and if it occured within the component, which is normally bigger than the active area.


isConsider

protected boolean isConsider(MouseEvent me)
Checks if the mouse event is triggered by a left mouse click and if it occured within the active area.


clearOnRepaint

protected void clearOnRepaint(Graphics2D g2d)
Clears leftovers before redrawing. Canvas cursor only provides an empty method.


repaintCanvas

protected void repaintCanvas()
Updates the canvas in its own thread.