Package com.xinapse.multisliceimage.roi
Class EllipticalROI
java.lang.Object
com.xinapse.multisliceimage.roi.ROI
com.xinapse.multisliceimage.roi.EllipticalROI
- All Implemented Interfaces:
RegularROI
,RotatableROI
,Cloneable
A Class representing an elliptical region of an image.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The token written to ROI output files to represent the first semi-major axis length.static final String
The token written to ROI output files to represent the second semi-major axis length.static final String
The token written to ROI output files to represent the rotation angle.Fields inherited from class com.xinapse.multisliceimage.roi.ROI
BUTTON_ICON_SIZE, handles, PREFERENCES_NODE_NAME, XTOKEN, YTOKEN
-
Constructor Summary
ConstructorDescriptionEllipticalROI
(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
(Point2D.Double centre, double a, double b, double theta) Creates a new EllipticalROI with the specified shape in mm coordinates. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of thisROI
.boolean
Indicates whether thisEllipticalROI
contains anotherROI
entirely within its borders.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 thisROI
if it needs to be be drawn on screen.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) Draws this ROI on top of an orthogonal view of an image.boolean
void
flipHorizontal
(Point2D flipPoint) Flip thisROI
horizontally about a given location.void
flipVertical
(Point2D flipPoint) Flip thisROI
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 Icon
Returns an Icon that can be used for a button to create this type of ROI.Gets the centre (about which rotation will occur) of this RotatableROI in mm.getCentrePix
(int nCols, int nRows, float pixelXSize, float pixelYSize) Gets the centre of this ROI in pixel coordinates.org.jogamp.vecmath.Point2d
Returns the centroid (centre of area) of thisROI
.getCopy()
Returns a copy of thisROI
.static ROICreateDialog
getCreateDialog
(CanAddROIToFrame listener) Returns a JDialog that can be used to create Elliptical ROIs.static InteractionType
Returns the type of interaction needed to create an EllipticalROI.Return a description of this type ofROI
.getFeret()
Returns the minimum and maximum Feret's diameter for thisROI
, in mm.static EllipticalROI
getInstance
(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 String
getName()
Returns a descriptive name for this type of ROI.double
Returns the perimeter length of this EllipticalROI.double
Returns the angle between the major principal axis of thisROI
and the x-axis.double
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 thisEllipticalROI
.intersect
(ROI roi, IndeterminateProgressMonitor progressMonitor) Performs an intersection operation on the shape of this ROI with another ROI.void
move
(double dx, double dy) Move thisROI
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
void
setTheta
(double theta) Sets the rotation angle for this RotatableROI.toSpline()
Returns a SplineROI that closely approximates to this EllipticalROI.toString()
Methods inherited from class com.xinapse.multisliceimage.roi.ROI
andNot, andNot, andNot, clearDeletionHistory, dilate, exclusiveOr, exclusiveOr, getAnnotation, getBoundingRectangle, getBoundingRectangle, getCentroid, getClasses, getColor, getDesignTextFontSize, getDisplayedBounds2D, getDisplayedBounds2D, getDisplayedRoiArea, getFeret, getGroupUid, getGroupUid, getHandles, getHandleUnderPoint, getImageSource, getPixelValue, getROIs, getROIs, getROIs, getROIs, getROIs, getSlice, getState, getStats, getStats, getStats, getTextColor, getUserColour, group, intersect, intersect, intersects, isDeleted, isEditable, isGroup, isReloaded, isSameAnnotation, isSameColour, isSelected, join, logicalUnion, main, markDeleted, mmPosToPix, moveROIs, pixPosToMm, printStats, selectDeselect, setAnnotation, setCreationHistory, setGroupUid, setSlice, setState, setTextColor, setTextSize, setUserColour, ungroup, ungroup, union, union, write, write
-
Field Details
-
ATOKEN
The token written to ROI output files to represent the first semi-major axis length.- See Also:
-
BTOKEN
The token written to ROI output files to represent the second semi-major axis length.- See Also:
-
THETATOKEN
The token written to ROI output files to represent the rotation angle.- See Also:
-
-
Constructor Details
-
EllipticalROI
Creates a new EllipticalROI with the specified shape in mm coordinates. The ROI state will beROIState.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.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 selection state of the EllipticalROI.- Throws:
ROIException
- if either the major or the minor semi-axis length is not positive.
-
-
Method Details
-
getCentre
Description copied from interface:RotatableROI
Gets the centre (about which rotation will occur) of this RotatableROI in mm.- Specified by:
getCentre
in interfaceRotatableROI
- 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
Gets the centre of this ROI in pixel coordinates.- Parameters:
nCols
- the number of image columns.nRows
- the number of image rows.pixelXSize
- the image pixel width, in mm.pixelYSize
- the image pixel height, in mm.- 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 interfaceRotatableROI
- 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 interfaceRotatableROI
- Parameters:
theta
- the rotation angle.
-
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 interfaceRegularROI
- Returns:
- the area of this ROI in square mm.
-
move
public void move(double dx, double dy) Description copied from class:ROI
Move thisROI
by specified distances (in mm) in the x and y directions. -
flipVertical
Description copied from class:ROI
Flip thisROI
vertically about a given location.- Specified by:
flipVertical
in classROI
- Parameters:
flipPoint
- the point about which the ROI will be flipped.
-
flipHorizontal
Description copied from class:ROI
Flip thisROI
horizontally about a given location.- Specified by:
flipHorizontal
in classROI
- Parameters:
flipPoint
- the point about which the ROI will be flipped.
-
move
Moves and rehapes this EllipticalROI so that the size and location are the same as the given EllipticalROI.- Parameters:
newEllipse
- theEllipticalROI
from which to take the location, size and rotation angle.pixelSnap
- indicates whether pixel snap is turned on.
-
getInstance
public static EllipticalROI getInstance(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.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 initial state of this newly-created ROI.- Returns:
- a new EllipticalROI that can be displayed inside the specified region of image pixels.
- Throws:
ROIException
- if the ROI cannot be created as requested.
-
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 thisROI
if it needs to be be drawn on screen.- Overrides:
draw
in classROI
- 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 thisROI
is defined.nRows
- the number of rows in the image on which thisROI
is defined.pixelXSize
- pixel width for the image on which thisROI
is defined.pixelYSize
- pixel height for the image on which thisROI
is defined.drawAnnotation
- a flag to indicate whether annotation should be drawn.- Returns:
true
if theROI
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 classROI
- Parameters:
orthoView
- theImage
into which the ROI is to be drawn.orthoViewPosition
- the coordinates (col, row, slice position) of the orthogonal view in the original image.imageToViewTx
- theTransform3D
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).
-
toSpline
Returns a SplineROI that closely approximates to this EllipticalROI.- Returns:
- a SplineROI that closely approximates to this EllipticalROI.
-
getFeret
Description copied from class:ROI
Returns the minimum and maximum Feret's diameter for thisROI
, in mm. -
getPerimeter
public double getPerimeter()Returns the perimeter length of this EllipticalROI. The returned perimeter is 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 classROI
- Returns:
- the (approximate) perimeter length of this Elliptical ROI.
-
getCentroid
public org.jogamp.vecmath.Point2d getCentroid()Description copied from class:ROI
Returns the centroid (centre of area) of thisROI
.- Specified by:
getCentroid
in classROI
- Returns:
- the centroid of this
ROI
.
-
getPrincipalAxisAngle
public double getPrincipalAxisAngle()Returns the angle between the major principal axis of thisROI
and the x-axis. For an EllipticalROI, this is the angle between the largest ellipse axis and the x-axis.- Returns:
- the main principal axis angle of this
ROI
.
-
getCreateDialog
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
Indicates whether thisEllipticalROI
contains anotherROI
entirely within its borders. -
intersect
Description copied from class:ROI
Performs an intersection operation on the shape of this ROI with another ROI. -
equals
Description copied from class:ROI
-
hashCode
public int hashCode()Returns a hash code value for thisEllipticalROI
.- Overrides:
hashCode
in classROI
- Returns:
- a hash code value for this
EllipticalROI
.
-
set
Description copied from class:ROI
- Specified by:
set
in classROI
- Parameters:
roi
- the ROI from which the shape is set.- Throws:
ClassCastException
- if the sub-class of the argumentROI
is not the same as thisROI
.
-
getCopy
Description copied from class:ROI
Returns a copy of thisROI
. The copy will be identical in shape and annotation as the original ROI, but with a history of that of a newly-created ROI. -
clone
Description copied from class:ROI
-
toString
Description copied from class:ROI
-
getDescription
Description copied from class:ROI
Return a description of this type ofROI
.- Specified by:
getDescription
in classROI
- Returns:
- a String describing the type of this
ROI
.
-
getName
Returns a descriptive name for this type of ROI.- Returns:
- a String describing this type of ROI.
-
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.
-