Class HollowROI

java.lang.Object
com.xinapse.multisliceimage.roi.ROI
com.xinapse.multisliceimage.roi.HollowROI
All Implemented Interfaces:
EditableOutlineROI, RotatableROI, StretchableROI, Cloneable

public class HollowROI extends ROI implements Cloneable, StretchableROI, RotatableROI, EditableOutlineROI
A Class representing an irregularly-shaped region but with one or more holes.
  • Field Details

    • OUTERPOINTSTOKEN

      public static final String OUTERPOINTSTOKEN
      The token written to ROI output files to indicate that a list of outer points is to follow.
      See Also:
    • INNERPOINTSTOKEN

      public static final String INNERPOINTSTOKEN
      The token written to ROI output files to indicate that a list of inner points is to follow.
      See Also:
  • Constructor Details

    • HollowROI

      public HollowROI(List<ROI> rois, ROIState state) throws ROIException
      Creates a new HollowROI, created from a List of ROIs, where one ROI completely contains all the others. The ROIs may be Irregular, Rectangular, Elliptical or SplineROIs.
      Parameters:
      rois - the List of ROIs.
      state - the ROIState of the newly-created HollowROI.
      Throws:
      ROIException - if the HollowROI cannot be created.
  • Method Details

    • getOuterROI

      public ROI getOuterROI()
      Returns the ROI that encloses all the inner ROIs.
      Returns:
      the ROI that encloses all the inner ROIs.
    • getInnerROIs

      public List<ROI> getInnerROIs()
      Returns a list of ROIs that form the holes in this HollowROI.
      Returns:
      a list of ROIs that form the holes in this HollowROI.
    • 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.
    • move

      public void move(double dx, double dy, double stretchX, double stretchY)
      Description copied from interface: StretchableROI
      Moves and stretches an ROI. A stretch value is a scaling factor for dimensions in either the horizontal or vertical directions. A stretch of 1.0 means no stretch.
      Specified by:
      move in interface StretchableROI
      Parameters:
      dx - the distance (in mm) to move the centre of the StretchableROI in the horizontal direction.
      dy - the distance (in mm) to move the centre of the StretchableROI in the vertical direction.
      stretchX - the stretch in the horizontal direction.
      stretchY - the stretch in the vertical direction.
    • getCentre

      public Point2D getCentre()
      Description copied from interface: RotatableROI
      Gets the centre (about which rotation will occur) of this RotatableROI in mm.
      Specified by:
      getCentre in interface RotatableROI
      Returns:
      the centre of this ROI, about which rotation will occur.
    • setTheta

      public void setTheta(double theta)
      Description copied from interface: RotatableROI
      Sets the rotation angle for this RotatableROI.
      Specified by:
      setTheta in interface RotatableROI
      Parameters:
      theta - the rotation angle.
    • getTheta

      public double getTheta()
      Description copied from interface: RotatableROI
      Returns the current rotation angle for this RotatableROI.
      Specified by:
      getTheta in interface RotatableROI
      Returns:
      theta the current rotation angle.
    • contains

      public boolean contains(ROI roi)
      Description copied from class: ROI
      Indicates whether this ROI entirely contains another ROI entirely within its borders. If the supplied ROI just touches the border, then it is not contained within this ROI.
      Specified by:
      contains in class ROI
      Parameters:
      roi - the ROI to be tested for containment within this ROI.
      Returns:
      true if the supplied ROI is contained within this ROI; false otherwise.
    • intersect

      public List<ROI> intersect(ROI roi, IndeterminateProgressMonitor progressMonitor) throws ROIException, CancelledException
      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.
      Throws:
      ROIException - if the operation cannot be performed.
      CancelledException - if the operation is cancelled by the user.
    • moveVertex

      public void moveVertex(Point2D newPos, Handle handle, int nCols, int nRows, float pixelXSize, float pixelYSize, boolean pixelSnap) throws ROIException
      Description copied from interface: EditableOutlineROI
      Move a point on the outline of this EditableOutlineROI to a new position.
      Specified by:
      moveVertex in interface EditableOutlineROI
      Parameters:
      newPos - the new location of the vertex in real-space coordinates.
      handle - the Handle that the user has grabbed, used to identify the vertex to be moved.
      nCols - the number of image columns.
      nRows - the number of image rows.
      pixelXSize - the pixel width in mm.
      pixelYSize - the pixel height in mm.
      pixelSnap - whether pixel snap is turned on.
      Throws:
      ROIException - if the vertex cannot be moved to the requested position.
    • deleteVertex

      public boolean deleteVertex(Handle handle) throws ROIException
      Description copied from interface: EditableOutlineROI
      Delete a point on the outline of this EditableOutlineROI that is under a handle.
      Specified by:
      deleteVertex in interface EditableOutlineROI
      Parameters:
      handle - the Handle that the user has grabbed, used to identify the vertex to be deleted.
      Returns:
      true if a point is successfully deleted.
      Throws:
      ROIException - if the point cannot be deleted from this ROI.
    • insertTwoVertices

      public boolean insertTwoVertices(Handle handle)
      Description copied from interface: EditableOutlineROI
      Insert two points into the outline of this EditableOutlineROI: one just before the one that is under a handle, and one just after.
      Specified by:
      insertTwoVertices in interface EditableOutlineROI
      Parameters:
      handle - the Handle that the user has grabbed, used to identify the vertex around which the new vertices are to be placed.
      Returns:
      true if a point is successfully inserted.
    • getVertexHandles

      public Handle[] getVertexHandles()
      Description copied from interface: EditableOutlineROI
      Returns an array of VertexHandles.
      Specified by:
      getVertexHandles in interface EditableOutlineROI
      Returns:
      an array of VertexHandles, or null if this ROI is not having its outline edited.
    • getPrecedingVisibleHandle

      public Handle getPrecedingVisibleHandle(Handle handle)
      Description copied from interface: EditableOutlineROI
      Returns the visible Handle that is immediately before the specified handle, in the order in which they were placed around the ROI.
      Specified by:
      getPrecedingVisibleHandle in interface EditableOutlineROI
      Parameters:
      handle - the handle for which to get the preceding handle.
      Returns:
      the preceding visible Handle, or null if there is no preceding visible handle.
    • getFollowingVisibleHandle

      public Handle getFollowingVisibleHandle(Handle handle)
      Description copied from interface: EditableOutlineROI
      Returns the visible Handle that is immediately after the specified handle, in the order in which they were placed around the ROI.
      Specified by:
      getFollowingVisibleHandle in interface EditableOutlineROI
      Parameters:
      handle - the handle for which to get the following handle.
      Returns:
      the following visible Handle, or null if there is no following visible handle.
    • 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.
    • 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)
      Description copied from class: ROI
      Draws this ROI if it needs to be be drawn on screen.
      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).
    • 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.
    • setState

      public void setState(ROIState state)
      Description copied from class: ROI
      Sets the state of this ROI.
      Overrides:
      setState in class ROI
      Parameters:
      state - the ROIState of this ROI to be set. One of: ROIState.DELETED, ROIState.DELETED_SELECTED, ROIState.NORMAL, ROIState.SELECTED, ROIState.EDITABLE, ROIState.EDIT_OUTLINE.
    • setUserColour

      public void setUserColour(byte index)
      Description copied from class: ROI
      Sets the user-defined colour for this ROI.
      Overrides:
      setUserColour in class ROI
      Parameters:
      index - a value which is an index to the user-defined colour. A value of 0 indicates the a user-defined colour is to be unset; values greater than zero are the index into the user-defined colour palette of user-settable ROI colours.
    • 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 IrregularROI.
      Overrides:
      hashCode in class ROI
      Returns:
      a hash code value for this IrregularROI.
    • 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.
    • clone

      public HollowROI 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.
    • 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.