com.vividsolutions.jump.workbench.ui.cursortool
Class AbstractCursorTool

java.lang.Object
  extended bycom.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
All Implemented Interfaces:
CursorTool, java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
Direct Known Subclasses:
DragTool, MultiClickTool, SnapIndicatorTool

public abstract class AbstractCursorTool
extends java.lang.Object
implements CursorTool

A tool that draws an XOR visual indicator. Subclasses need not keep track of the XOR state of the indicator -- that logic is all handled by this class. Even if the LayerViewPanel is repainted while the XOR indicator is on-screen.


Nested Class Summary
static interface AbstractCursorTool.Listener
           
 
Constructor Summary
AbstractCursorTool()
           
 
Method Summary
 void activate(LayerViewPanel layerViewPanel)
           
 void add(AbstractCursorTool.Listener listener)
           
 void allowSnapping()
          Makes this CursorTool obey the snapping settings in the Options dialog.
 void cancelGesture()
          Notifies the CursorTool that a party is requesting that the gesture currently in progress be aborted.
protected  boolean check(EnableCheck check)
           
protected  void cleanup(java.awt.Graphics2D graphics)
           
protected  void clearShape()
           
static java.awt.Cursor createCursor(java.awt.Image image)
          The cursor will look best if the image is a 32 x 32 transparent GIF.
static java.awt.Cursor createCursor(java.awt.Image image, java.awt.Point hotSpot)
           
static java.util.List createStandardSnappingPolicies(Blackboard blackboard)
           
 void deactivate()
           
protected  void drawShapeXOR(java.awt.Graphics2D g)
           
protected  void drawShapeXOR(java.awt.Shape shape, java.awt.Graphics2D graphics)
           
protected  void execute(UndoableCommand command)
          Optional means of execution, with undoability.
protected  void fireGestureFinished()
           
protected abstract  void gestureFinished()
           
 java.awt.Color getColor()
           
 java.awt.Cursor getCursor()
           
 java.lang.String getName()
          Returns a very brief description of this CursorTool.
protected  LayerViewPanel getPanel()
           
protected abstract  java.awt.Shape getShape()
           
 SnapManager getSnapManager()
           
protected  TaskFrame getTaskFrame()
           
 JUMPWorkbench getWorkbench()
           
 boolean isGestureInProgress()
          Used by OrCompositeTool to determine whether a CursorTool is busy interacting with the user.
 boolean isRightMouseButtonUsed()
           
protected  boolean isRollingBackInvalidEdits()
           
 boolean isShapeOnScreen()
          Important for XOR drawing.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
static java.lang.String name(CursorTool tool)
           
protected  void redrawShape()
           
protected  void reportNothingToUndoYet()
          Notifies the UndoManager that this PlugIn did not modify any model states, and therefore the undo history should remain unchanged.
 void setColor(java.awt.Color color)
           
protected  void setFilling(boolean filling)
           
protected  void setStroke(java.awt.Stroke stroke)
           
protected  void setStrokeWidth(int strokeWidth)
          Deprecated. Use #setStroke instead.
protected  void setup(java.awt.Graphics2D graphics)
           
protected  com.vividsolutions.jts.geom.Coordinate snap(com.vividsolutions.jts.geom.Coordinate modelCoordinate)
           
protected  com.vividsolutions.jts.geom.Coordinate snap(java.awt.geom.Point2D viewPoint)
           
 java.lang.String toString()
           
protected  boolean wasControlPressed()
           
protected  boolean wasShiftPressed()
           
static JUMPWorkbench workbench(LayerViewPanel panel)
           
static WorkbenchFrame workbenchFrame(LayerViewPanel layerViewPanel)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.vividsolutions.jump.workbench.ui.cursortool.CursorTool
getIcon
 

Constructor Detail

AbstractCursorTool

public AbstractCursorTool()
Method Detail

allowSnapping

public void allowSnapping()
Makes this CursorTool obey the snapping settings in the Options dialog.


wasShiftPressed

protected boolean wasShiftPressed()

wasControlPressed

protected boolean wasControlPressed()

createCursor

public static java.awt.Cursor createCursor(java.awt.Image image)
The cursor will look best if the image is a 32 x 32 transparent GIF.


