com.xinapse.multisliceimage.roi
Class EllipticalROI

java.lang.Object
  extended by com.xinapse.multisliceimage.roi.ROI
      extended by com.xinapse.multisliceimage.roi.EllipticalROI
All Implemented Interfaces:
RegularROI, RotatableROI, java.lang.Cloneable

public class EllipticalROI
extends ROI
implements java.lang.Cloneable, RotatableROI, RegularROI

A Class representing an elliptical region of an image.


Field Summary
static java.lang.String ATOKEN
          The token written to ROI output files to represent the first semi-major axis length.
static java.lang.String BTOKEN
          The token written to ROI output files to represent the second semi-major axis length.
static java.lang.String THETATOKEN
          The token written to ROI output files to represent the rotation angle.
 
Fields inherited from class com.xinapse.multisliceimage.roi.ROI
handles, PREFERENCES_NODE_NAME, XTOKEN, YTOKEN
 
Constructor Summary
EllipticalROI(double centreX, double centreY, double a, double b, double theta, byte userColour, ROIState state)
          Creates a new EllipticalROI with the specified shape in mm coordinates.
EllipticalROI(double centreX, double centreY, double a, double b, double theta, ROIState state)
          Creates a new EllipticalROI with the specified shape in mm coordinates.
EllipticalROI(java.awt.geom.Point2D.Double centre, double a, double b, double theta)
          Creates a new EllipticalROI with the specified shape in mm coordinates.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this ROI.
 boolean contains(ROI roi)
          Indicates whether this EllipticalROI contains another ROI entirely within its borders.
 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.
 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.
 double getA()
          Returns the first semi-major axis length in mm.
 double getB()
          Returns the second semi-major axis length in mm.
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.
 java.awt.geom.Point2D.Double getCentrePix(int nCols, int nRows, float pixelXSize, float pixelYSize)
          Gets the centre of this ROI in pixel coordinates.
 ROI getCopy()
          Returns a copy of this ROI.
static ROICreateDialog getCreateDialog(CanAddROIToFrame listener)
          Returns a JDialog that can be used to create Elliptical ROIs.
static InteractionType getCreateInteractionType()
          Returns the type of interaction needed to create an EllipticalROI.
 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.
static EllipticalROI getInstance(java.awt.Rectangle boundingRectangle, int nCols, int nRows, float pixelXSize, float pixelYSize, byte userColour, ROIState state)
          Creates an instance of a EllipticalROI suitable for drawing on a window.
static java.lang.String getName()
          Returns a descriptive name for this type of ROI.
 double getPerimeter()
          Returns the perimeter length of this EllipticalROI.
 double getSquareArea()
          Returns the area of this regular ROI in square mm.
 double getTheta()
          Returns the current rotation angle for this RotatableROI.
 int hashCode()
          Returns a hash code value for this EllipticalROI.
 void move(double dx, double dy)
          Move this ROI by specified distances (in mm) in the x and y directions.
 void move(EllipticalROI newEllipse, boolean pixelSnap)
          Moves and rehapes this EllipticalROI so that the size and location are the same as the given EllipticalROI.
 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.
 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
 

Field Detail

ATOKEN

public static final java.lang.String ATOKEN
The token written to ROI output files to represent the first semi-major axis length.

See Also:
Constant Field Values

BTOKEN

public static final java.lang.String BTOKEN
The token written to ROI output files to represent the second semi-major axis length.

See Also:
Constant Field Values

THETATOKEN

public static final java.lang.String THETATOKEN
The token written to ROI output files to represent the rotation angle.

See Also:
Constant Field Values
Constructor Detail

EllipticalROI

public EllipticalROI(java.awt.geom.Point2D.Double centre,
                     double a,
                     double b,
                     double theta)
              throws ROIException
Creates a new EllipticalROI with the specified shape in mm coordinates. The ROI state will be ROIState.NORMAL.

Parameters:
centre - the location of the centre of the ellipse in mm coordinates.
a - the first semi-axis length in mm.
b - the second semi-axis length in mm.
theta - the angle between the first axis and the x-direction. Theta is positive clockwise.
Throws:
ROIException - if either the major or the minor axis length is not positive.

