com.xinapse.multisliceimage.roi
Class IrregularROI

java.lang.Object
  extended by com.xinapse.multisliceimage.roi.ROI
      extended by com.xinapse.multisliceimage.roi.IrregularROI
All Implemented Interfaces:
EditableOutlineROI, RotatableROI, StretchableROI, java.lang.Cloneable
Direct Known Subclasses:
ContourROI, CurvedLineROI

public class IrregularROI
extends ROI
implements java.lang.Cloneable, StretchableROI, RotatableROI, EditableOutlineROI

A Class representing an irregularly-shaped closed region on an image.


Field Summary
protected  int nPoints
           
static java.lang.String POINTSTOKEN
          The token written to ROI output files to indicate that a list of points is to follow.
protected  double[] xpts
           
protected  double[] ypts
           
 
Fields inherited from class com.xinapse.multisliceimage.roi.ROI
handles, PREFERENCES_NODE_NAME, XTOKEN, YTOKEN
 
Constructor Summary
IrregularROI(double[] x, double[] y, int n, ROIState state)
          Creates a new IrregularROI with the specified shape in mm coordinates.
IrregularROI(java.util.List<java.awt.geom.Point2D.Double> pointsList, int nCols, int nRows, float pixelXSize, float pixelYSize, byte userColour, ROIState state)
          Creates a new IrregularROI with the specified shape in image pixel coordinates.
