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 Link icon

  • Constructor Details Link icon

    • WandToolEventHandler Link icon

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

    • wandTypeProperty Link icon

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

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

      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 Link icon

      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 Link icon

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

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

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      protected void ensureCursorType(Cursor cursor)
      Ensure that the specified cursor is set in the current viewer.
      Parameters:
      cursor -
    • requestPixelSnapping Link icon

      protected boolean requestPixelSnapping()
      Returns true if the tool requests that pixel coordinates be snapped to integer values. Default returns true.
      Returns:
    • getViewer Link icon

      protected QuPathViewer getViewer()
    • mouseLocationToImage Link icon

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

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

      This might depend upon the MouseEvent.

      Parameters:
      e -
      Returns:
    • refineROIByParent Link icon

      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 Link icon

      protected Geometry refineGeometryByParent(Geometry geometry)
    • updatingConstrainingObjects Link icon

      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 Link icon

      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 Link icon

      protected PathObject getCurrentParent()
    • mouseClicked Link icon

      public void mouseClicked(MouseEvent e)
    • handle Link icon

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