EllipticalROI

public EllipticalROI(double centreX,
                     double centreY,
                     double a,
                     double b,
                     double theta,
                     ROIState state)
              throws ROIException
Creates a new EllipticalROI with the specified shape in mm coordinates.

Parameters:
centreX - the x-location of the centre of the ellipse in mm.
centreY - the y-location of the centre of the ellipse in mm.
a - the first semi-axis length in mm.
b - the second semi-axis length in mm.
theta - the angle between the first axis and the x-direction. Theta is positive clockwise.
state - the selection state of the EllipticalROI.
Throws:
ROIException - if either the major or the minor semi-axis length is not positive.

EllipticalROI

public EllipticalROI(double centreX,
                     double centreY,
                     double a,
                     double b,
                     double theta,
                     byte userColour,
                     ROIState state)
              throws ROIException
Creates a new EllipticalROI with the specified shape in mm coordinates.

Parameters:
centreX - the x-location of the centre of the ellipse in mm.
centreY - the y-location of the centre of the ellipse in mm.
a - the first semi-axis length in mm.
b - the second semi-axis length in mm.
theta - the angle between the first axis and the x-direction. Theta is positive clockwise.
state - the selection state of the EllipticalROI.
Throws:
ROIException - if either the major or the minor semi-axis length is not positive.
Method Detail

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.

getA

public double getA()
Returns the first semi-major axis length in mm.

Returns:
the first semi-major axis length in mm.

getB

public double getB()
Returns the second semi-major axis length in mm.

Returns:
the second semi-major axis length in mm.

getCentrePix

public java.awt.geom.Point2D.Double getCentrePix(int nCols,
                                                 int nRows,
                                                 float pixelXSize,
                                                 float pixelYSize)
Gets the centre of this ROI in pixel coordinates.

Returns:
the centre of this ROI in pixel coordinates.

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.

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.

getCreateInteractionType

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

Returns:
type of interaction needed to create an EllipticalROI - InteractionType.NONE.

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 ROI in square mm.

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(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.

move

public void move(EllipticalROI newEllipse,
                 boolean pixelSnap)
Moves and rehapes this EllipticalROI so that the size and location are the same as the given EllipticalROI.

Parameters:
newEllipse - the EllipticalROI from which to take the location, size and rotation angle.
pixelSnap - indicates whether pixel snap is turned on.

getInstance

public static EllipticalROI getInstance(java.awt.Rectangle boundingRectangle,
                                        int nCols,
                                        int nRows,
                                        float pixelXSize,
                                        float pixelYSize,
                                        byte userColour,
                                        ROIState state)
                                 throws ROIException
Creates an instance of a EllipticalROI suitable for drawing on a window. Bounding rectangle determines the maximum size of the ROI (in image pixels).

Parameters:
boundingRectangle - the area of screen into which the ROI must fit.
nCols - the number of image columns.
nRows - the number of image rows.
pixelXSize - the size of image pixels in the horizontal direction.
pixelYSize - the size of image pixels in the vertical direction.
state - the initial state of this newly-created ROI.
Returns:
a new EllipticalROI that can be displayed inside the specified region of image pixels.
Throws:
ROIException

dilate

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

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()
Returns the perimeter length of this EllipticalROI. The returned perimeter is the computed using the YNOT approximation formula, which gives a maximum error of 0.362%. The maximum error occurs when the eccentricity is slightly above 5.

Specified by:
getPerimeter in class ROI
Returns:
the (approximate) perimeter length of this Elliptical ROI.

getCreateDialog

public static ROICreateDialog getCreateDialog(CanAddROIToFrame listener)
Returns a JDialog that can be used to create Elliptical ROIs.

Parameters:
listener - the CanAddROIToFrame to which the ROI will be added when the Add button of the Dialog is clicked.
Returns:
a ROICreateDialog that is used to create an EllipticalROI.

contains

public boolean contains(ROI roi)
Indicates whether this EllipticalROI 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 EllipticalROI 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 EllipticalROI.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this EllipticalROI.

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.