IrregularROI(java.util.List<java.awt.geom.Point2D.Double> pointsList, ROIState state)
          Creates a new IrregularROI with the specified shape in mm coordinates.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this ROI.
 java.awt.geom.Line2D closestPoints(IrregularROI roi)
          Returns the line that represents the line that joins the two points that are closest together (in space) between this IrregularROI and another IrregularROI.
 boolean contains(ROI roi)
          Indicates whether this IrregularROI contains another ROI entirely within its borders.
 boolean deleteVertex(Handle handle)
          Delete a point on the outline of this CurvedLineROI that is under a handle.
 java.util.List<ROI> dilate(double radius, com.xinapse.util.Incrementer incrementer, com.xinapse.util.CancellableThread.Flag cancelFlag)
           
 boolean draw(java.awt.Graphics g, java.awt.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.
 boolean equals(java.lang.Object o)
          Indicates whether some Object is equal to this ROI.
 java.util.List<ROI> erasePoints(java.util.List<java.awt.geom.Point2D> erasePoints, float size, int nCols, int nRows, float pixelXSize, float pixelYSize)
          Erase points from this ROI.
 void flipHorizontal(java.awt.geom.Point2D flipPoint)
          Flip this ROI horizontally about a given location.
 void flipVertical(java.awt.geom.Point2D flipPoint)
          Flip this ROI vertically about a given location.
static javax.swing.Icon getButtonIcon()
          Returns an Icon that can be used to create this type of ROI.
 java.awt.geom.Point2D getCentre()
          Gets the centre (about which rotation will occur) of this RotatableROI in mm.
 ROI getCopy()
          Returns a copy of this ROI.
static InteractionType getCreateInteractionType()
          Returns the type of interaction needed to create an IrregularROI.
 java.lang.String getDescription()
          Return a description of this type of ROI.
 Feret getFeret()
          Returns the minimum and maximum Feret's diameter for this ROI, in mm.
 Handle getFollowingHandle(Handle handle)
          Returns the Handle that is immediately after the specified handle, in the order in which they were placed around the ROI.
static java.lang.String getName()
          Returns a descriptive name for this type of ROI.
 int getNPoints()
           
 double getPerimeter()
          Returns the perimeter length of this ROI.
 Handle getPrecedingHandle(Handle handle)
          Returns the Handle that is immediately before the specified handle, in the order in which they were placed around the ROI.
 double getTheta()
          Returns the current rotation angle for this RotatableROI.
 Handle[] getVertexHandles()
          Returns an array of VertexHandles.
 java.awt.geom.Point2D[] getVertices()
          Returns the vertex locations for this IrregularROI.
 int hashCode()
          Returns a hash code value for this IrregularROI.
 boolean insertTwoVertices(Handle handle)
          Insert two points into the outline of this CurvedLineROI: one just before the one that is under a handle, and one just after.
 IrregularROI join(IrregularROI roi)
          Joins this ROI to another IrregularROI with a waisted join - a join at the nearest point.
 void makeConvex(CanAddROIToFrame canAddROIToFrame, float pixelXSize, float pixelYSize, float minConcaveRadius)
          Make this Irregular ROI convex, or at least less concave.
 void move(double dx, double dy)
          Move this ROI by specified distances (in mm) in the x and y directions.
 void move(double dx, double dy, double stretchX, double stretchY)
          Moves and stretches an ROI.
 void moveVertex(java.awt.geom.Point2D newPos, Handle handle, int nCols, int nRows, float pixelXSize, float pixelYSize, boolean pixelSnap)
          Move a point on the outline of this IrregularROI to a new position.
 boolean selfIntersects()
          Returns true if this ROI has line segments that cross.
 void set(ROI roi)
          Sets the shape of this ROI to the shape of the supplied argument ROI.
 void setTheta(double theta)
          Sets the rotation angle for this RotatableROI.
 void setVertices(double[] x, double[] y)
          Sets the vertex positions for this ROI.
 void setVertices(double[] x, double[] y, int n)
          Sets the vertex positions for this ROI.
 void setVertices(java.util.List<java.awt.geom.Point2D.Double> vertices)
          Sets the vertex positions for this ROI.
 java.lang.String toString()
          Returns a String describing this ROI.
 
Methods inherited from class com.xinapse.multisliceimage.roi.ROI
add, add, clearDeletionHistory, clearStats, dilate, exclusiveOr, getAnnotation, getBoundingRectangle, getBoundingRectangle, getCachedStatistics, getClasses, getColor, getDisplayedBounds2D, getDisplayedBounds2D, getDisplayedRoiArea, getHandles, getHandleUnderPoint, getImageSource, getPixelValue, getROIs, getROIs, getSlice, getState, getStats, getStats, getStats, getTextColor, getTextFontSize, getUserColour, intersect, isDeleted, isEditable, isReloaded, isSelected, join, main, markDeleted, mmPosToPix, moveROIs, pixPosToMm, printStats, selectDeselect, setAnnotation, setCreationHistory, setSlice, setState, setTextColor, setTextSize, setUserColour, subtract, subtract, write, write
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.xinapse.multisliceimage.roi.StretchableROI
getDisplayedBounds2D
 

Field Detail

POINTSTOKEN

public static final java.lang.String POINTSTOKEN
The token written to ROI output files to indicate that a list of points is to follow.

See Also:
Constant Field Values

xpts

protected double[] xpts

ypts

protected double[] ypts

nPoints

protected int nPoints
Constructor Detail

IrregularROI

public IrregularROI(double[] x,
                    double[] y,
                    int n,
                    ROIState state)
             throws ROIException
Creates a new IrregularROI with the specified shape in mm coordinates.

Parameters:
x - an array of x-coordinates for the points forming the outline.
y - an array of y-coordinates for the points forming the outline.
n - the number points to be taken from the x and y arrays - must be less that or equal to then length of the smallest array.
state - the ROIState of the newly-created ROI.
Throws:
ROIException - if the ROI cannot be created as specified.

IrregularROI

public IrregularROI(java.util.List<java.awt.geom.Point2D.Double> pointsList,
                    ROIState state)
             throws ROIException
Creates a new IrregularROI with the specified shape in mm coordinates.

Parameters:
pointsList - a List of Point2D.Double points, in real-space (mm) coordinates, forming the outline.
state - the ROIState of the newly-created ROI.
Throws:
ROIException - if the ROI cannot be created as specified.

IrregularROI

public IrregularROI(java.util.List<java.awt.geom.Point2D.Double> pointsList,
                    int nCols,
                    int nRows,
                    float pixelXSize,
                    float pixelYSize,
                    byte userColour,
                    ROIState state)
             throws ROIException
Creates a new IrregularROI with the specified shape in image pixel coordinates.

Parameters:
pointsList - a java.util.List, in pixel coordinates, forming the outline.
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.
state - the ROIState of the newly-created ROI.
Throws:
ROIException - if the ROI cannot be created as specified.
Method Detail

getVertices

public java.awt.geom.Point2D[] getVertices()
Returns the vertex locations for this IrregularROI.

Returns:
the vertex locations as an array of Point2D.

getCreateInteractionType

public static InteractionType getCreateInteractionType()
Returns the type of interaction needed to create an IrregularROI.

Returns:
type of interaction needed to create an IrregularROI - InteractionType.CLICK_OUTLINE.

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.

flipVertical

public void flipVertical(java.awt.geom.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(java.awt.geom.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.

moveVertex

public void moveVertex(java.awt.geom.Point2D newPos,
                       Handle handle,
                       int nCols,
                       int nRows,
                       float pixelXSize,
                       float pixelYSize,
                       boolean pixelSnap)
Move a point on the outline of this IrregularROI to a new position.

Specified by:
moveVertex in interface EditableOutlineROI
Parameters:
newPos - the new location of the vertex in pixel 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.

deleteVertex

public boolean deleteVertex(Handle handle)
Description copied from interface: EditableOutlineROI
Delete a point on the outline of this CurvedLineROI 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.

insertTwoVertices

public boolean insertTwoVertices(Handle handle)
Description copied from interface: EditableOutlineROI
Insert two points into the outline of this CurvedLineROI: 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.

setVertices

public void setVertices(double[] x,
                        double[] y)
                 throws ROIException
Sets the vertex positions for this ROI.

Parameters:
x - a list of x-coordinates for the new vertex positions.
y - a list of y-coordinates for the new vertex positions.
Throws:
ROIException - if the vertices cannot be set as specified.

setVertices

public void setVertices(double[] x,
                        double[] y,
                        int n)
                 throws ROIException
Sets the vertex positions for this ROI.

Parameters:
x - an array of x-coordinates for the new vertex positions.
y - an array of y-coordinates for the new vertex positions.
n - the number of points to copy from the arrays, starting at index 0.
Throws:
ROIException - if the vertices cannot be set as specified.

setVertices

public void setVertices(java.util.List<java.awt.geom.Point2D.Double> vertices)
Sets the vertex positions for this ROI.

Parameters:
vertices - a java.util.List of new vertex positions.

getCentre

public java.awt.geom.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.

getNPoints

public int getNPoints()

erasePoints

public java.util.List<ROI> erasePoints(java.util.List<java.awt.geom.Point2D> erasePoints,
                                       float size,
                                       int nCols,
                                       int nRows,
                                       float pixelXSize,
                                       float pixelYSize)
Description copied from interface: EditableOutlineROI
Erase points from this ROI. erasePoints may edit this ROI by deleting points, or it may split this ROI into two or more new ROIs. If more than one ROI is returned, then the (edited) original ROI will be in the list of returned ROIs, and will be the remaining ROI which is biggest (has the most points).

Specified by:
erasePoints in interface EditableOutlineROI
Parameters:
erasePoints - a List of points through which the erasing pen has passed.
size - the size of the erasing pen in mm.
nCols - the number of image columns.
nRows - the number of image rows.
pixelXSize - the pixel width in mm.
pixelYSize - the pixel height in mm.
Returns:
a List of ROIs resulting from the points erasure.

join

public IrregularROI join(IrregularROI roi)
                  throws ROIException
Joins this ROI to another IrregularROI with a waisted join - a join at the nearest point. If the two ROIs overlap, then the resulting ROI is just the union of the two ROIs.

Parameters:
roi - the roi to which this is to be joined.
Returns:
the original ROI joined to the ROI supplied as an argument.
Throws:
ROIException - if the two ROIs cannot be joined.

closestPoints

public java.awt.geom.Line2D closestPoints(IrregularROI roi)
Returns the line that represents the line that joins the two points that are closest together (in space) between this IrregularROI and another IrregularROI.

Parameters:
roi - the IrregularROI against which this IrregularROI will be tested.
Returns:
a Line2D representing the line that joins the two closest points. The first end of the line will be on this IrregularROI, and the second will be on the supplied argument IrregularROI.

makeConvex

public void makeConvex(CanAddROIToFrame canAddROIToFrame,
                       float pixelXSize,
                       float pixelYSize,
                       float minConcaveRadius)
Description copied from interface: EditableOutlineROI
Make this Irregular ROI convex, or at least less concave. The supplied pixel sizes are used to decide on the separation between data points around the ROI. A minimum radius of curvature for concave radii of curvature is given. The action of making the ROI convex will be executed asynchronously using a javax.swing.SwingWorker that will update the ImageDisplayer when finished.

Specified by:
makeConvex in interface EditableOutlineROI
Parameters:
canAddROIToFrame - the CanAddROIToFrame to be updated when the operation is complete.
pixelXSize - the width of an image pixel in mm.
pixelYSize - the height of an image pixel in mm.
minConcaveRadius - the minimum radius of curvature for concave parts of this ROI.

dilate

public java.util.List<ROI> dilate(double radius,
                                  com.xinapse.util.Incrementer incrementer,
                                  com.xinapse.util.CancellableThread.Flag cancelFlag)
                           throws com.xinapse.util.CancelledException
Throws:
com.xinapse.util.CancelledException

draw

public boolean draw(java.awt.Graphics g,
                    java.awt.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.

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.

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 ouline edited.

getPrecedingHandle

public Handle getPrecedingHandle(Handle handle)
Description copied from interface: EditableOutlineROI
Returns the Handle that is immediately before the specified handle, in the order in which they were placed around the ROI.

Specified by:
getPrecedingHandle in interface EditableOutlineROI
Parameters:
handle - the handle for which to get the preceding handle.
Returns:
the preceding Handle, or null if there is no preceding handle.

getFollowingHandle

public Handle getFollowingHandle(Handle handle)
Description copied from interface: EditableOutlineROI
Returns the Handle that is immediately after the specified handle, in the order in which they were placed around the ROI.

Specified by:
getFollowingHandle in interface EditableOutlineROI
Parameters:
handle - the handle for which to get the following handle.
Returns:
the following Handle, or null if there is no following handle.

selfIntersects

public boolean selfIntersects()
Returns true if this ROI has line segments that cross.

Returns:
true if this ROI has line segments that cross; false otherwise.

contains

public boolean contains(ROI roi)
Indicates whether this IrregularROI contains another ROI entirely within its borders.

Specified by:
contains in class ROI
Parameters:
roi - the ROI to be tested for containment within this ROI.
Returns:
true if this IrregularROI contains the specified ROI; false otherwise.

equals

public boolean equals(java.lang.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 java.lang.Object
Returns:
a hash code value for this IrregularROI.

set

public void set(ROI roi)
         throws java.lang.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
Throws:
java.lang.ClassCastException - of 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, cast to an Object.

clone

public java.lang.Object 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 java.lang.String toString()
Description copied from class: ROI
Returns a String describing this ROI.

Specified by:
toString in class ROI
Returns:
a java.lang.String describing this ROI.

getDescription

public java.lang.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 java.lang.String getName()
Returns a descriptive name for this type of ROI.

Returns:
a String describing this type of ROI.

getButtonIcon

public static javax.swing.Icon getButtonIcon()
Returns an Icon that can be used to create this type of ROI.

Returns:
an Icon that can be used to represent this type of ROI.


Copyright 2006-2008 Xinapse Systems Limited. All Rights Reserved.