createCursor

public static java.awt.Cursor createCursor(java.awt.Image image,
                                           java.awt.Point hotSpot)

getCursor

public java.awt.Cursor getCursor()
Specified by:
getCursor in interface CursorTool

isGestureInProgress

public boolean isGestureInProgress()
Used by OrCompositeTool to determine whether a CursorTool is busy interacting with the user.

Specified by:
isGestureInProgress in interface CursorTool

isRightMouseButtonUsed

public boolean isRightMouseButtonUsed()
Specified by:
isRightMouseButtonUsed in interface CursorTool
Returns:
true if this CursorTool uses the right mouse button; false to allow the panel to show a popup-menu on right-clicks

isShapeOnScreen

public boolean isShapeOnScreen()
Important for XOR drawing. Even if #getShape returns null, this method will return true between calls of #redrawShape and #clearShape.


activate

public void activate(LayerViewPanel layerViewPanel)
Specified by:
activate in interface CursorTool

workbenchFrame

public static WorkbenchFrame workbenchFrame(LayerViewPanel layerViewPanel)

createStandardSnappingPolicies

public static java.util.List createStandardSnappingPolicies(Blackboard blackboard)

isRollingBackInvalidEdits

protected boolean isRollingBackInvalidEdits()

deactivate

public void deactivate()
Specified by:
deactivate in interface CursorTool

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

setColor

public void setColor(java.awt.Color color)

setFilling

protected void setFilling(boolean filling)

setStrokeWidth

protected void setStrokeWidth(int strokeWidth)
Deprecated. Use #setStroke instead.


setStroke

protected void setStroke(java.awt.Stroke stroke)

setup

protected void setup(java.awt.Graphics2D graphics)

getPanel

protected LayerViewPanel getPanel()

getShape

protected abstract java.awt.Shape getShape()
                                    throws java.lang.Exception
Returns:
null if nothing should be drawn
Throws:
java.lang.Exception

cleanup

protected void cleanup(java.awt.Graphics2D graphics)

clearShape

protected void clearShape()

cancelGesture

public void cancelGesture()
Description copied from interface: CursorTool
Notifies the CursorTool that a party is requesting that the gesture currently in progress be aborted.

Specified by:
cancelGesture in interface CursorTool

drawShapeXOR

protected void drawShapeXOR(java.awt.Graphics2D g)
                     throws java.lang.Exception
Throws:
java.lang.Exception

drawShapeXOR

protected void drawShapeXOR(java.awt.Shape shape,
                            java.awt.Graphics2D graphics)

redrawShape

protected void redrawShape()
                    throws java.lang.Exception
Throws:
java.lang.Exception

snap

protected com.vividsolutions.jts.geom.Coordinate snap(java.awt.geom.Point2D viewPoint)
                                               throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

snap

protected com.vividsolutions.jts.geom.Coordinate snap(com.vividsolutions.jts.geom.Coordinate modelCoordinate)

getTaskFrame

protected TaskFrame getTaskFrame()
Returns:
null if the LayerViewPanel is not inside a TaskFrame

getWorkbench

public JUMPWorkbench getWorkbench()

workbench

public static JUMPWorkbench workbench(LayerViewPanel panel)

gestureFinished

protected abstract void gestureFinished()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

fireGestureFinished

protected void fireGestureFinished()
                            throws java.lang.Exception
Throws:
java.lang.Exception

add

public void add(AbstractCursorTool.Listener listener)

execute

protected void execute(UndoableCommand command)
Optional means of execution, with undoability.


reportNothingToUndoYet

protected void reportNothingToUndoYet()
Notifies the UndoManager that this PlugIn did not modify any model states, and therefore the undo history should remain unchanged. Call this method inside #execute(PlugInContext).


toString

public java.lang.String toString()

getName

public java.lang.String getName()
Description copied from interface: CursorTool
Returns a very brief description of this CursorTool.

Specified by:
getName in interface CursorTool
Returns:
the name of this CursorTool

name

public static java.lang.String name(CursorTool tool)

check

protected boolean check(EnableCheck check)

getSnapManager

public SnapManager getSnapManager()

getColor

public java.awt.Color getColor()