Class MoveToolEventHandler
java.lang.Object
qupath.lib.gui.viewer.tools.handlers.MoveToolEventHandler
- All Implemented Interfaces:
EventListener
,EventHandler<MouseEvent>
The MoveTool is used for quite a lot of things, movement-related:
movement around an image (panning), moving ROIs (translating) and moving individual
'handles' of ROIs (resizing/reshaping)
- Author:
- Pete Bankhead
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Helper class for panning aQuPathViewer
(reasonably) smoothly. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
ensureCursorType
(Cursor cursor) Ensure that the specified cursor is set in the current viewer.protected PathObject
protected QuPathViewer
void
handle
(MouseEvent event) void
void
void
void
protected Point2D
mouseLocationToImage
(MouseEvent e, boolean constrainToBounds, boolean snapToPixel) void
void
void
protected Geometry
refineGeometryByParent
(Geometry geometry) protected ROI
refineROIByParent
(ROI currentROI) Apply clipping based on the current parent object.protected boolean
Query whether parent clipping should be applied.protected boolean
Returns true if the tool requests that pixel coordinates be snapped to integer values.protected void
Reset the constraining objects.protected void
updatingConstrainingObjects
(QuPathViewer viewer, double xx, double yy, Collection<PathObject> exclusions) New annotations can be constrained while they are being drawn, to avoid overlaps with existing annotations or to ensure they are drawn within a parent annotation.
-
Constructor Details
-
MoveToolEventHandler
public MoveToolEventHandler()
-
-
Method Details
-
mousePressed
-
mouseDragged
-
mouseReleased
-
mouseMoved
-
ensureCursorType
Ensure that the specified cursor is set in the current viewer.- Parameters:
cursor
-
-
requestPixelSnapping
protected boolean requestPixelSnapping()Returns true if the tool requests that pixel coordinates be snapped to integer values. Default returns true.- Returns:
-
getViewer
-
mouseLocationToImage
protected Point2D mouseLocationToImage(MouseEvent e, boolean constrainToBounds, boolean snapToPixel) -
requestParentClipping
Query whether parent clipping should be applied.This might depend upon the MouseEvent.
- Parameters:
e
-- Returns:
-
refineROIByParent
Apply clipping based on the current parent object.Returns an empty ROI if this result of the clipping is an empty area.
- Parameters:
currentROI
-- Returns:
-
refineGeometryByParent
-
updatingConstrainingObjects
protected void updatingConstrainingObjects(QuPathViewer viewer, double xx, double yy, Collection<PathObject> exclusions) New annotations can be constrained while they are being drawn, to avoid overlaps with existing annotations or to ensure they are drawn within a parent annotation.This method requests that the constraining objects are identified now based upon the specified mouse position. It is useful when starting to draw with a tool that makes use of constraining objects.
- Parameters:
viewer
- the viewer that may contain potential constraining objectsxx
- x-coordinate in the image space of the starting point for the new objectyy
- y-coordinate in the image space of the starting point for the new objectexclusions
- objects not to consider (e.g. the new ROI being created)
-
resetConstrainingObjects
protected void resetConstrainingObjects()Reset the constraining objects. These should be done as soon as they are no longer required, to prevent a memory leak by inadvertently holding on to an object hierarchy too long. -
getCurrentParent
-
mouseClicked
-
mouseEntered
-
mouseExited
-
handle
- Specified by:
handle
in interfaceEventHandler<MouseEvent>
-