Class WandToolEventHandler

All Implemented Interfaces:
EventListener, EventHandler<MouseEvent>

public class WandToolEventHandler extends BrushToolEventHandler
Wand tool, which acts rather like the brush - except that it expands regions (sometimes rather too eagerly?) based upon local pixel values.
Author:
Pete Bankhead
  • Property Details

  • Constructor Details

    • WandToolEventHandler

      public WandToolEventHandler(QuPathGUI qupath)
      Constructor.
      Parameters:
      qupath -
  • Method Details

    • wandTypeProperty

      public static ObjectProperty<WandToolEventHandler.WandType> wandTypeProperty()
      Property specifying whether the wand tool should be influenced by pixel values painted on image overlays.
      Returns:
    • wandUseOverlaysProperty

      public static BooleanProperty wandUseOverlaysProperty()
      Property specifying whether the wand tool should be influenced by pixel values painted on image overlays.
      Returns:
      See Also:
    • getWandUseOverlays

      public static boolean getWandUseOverlays()
      Query whether the wand tool should be influenced by pixel values painted on image overlays.

      If false, only RGB values of the underlying image will be used.

      Returns:
    • setWandUseOverlays

      public static void setWandUseOverlays(boolean useOverlays)
      Set whether the wand tool should be influenced by pixel values painted on image overlays. If false, only RGB values of the underlying image will be used.
      Parameters:
      useOverlays -
    • wandSigmaPixelsProperty

      public static DoubleProperty wandSigmaPixelsProperty()
      Property representing the Gaussian sigma value used to smooth the image when applying the wand.
      Returns:
      See Also:
    • getWandSigmaPixels

      public static double getWandSigmaPixels()
      Query the Gaussian sigma value used to smooth the image when applying the wand.
      Returns:
    • setWandSigmaPixels

      public static void setWandSigmaPixels(double sigma)
      Set the Gaussian sigma value used to smooth the image when applying the wand.
      Parameters:
      sigma -
    • wandSensitivityProperty

      public static DoubleProperty wandSensitivityProperty()
      Property representing the wand sensitivity value, which influences how similar local intensity values must be for the wand region growing.
      Returns:
      See Also:
    • getWandSensitivity

      public static double getWandSensitivity()
      Query the wand sensitivity value, which influences how similar local intensity values must be for the wand region growing.
      Returns:
    • setWandSensitivity

      public static void setWandSensitivity(double sensitivity)
      Set the wand sensitivity value, which influences how similar local intensity values must be for the wand region growing.
      Parameters:
      sensitivity -
    • createShape

      protected Geometry createShape(MouseEvent e, double x, double y, boolean useTiles, Geometry addToShape)
      Description copied from class: BrushToolEventHandler
      Create a new Geometry using the specified tool, assuming a user click/drag at the provided x & y coordinates.
      Overrides:
      createShape in class BrushToolEventHandler
      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:
    • getBrushDiameter

      protected double getBrushDiameter()
      Don't actually need the diameter for calculations here, but it's helpful for setting the cursor
      Overrides:
      getBrushDiameter in class BrushToolEventHandler
    • createNewAnnotation

      protected PathObject createNewAnnotation(MouseEvent e, double x, double y)
      Create a new annotation and set it in the current viewer.
      Parameters:
      e -
      x -
      y -
      Returns:
    • ensureCursorType

      protected void ensureCursorType(Cursor cursor)
      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

      protected QuPathViewer getViewer()
    • mouseLocationToImage

      protected Point2D mouseLocationToImage(MouseEvent e, boolean constrainToBounds, boolean snapToPixel)
    • requestParentClipping

      protected boolean requestParentClipping(MouseEvent e)
      Query whether parent clipping should be applied.

      This might depend upon the MouseEvent.

      Parameters:
      e -
      Returns:
    • refineROIByParent

      protected ROI refineROIByParent(ROI currentROI)
      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

      protected Geometry refineGeometryByParent(Geometry geometry)
    • 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 objects
      xx - x-coordinate in the image space of the starting point for the new object
      yy - y-coordinate in the image space of the starting point for the new object
      exclusions - 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

      protected PathObject getCurrentParent()
    • mouseClicked

      public void mouseClicked(MouseEvent e)
    • handle

      public void handle(MouseEvent event)
      Specified by:
      handle in interface EventHandler<MouseEvent>