Class AbstractCursorTool
java.lang.Object
com.vividsolutions.jump.workbench.ui.cursortool.AbstractCursorTool
- All Implemented Interfaces:
CursorTool, MouseListener, MouseMotionListener, EventListener
- Direct Known Subclasses:
ConstrainedDragTool, ConstrainedMultiClickTool, DragTool, MultiClickTool, SnapIndicatorTool
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.
You can use a java.awt.Shape for a simple visual indicator such as a
Rectangle or Ellipse for example. For more complex indicators you can use a
java.awt.Image. Here you can build complex geometric stuff with filling,
transparency and so on. Real photos are possible too. For the use of an image
as a visual indicator you have to override the
getImage(),
getImagePosition() methods for generating the image to be draw.
Instead to call redrawShape(), you have to use the
redrawImage() method.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(LayerViewPanel new_panel) voidadd(AbstractCursorTool.Listener listener) voidMakes this CursorTool obey the snapping settings in the Options dialog.voidNotifies the CursorTool that a party is requesting that the gesture currently in progress be aborted.protected booleancheck(EnableCheck check) protected voidcleanup(Graphics2D graphics) protected voidClears an previously painted image from screen.protected voidstatic booleanutility method to be used by cursor tools to determine if the ui component with focus falls into it's purviewstatic CursorcreateCursor(Image image) The cursor will look best if the image is a 32 x 32 transparent GIF.static CursorcreateCursor(Image image, Point hotSpot) static CursorcreateCursor(Image image, Point hotSpot, String name) protected List<SnapPolicy> createStandardSnappingPolicies(Blackboard blackboard) voidprotected voidDraw the image in XOR mode at the specified position on screen.protected voiddrawImageXOR(Image image, Point position, Graphics2D graphics) Draw an image in XOR mode on screen.protected voidprotected voiddrawShapeXOR(Shape shape, Graphics2D graphics) protected voidexecute(UndoableCommand command) Optional means of execution, with undoability.protected voidexecute(UndoableCommand command, boolean ignoreNull) Optional means of execution, with undoability.protected voidprotected abstract voidgetColor()protected ImagegetImage()This method have to return an Image as a visual indicator.protected PointThis method have to return the position for the Image.getName()Returns a very brief description of this CursorTool.final LayerViewPanelgetPanel()static LayerViewPanelgetPanel(CursorTool ct) protected abstract ShapegetShape()protected Stroke**protected TaskFrameprotected WorkbenchContextbooleanUsed by OrCompositeTool to determine whether a CursorTool is busy interacting with the user.booleanprotected booleanbooleanImportant for XOR drawing.voidvoidvoidvoidvoidvoidvoidstatic Stringname(CursorTool tool) voidprotected voidRedraws the image on screen.protected voidprotected voidNotifies the UndoManager that this PlugIn did not modify any model states, and therefore the undo history should remain unchanged.voidprotected voidsetControlPressed(boolean onoff) protected voidsetFilling(boolean filling) protected voidsetPanel(LayerViewPanel panel) protected voidsetShiftPressed(boolean onoff) protected voidprotected voidsetup(Graphics2D graphics) protected org.locationtech.jts.geom.Coordinateprotected org.locationtech.jts.geom.Coordinatesnap(org.locationtech.jts.geom.Coordinate modelCoordinate) booleantoString()protected booleanprotected booleanMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface CursorTool
getIcon
-
Field Details
-
isLinuxOS
protected boolean isLinuxOS -
panel
-
-
Constructor Details
-
AbstractCursorTool
-
-
Method Details
-
getWorkbenchContext
-
allowSnapping
public void allowSnapping()Makes this CursorTool obey the snapping settings in the Options dialog. -
prohibitSnapping
public void prohibitSnapping() -
supportsSnapping
public boolean supportsSnapping() -
setShiftPressed
protected void setShiftPressed(boolean onoff) -
wasShiftPressed
protected boolean wasShiftPressed() -
setControlPressed
protected void setControlPressed(boolean onoff) -
wasControlPressed
protected boolean wasControlPressed() -
createCursor
-
createCursor
-
createCursor
-
getCursor
- Specified by:
getCursorin interfaceCursorTool
-
isGestureInProgress
public boolean isGestureInProgress()Used by OrCompositeTool to determine whether a CursorTool is busy interacting with the user.- Specified by:
isGestureInProgressin interfaceCursorTool
-
isRightMouseButtonUsed
public boolean isRightMouseButtonUsed()- Specified by:
isRightMouseButtonUsedin interfaceCursorTool- 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.- Returns:
- true if the cursor shape is on screen (even if not visible)
-
activate
- Specified by:
activatein interfaceCursorTool
-
createStandardSnappingPolicies
-
isRollingBackInvalidEdits
protected boolean isRollingBackInvalidEdits() -
deactivate
public void deactivate()- Specified by:
deactivatein interfaceCursorTool
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
setColor
-
setFilling
protected void setFilling(boolean filling) -
getStroke
** -
setStroke
-
setup
-
getShape
-
getImage
This method have to return an Image as a visual indicator. Usually this method should to be abstract. But if we do this here, many other derived classes have to implement this method. Thereby we would break the compatibility for many other classes in OJ and 3rd party plugins.- Returns:
- a Image or null if nothing should be drawn.
-
getImagePosition
This method have to return the position for the Image. The position is the top left corner of the image for the Graphics2D.drawImage() method. This method is called after thegetImage()method. For the abstract problematic please seegetImage().- Returns:
- the position for the Image
-
cleanup
-
clearShape
protected void clearShape() -
clearImage
protected void clearImage()Clears an previously painted image from screen. -
cancelGesture
public void cancelGesture()Description copied from interface:CursorToolNotifies the CursorTool that a party is requesting that the gesture currently in progress be aborted.- Specified by:
cancelGesturein interfaceCursorTool
-
drawShapeXOR
- Throws:
Exception
-
drawImageXOR
Draw the image in XOR mode at the specified position on screen. The position and the image is remembered for a later clear.- Parameters:
g- the graphics context
-
drawShapeXOR
-
drawImageXOR
Draw an image in XOR mode on screen.- Parameters:
image- the image to be drawposition- the positiongraphics- the Graphics2D
-
redrawShape
-
redrawImage
-
snap
protected org.locationtech.jts.geom.Coordinate snap(Point2D viewPoint) throws NoninvertibleTransformException - Throws:
NoninvertibleTransformException
-
snap
protected org.locationtech.jts.geom.Coordinate snap(org.locationtech.jts.geom.Coordinate modelCoordinate) -
getTaskFrame
- Returns:
- null if the LayerViewPanel is not inside a TaskFrame
-
getWorkbench
-
gestureFinished
-
fireGestureFinished
-
add
-
execute
Optional means of execution, with undoability.- Parameters:
command- undoable command to execute
-
execute
Optional means of execution, with undoability. Allows to ignore when command is null in case the calling code already warns user accordingly.- Parameters:
command-ignoreNull-
-
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
-
getName
Description copied from interface:CursorToolReturns a very brief description of this CursorTool.- Specified by:
getNamein interfaceCursorTool- Returns:
- the name of this CursorTool
-
getPanel
-
getPanel
-
setPanel
-
name
-
check
-
getSnapManager
-
getColor
-
componentWithFocusIsHandledByCursorTools
public static boolean componentWithFocusIsHandledByCursorTools()utility method to be used by cursor tools to determine if the ui component with focus falls into it's purview- Returns:
- boolean
-