Class Marker

java.lang.Object
com.xinapse.multisliceimage.roi.ROI
com.xinapse.multisliceimage.roi.Marker
All Implemented Interfaces:
RegularROI, Cloneable
Direct Known Subclasses:
Text

public class Marker extends ROI implements Cloneable, RegularROI
A Class representing a point on an image.
  • Constructor Details

    • Marker

      public Marker(Point2D.Double pt)
      Creates a new Marker at the given point.
      Parameters:
      pt - the location of the marker.
    • Marker

      public Marker(double x, double y)
      Creates a new Marker at the given (x, y) coordinate.
      Parameters:
      x - the x location of the marker.
      y - the y location of the marker.
    • Marker

      public Marker(double x, double y, ROIState state)
      Creates a new Marker at the given (x, y) coordinate, and sets the state of the ROI.
      Parameters:
      x - the x location of the marker.
      y - the y location of the marker.
      state - the ROIState of the Marker.
  • Method Details

    • getX

      public double getX()
      Returns the x-coordinate of this Marker.
      Returns:
      the x-coordinate of this Marker.
    • getY

      public double getY()
      Returns the y-coordinate of this Marker.
      Returns:
      the y-coordinate of this Marker.
    • getSquareArea

      public double getSquareArea()
      Description copied from interface: RegularROI
      Returns the area of this regular ROI in square mm.
      Specified by:
      getSquareArea in interface RegularROI
      Returns:
      the area of this Marker, which is always zero.
    • getCreateInteractionType

      public static InteractionType getCreateInteractionType()
      Returns the type of interaction needed to create a Marker.
      Returns:
      type of interaction needed to create a Marker - InteractionType.CLICK.
    • move

      public void move(double dx, double dy)
      Description copied from class: ROI
      Move this ROI by specified distances (in mm) in the x and y directions.
      Specified by:
      move in class ROI
      Parameters:
      dx - the distance to move in the x-direction.
      dy - the distance to move in the y-direction.
    • flipVertical

      public void flipVertical(Point2D flipPoint)
      Description copied from class: ROI
      Flip this ROI vertically about a given location.
      Specified by:
      flipVertical in class ROI
      Parameters:
      flipPoint - the point about which the ROI will be flipped.
    • flipHorizontal

      public void flipHorizontal(Point2D flipPoint)
      Description copied from class: ROI
      Flip this ROI horizontally about a given location.
      Specified by:
      flipHorizontal in class ROI
      Parameters:
      flipPoint - the point about which the ROI will be flipped.
    • getInstance

      public static ROI getInstance(Point2D point, boolean pixelSnap, int nCols, int nRows, float pixelXSize, float pixelYSize, byte userColour, ROIState state)
      Create a Marker at a point on an image.
      Parameters:
      point - the point on the image in pixel coordinates.
      pixelSnap - true if pixel snap is turned on.
      nCols - the number of columns in the image.
      nRows - the number of rows in the image.
      pixelXSize - the width of an image pixel in mm.
      pixelYSize - the height of an image pixel in mm.
      userColour - the colour of this ROI. A value of 0 indicates that the ROI will be drawn with the default colour for normal ROIs if unselected.
      state - the ROIState of this ROI on creation.
      Returns:
      a new Marker ROI.
    • union

      public List<ROI> union(ROI roi, IndeterminateProgressMonitor progressMonitor)
      Description copied from class: ROI
      Logically add (forms the union) an ROI to this ROI to create a new java.util.List<ROI> of ROIs that is the result of adding the shapes of the two ROIs.
      Overrides:
      union in class ROI
      Parameters:
      roi - the ROI to add.
      progressMonitor - if non-null, the IndeterminateProgressMonitor that can be used to cancel the operation.
      Returns:
      a List<ROI> of ROIs that results from the addition of the shape.
    • andNot

      public List<ROI> andNot(ROI roi, IndeterminateProgressMonitor progressMonitor)
      Description copied from class: ROI
      Logically AND NOTs (subtracts) an ROI from this ROI to create a new java.util.List<ROI> of ROIs that is the result of subtracting the shape of the supplied ROI from this ROI.
      Overrides:
      andNot in class ROI
      Parameters:
      roi - the ROI to subtract.
      progressMonitor - if non-null, the IndeterminateProgressMonitor that can be used to cancel the operation.
      Returns:
      a List<ROI> of ROIs that results from the subtraction of the ROI.
    • intersect

      public List<ROI> intersect(ROI roi, IndeterminateProgressMonitor progressMonitor)
      Description copied from class: ROI
      Performs an intersection operation on the shape of this ROI with another ROI.
      Overrides:
      intersect in class ROI
      Parameters:
      roi - the ROI with which to perform the intersection operation.
      progressMonitor - if non-null, the IndeterminateProgressMonitor that can be used to cancel the operation.
      Returns:
      a List<ROI> of ROIs that result from the operation.
    • exclusiveOr

      public List<ROI> exclusiveOr(ROI roi, IndeterminateProgressMonitor progressMonitor)
      Description copied from class: ROI
      Performs an exclusive OR operation on the shape of this ROI with another ROI.
      Overrides:
      exclusiveOr in class ROI
      Parameters:
      roi - the ROI with which to perform the XOR operation.
      progressMonitor - if non-null, the IndeterminateProgressMonitor that can be used to cancel the operation.
      Returns:
      a List<ROI> of ROIs that result from the operation.
    • draw

      public boolean draw(Graphics g, Rectangle visibleRectangle, int imageDrawCols, int imageDrawRows, int xOffset, int yOffset, int nCols, int nRows, float pixelXSize, float pixelYSize, boolean drawAnnotation)
      Draws this ROI if it needs to be be drawn on screen. Marker ROIs are a special case, since we can't use the Bounding Rectangle to decide whether a Marker is on screen, since the zero-area bounding rectangle never intersects anything.
      Overrides:
      draw in class ROI
      Parameters:
      g - the graphics context for the drawing operation.
      visibleRectangle - the part of the image that can be seen on-screen.
      imageDrawCols - width of the area in which this portion of the image is to be drawn.
      imageDrawRows - height of the area in which this portion of the image is to be drawn.
      xOffset - a horizontal offset for drawing operations.
      yOffset - a vertical offset for drawing operations.
      nCols - the number of columns in the image on which this ROI is defined.
      nRows - the number of rows in the image on which this ROI is defined.
      pixelXSize - pixel width for the image on which this ROI is defined.
      pixelYSize - pixel height for the image on which this ROI is defined.
      drawAnnotation - a flag to indicate whether annotation should be drawn.
      Returns:
      true if the ROI is visible and been drawn on screen; false otherwise.
    • drawInOrthoView

      public void drawInOrthoView(Image orthoView, org.jogamp.vecmath.Point3f orthoViewPosition, org.jogamp.java3d.Transform3D imageToViewTx, int nCols, int nRows, int nSlices, float pixelXSize, float pixelYSize, boolean filled)
      Description copied from class: ROI
      Draws this ROI on top of an orthogonal view of an image.
      Specified by:
      drawInOrthoView in class ROI
      Parameters:
      orthoView - the Image into which the ROI is to be drawn.
      orthoViewPosition - the coordinates (col, row, slice position) of the orthogonal view in the original image.
      imageToViewTx - the Transform3D that maps original image pixel coordinates to pixel coordinates in the orthogonal view.
      nCols - the number of columns in the original image.
      nRows - the number of rows in the original image.
      nSlices - the number of slices in the original image.
      pixelXSize - the pixel width in the original image.
      pixelYSize - the pixel height in the original image.
      filled - whether the ROI should be drawn filled (effective only for ROIs that enclose an area).
    • getBoundingRectangle

      public Rectangle2D getBoundingRectangle(int nCols, int nRows, float pixelXSize, float pixelYSize)
      Description copied from class: ROI
      Returns a high-precision rectangle (in image pixel coordinates) that just bounds this ROI.
      Overrides:
      getBoundingRectangle in class ROI
      Parameters:
      nCols - the number of columns in the image on which this ROI is defined.
      nRows - the number of rows in the image on which this ROI is defined.
      pixelXSize - pixel width for the image on which this ROI is defined.
      pixelYSize - pixel height for the image on which this ROI is defined.
      Returns:
      a Rectangle2D that just bounds this ROI.
    • getStats

      public ROIStats getStats(Object pix, PixelDataType dataType, int nCols, int nRows, int offset, float pixelXSize, float pixelYSize, MaskAction maskAction, MaskMode maskMode, double maskValue, PrintStream intensityOutputStream, boolean isUnitsMM, ComplexMode complexMode)
      Description copied from class: ROI
      Returns statistics about this ROI, and (optionally) performs a masking operation.
      Overrides:
      getStats in class ROI
      Parameters:
      pix - the whole image pixel value array. If pix is null, then the intensity-related stats will all be set to zero.
      dataType - the type of pixels.
      nCols - the number of columns in the slice.
      nRows - the number of rows in the slice.
      offset - an offset (in pixels) into the pixel value array for the starting pixel of the slice on which this ROI is defined.
      pixelXSize - the size of image pixels in the horizontal direction.
      pixelYSize - the size of image pixels in the vertical direction.
      maskAction - one of:
      maskMode - how much of a pixel must be inside ROIs for the pixel to be part of the mask.
      maskValue - the pixel value to set outside/inside the shape when performing masking ops.
      intensityOutputStream - if non-null, pixel intensities within the ROI will be printed to this PrintStream.
      isUnitsMM - true if the (x,y) coordinates of the pixel intensities are to be written in mm, false if the coordinates are to be writtn in pixel units.
      complexMode - the calculation mode for PixelDataType.COMPLEX images. The statistics returned will correspond to the mode: the real part, imaginary part, magnitude or phase.
      Returns:
      statistics about the ROI.
    • getFeret

      public Feret getFeret()
      Description copied from class: ROI
      Returns the minimum and maximum Feret's diameter for this ROI, in mm.
      Specified by:
      getFeret in class ROI
      Returns:
      the minimum and maximum Feret's diameter (in mm) as a Feret object.
    • getPerimeter

      public double getPerimeter()
      Description copied from class: ROI
      Returns the perimeter length of this ROI.
      Specified by:
      getPerimeter in class ROI
      Returns:
      the perimeter length of this ROI.
    • getCentroid

      public org.jogamp.vecmath.Point2d getCentroid()
      Description copied from class: ROI
      Returns the centroid (centre of area) of this ROI.
      Specified by:
      getCentroid in class ROI
      Returns:
      the centroid of this ROI.
    • selectDeselect

      public boolean selectDeselect(Point point, boolean editMode, boolean showDeleted, int nAlreadySelected)
      Description copied from class: ROI
      Selects or deselects an ROI after a user click at the point.
      Overrides:
      selectDeselect in class ROI
      Parameters:
      point - the Point at which the user has clicked.
      editMode - true if the tool working with ROIs is in edit mode; false if it is in view mode.
      showDeleted - true if the tool working with ROIs is set to show deleted ROIs; false if it is not.
      nAlreadySelected - the number of ROIs already selected. This determines the exact selection/deselection behaviour.
      Returns:
      true if the selection was changed.
    • getCreateDialog

      public static ROICreateDialog getCreateDialog(CanAddROIToFrame listener)
      Returns a JDialog that can be used to create Marker ROIs.
      Parameters:
      listener - the CanAddROIToFrame to which the ROI will be added when the Add button of the Dialog is clicked.
      Returns:
      a JDialog that can be used to create Marker ROIs.
    • contains

      public boolean contains(ROI roi)
      Indicates whether this Marker ROI contains another ROI entirely within its borders. A Marker ROI never contains another ROI, since it has zero area.
      Specified by:
      contains in class ROI
      Parameters:
      roi - the ROI to be tested for containment within this ROI.
      Returns:
      false always.
    • equals

      public boolean equals(Object o)
      Description copied from class: ROI
      Indicates whether some Object is equal to this ROI. To be equal, the Object must be an ROI of the same type, and of the same shape and location as this ROI.
      Specified by:
      equals in class ROI
      Parameters:
      o - the Object to be tested for equality to this ROI.
      Returns:
      true if the supplied Object is an ROI of the same type, shape and location as this ROI; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this Marker ROI.
      Overrides:
      hashCode in class ROI
      Returns:
      a hash code value for this Marker ROI.
    • set

      public void set(double x, double y)
      Sets the location of this Marker to the given location.
      Parameters:
      x - the x-location.
      y - the y-location.
    • set

      public void set(ROI roi) throws ClassCastException
      Description copied from class: ROI
      Sets the shape of this ROI to the shape of the supplied argument ROI.
      Specified by:
      set in class ROI
      Parameters:
      roi - the ROI from which the shape is set.
      Throws:
      ClassCastException - if the sub-class of the argument ROI is not the same as this ROI.
    • getCopy

      public ROI getCopy()
      Description copied from class: ROI
      Returns a copy of this ROI. The copy will be identical in shape and annotation as the original ROI, but with a history of that of a newly-created ROI.
      Specified by:
      getCopy in class ROI
      Returns:
      a copy of this ROI.
    • toString

      public String toString()
      Description copied from class: ROI
      Returns a String describing this ROI.
      Specified by:
      toString in class ROI
      Returns:
      a String describing this ROI.
    • getDescription

      public String getDescription()
      Description copied from class: ROI
      Return a description of this type of ROI.
      Specified by:
      getDescription in class ROI
      Returns:
      a String describing the type of this ROI.
    • getName

      public static String getName()
      Returns a descriptive name for this type of ROI.
      Returns:
      a String describing this type of ROI.
    • getButtonIcon

      public static Icon getButtonIcon()
      Returns an Icon that can be used for a button to create this type of ROI.
      Returns:
      an Icon that can be used to represent this type of ROI.
    • clone

      public Marker clone()
      Description copied from class: ROI
      Returns a clone of this ROI. The copy will be identical in shape and annotation as the original ROI, and with a history identical to the cloned ROI.
      Overrides:
      clone in class ROI
      Returns:
      a clone of this ROI, cast to an Object.