Class BrushToolEventHandler
java.lang.Object
qupath.lib.gui.viewer.tools.handlers.BrushToolEventHandler
- All Implemented Interfaces:
EventListener
,EventHandler<MouseEvent>
- Direct Known Subclasses:
WandToolEventHandler
Tool for drawing (and subtract from) freehand regions, optionally adapting brush size to magnification.
- Author:
- Pete Bankhead
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected PathObject
createNewAnnotation
(MouseEvent e, double x, double y) Create a new annotation and set it in the current viewer.protected ROI
createNewROI
(MouseEvent e, double x, double y, ImagePlane plane) Create a new ROI with the given starting coordinates.protected Geometry
createShape
(MouseEvent e, double x, double y, boolean useTiles, Geometry addToShape) Create a new Geometry using the specified tool, assuming a user click/drag at the provided x & y coordinates.protected void
ensureCursorType
(Cursor cursor) Ensure that the specified cursor is set in the current viewer.protected double
protected PathObject
protected GeometryFactory
protected Cursor
protected QuPathViewer
void
handle
(MouseEvent event) protected boolean
void
void
void
void
protected Point2D
mouseLocationToImage
(MouseEvent e, boolean constrainToBounds, boolean snapToPixel) void
void
void
protected boolean
Returns false.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
-
BrushToolEventHandler
public BrushToolEventHandler()
-
-
Method Details
-
preferReturnToMove
protected boolean preferReturnToMove()Returns false.- Returns:
-
getRequestedCursor
-
mouseExited
-
mouseEntered
-
mouseMoved
-
mousePressed
-
mouseDragged
-
isSubtractMode
-
mouseReleased
-
getBrushDiameter
protected double getBrushDiameter() -
createShape
protected Geometry createShape(MouseEvent e, double x, double y, boolean useTiles, Geometry addToShape) Create a new Geometry using the specified tool, assuming a user click/drag at the provided x & y coordinates.- Parameters:
e
-x
-y
-useTiles
- If true, request generating a shape from existing tile objects.addToShape
- If provided, it can be assumed that any new shape ought to be added to this one. The purpose is that this method may (optionally) use the shape to refine the one it will generate, e.g. to avoid having isolated or jagged boundaries.- Returns:
-
getGeometryFactory
-
createNewROI
Create a new ROI with the given starting coordinates.- Parameters:
e
-x
-y
-plane
-- Returns:
-
createNewAnnotation
Create a new annotation and set it in the current viewer.- Parameters:
e
-x
-y
-- Returns:
-
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
-
handle
- Specified by:
handle
in interfaceEventHandler<MouseEvent>
-