org.openjump.core.ui.plugin.edittoolbox.cursortools
Class ConstrainedDragTool

java.lang.Object
  extended by com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
      extended by org.openjump.core.ui.plugin.edittoolbox.cursortools.ConstrainedDragTool
All Implemented Interfaces:
CursorTool, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener
Direct Known Subclasses:
ConstrainedMoveVertexTool

public abstract class ConstrainedDragTool
extends AbstractCursorTool

The default implementation draws a selection box, but this can be overridden (even to draw nothing).


Nested Class Summary
 
Nested classes/interfaces inherited from class com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
AbstractCursorTool.Listener
 
Field Summary
protected  java.util.List coordinates
           
static int DEFAULT_VIEW_CLICK_BUFFER
           
protected  com.vividsolutions.jts.geom.Coordinate modelDestination
          Modify using #setDestination
protected  com.vividsolutions.jts.geom.Coordinate modelSource
          Modify using #setSource
 
Constructor Summary
ConstrainedDragTool()
           
 
Method Summary
 void activate(LayerViewPanel layerViewPanel)
           
protected  com.vividsolutions.jts.geom.Coordinate doConstraint(java.awt.event.MouseEvent e)
           
protected  com.vividsolutions.jts.geom.Envelope getBoxInModelCoordinates()
           
 java.util.List getCoordinates()
           
protected  com.vividsolutions.jts.geom.Coordinate getModelDestination()
           
protected  com.vividsolutions.jts.geom.Coordinate getModelSource()
           
protected  java.awt.Shape getShape()
           
protected  java.awt.Shape getShape(java.awt.geom.Point2D source, java.awt.geom.Point2D destination)
           
protected  java.awt.geom.Point2D getViewDestination()
           
protected  java.awt.geom.Point2D getViewSource()
           
protected  double modelClickBuffer()
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
protected  void mouseLocationChanged(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          Begins handling of the drag.
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  void setModelSource(com.vividsolutions.jts.geom.Coordinate source)
           
protected  void setViewClickBuffer(int clickBuffer)
          A click is converted into a box by being expanded by this amount in the four directions.
protected  void setViewSource(java.awt.geom.Point2D source)
           
protected  boolean wasClick()
           
 
Methods inherited from class com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
add, allowSnapping, cancelGesture, check, cleanup, clearShape, createCursor, createCursor, createStandardSnappingPolicies, deactivate, drawShapeXOR, drawShapeXOR, execute, fireGestureFinished, gestureFinished, getColor, getCursor, getName, getPanel, getSnapManager, getTaskFrame, getWorkbench, isGestureInProgress, isRightMouseButtonUsed, isRollingBackInvalidEdits, isShapeOnScreen, mouseClicked, mouseEntered, mouseExited, mouseMoved, name, redrawShape, reportNothingToUndoYet, setColor, setFilling, setStroke, setStrokeWidth, setup, snap, snap, toString, wasControlPressed, wasShiftPressed, workbench, workbenchFrame
 
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
 

Field Detail

DEFAULT_VIEW_CLICK_BUFFER

public static final int DEFAULT_VIEW_CLICK_BUFFER
See Also:
Constant Field Values

modelSource

protected com.vividsolutions.jts.geom.Coordinate modelSource
Modify using #setSource


modelDestination

protected com.vividsolutions.jts.geom.Coordinate modelDestination
Modify using #setDestination


coordinates

protected java.util.List coordinates
Constructor Detail

ConstrainedDragTool

public ConstrainedDragTool()
Method Detail

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Begins handling of the drag. Subclasses can prevent handling of the drag by overriding this method and not calling it.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class AbstractCursorTool

setViewClickBuffer

protected void setViewClickBuffer(int clickBuffer)
A click is converted into a box by being expanded by this amount in the four directions.


wasClick

protected boolean wasClick()

getBoxInModelCoordinates

protected com.vividsolutions.jts.geom.Envelope getBoxInModelCoordinates()
                                                                 throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

modelClickBuffer

protected double modelClickBuffer()

mouseDragged

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

doConstraint

protected com.vividsolutions.jts.geom.Coordinate doConstraint(java.awt.event.MouseEvent e)
                                                       throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

getCoordinates

public java.util.List getCoordinates()

mouseLocationChanged

protected void mouseLocationChanged(java.awt.event.MouseEvent e)

getModelSource

protected com.vividsolutions.jts.geom.Coordinate getModelSource()

getModelDestination

protected com.vividsolutions.jts.geom.Coordinate getModelDestination()

setModelSource

protected void setModelSource(com.vividsolutions.jts.geom.Coordinate source)

setViewSource

protected void setViewSource(java.awt.geom.Point2D source)
                      throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

mouseReleased

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

getShape

protected java.awt.Shape getShape()
                           throws java.lang.Exception
Specified by:
getShape in class AbstractCursorTool
Returns:
null if nothing should be drawn
Throws:
java.lang.Exception

getViewSource

protected java.awt.geom.Point2D getViewSource()
                                       throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

getViewDestination

protected java.awt.geom.Point2D getViewDestination()
                                            throws java.awt.geom.NoninvertibleTransformException
Throws:
java.awt.geom.NoninvertibleTransformException

getShape

protected java.awt.Shape getShape(java.awt.geom.Point2D source,
                                  java.awt.geom.Point2D destination)
                           throws java.lang.Exception
Returns:
null if nothing should be drawn
Throws:
java.lang.Exception

activate

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