Package com.xinapse.multisliceimage.roi
Class RectangularROI
java.lang.Object
com.xinapse.multisliceimage.roi.ROI
com.xinapse.multisliceimage.roi.RectangularROI
- All Implemented Interfaces:
RegularROI,StretchableROI,Cloneable
An Class representing a rectangular region of an image.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe token written to ROI output files to represent the height of a rectangular ROI.static final StringThe token written to ROI output files to represent the width of a rectangular ROI.Fields inherited from class com.xinapse.multisliceimage.roi.ROI
BUTTON_ICON_SIZE, handles, PREFERENCES_NODE_NAME, XTOKEN, YTOKEN -
Constructor Summary
ConstructorsConstructorDescriptionRectangularROI(double x, double y, double width, double height) Creates a new RectangularROI with the supplied dimensions in mm coordinates.RectangularROI(double x, double y, double width, double height, ROIState state) Creates a new RectangularROI with the supplied dimensions in mm.RectangularROI(Rectangle2D.Double rect, ROIState state) Creates a new RectangularROI with the dimension given by the supplied Rectangle2D in mm coordinates. -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a clone of thisROI.booleanIndicates whether thisRectangularROIcontains anotherROIentirely within its borders.booleandraw(Graphics g, Rectangle visibleRectangle, int imageDrawCols, int imageDrawRows, int xOffset, int yOffset, int nCols, int nRows, float pixelXSize, float pixelYSize, boolean drawAnnotation) Draws thisROIif it needs to be be drawn on screen.voiddrawInOrthoView(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.booleanvoidflipHorizontal(Point2D flipPoint) Flip thisROIhorizontally about a given location.voidflipVertical(Point2D flipPoint) Flip thisROIvertically about a given location.static IconReturns an Icon that can be used for a button to create this type of ROI.org.jogamp.vecmath.Point2dReturns the centroid (centre of area) of thisROI.getCopy()Returns a copy of thisROI.static ROICreateDialoggetCreateDialog(CanAddROIToFrame listener) Returns a JDialog that can be used to create Rectangular ROIs.static InteractionTypeReturns the type of interaction needed to create a RectangularROI.Return a description of this type ofROI.getFeret()Returns the minimum and maximum Feret's diameter for thisROI, in mm.doubleReturns the height of this RectangularROI in mm.static ROIgetInstance(Rectangle boundingRectangle, int nCols, int nRows, float pixelXSize, float pixelYSize, byte userColour, ROIState state) Creates an instance of a RectangularROI suitable for drawing on a window.static StringgetName()Returns a descriptive name for this type of ROI.doubleReturns the perimeter length of thisROI.doubleReturns the angle between the major principal axis of thisROIand the x-axis.doubleReturns the area of this regular ROI in square mm.doublegetWidth()Returns the width of this RectangularROI in mm.doublegetX()Returns the x-coordinate of the top left corner of this RectangularROI in mm.doublegetY()Returns the y-coordinate of the top left corner of this RectangularROI in mm.inthashCode()Returns a hash code value for thisRectangularROI.intersect(ROI roi, IndeterminateProgressMonitor progressMonitor) Performs an intersection operation on the shape of this ROI with another ROI.voidmove(double dx, double dy) Move thisROIby specified distances (in mm) in the x and y directions.voidmove(double dx, double dy, double stretchX, double stretchY) Moves and stretches an ROI.voidtoString()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, writeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.xinapse.multisliceimage.roi.StretchableROI
getDisplayedBounds2D
-
Field Details
-
WIDTHTOKEN
The token written to ROI output files to represent the width of a rectangular ROI.- See Also:
-
HEIGHTTOKEN
The token written to ROI output files to represent the height of a rectangular ROI.- See Also:
-
-
Constructor Details
-
RectangularROI
Creates a new RectangularROI with the dimension given by the supplied Rectangle2D in mm coordinates.- Parameters:
rect- the Rectangle2D.Double that gives the size and location of the ROI in mm.state- the ROIState for the ROI at creation.- Throws:
ROIException- if the ROI cannot be created.
-
RectangularROI
Creates a new RectangularROI with the supplied dimensions in mm coordinates. The new RectangularROI will be in a state ROIState.NORMAL.- Parameters:
x- the x-coordinate of the top left corner of the rectangle in mm.y- the y-coordinate of the top left corner of the rectangle in mm.width- the width of the rectangle.height- the height of the rectangle.- Throws:
ROIException- if the ROI cannot be created.
-
RectangularROI
public RectangularROI(double x, double y, double width, double height, ROIState state) throws ROIException Creates a new RectangularROI with the supplied dimensions in mm.- Parameters:
x- the x-coordinate of the top left corner of the rectangle in mm.y- the y-coordinate of the top left corner of the rectangle in mm.width- the width of the rectangle in mm.height- the height of the rectangle in mm.state- the ROIState for the ROI at creation.- Throws:
ROIException- if the ROI cannot be created.
-
-
Method Details
-
getX
public double getX()Returns the x-coordinate of the top left corner of this RectangularROI in mm.- Returns:
- the x-coordinate of the top left corner of this RectangularROI in mm.
-
getY
public double getY()Returns the y-coordinate of the top left corner of this RectangularROI in mm.- Returns:
- the y-coordinate of the top left corner of this RectangularROI in mm.
-
getWidth
public double getWidth()Returns the width of this RectangularROI in mm.- Returns:
- the width of this RectangularROI in mm.
-
getHeight
public double getHeight()Returns the height of this RectangularROI in mm.- Returns:
- the height of this RectangularROI in mm.
-
getCreateInteractionType
Returns the type of interaction needed to create a RectangularROI.- Returns:
- type of interaction needed to create a RectangularROI - InteractionType.NONE.
-
getSquareArea
public double getSquareArea()Description copied from interface:RegularROIReturns the area of this regular ROI in square mm.- Specified by:
getSquareAreain interfaceRegularROI- Returns:
- the area of this ROI in square mm.
-
move
public void move(double dx, double dy) Description copied from class:ROIMove thisROIby specified distances (in mm) in the x and y directions. -
move
public void move(double dx, double dy, double stretchX, double stretchY) Description copied from interface:StretchableROIMoves 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:
movein interfaceStretchableROI- Parameters:
dx- the distance (in mm) to move the centre of theStretchableROIin the horizontal direction.dy- the distance (in mm) to move the centre of theStretchableROIin the vertical direction.stretchX- the stretch in the horizontal direction.stretchY- the stretch in the vertical direction.
-
flipVertical
Description copied from class:ROIFlip thisROIvertically about a given location.- Specified by:
flipVerticalin classROI- Parameters:
flipPoint- the point about which the ROI will be flipped.
-
flipHorizontal
Description copied from class:ROIFlip thisROIhorizontally about a given location.- Specified by:
flipHorizontalin classROI- Parameters:
flipPoint- the point about which the ROI will be flipped.
-
getInstance
public static ROI getInstance(Rectangle boundingRectangle, int nCols, int nRows, float pixelXSize, float pixelYSize, byte userColour, ROIState state) throws ROIException Creates an instance of a RectangularROI 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 RectangularROI that can be displayed inside the specified region of image pixels.
- Throws:
ROIException- if the ROI cannot be created as specified.
-
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:ROIDraws thisROIif it needs to be be drawn on screen.- Overrides:
drawin 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 thisROIis defined.nRows- the number of rows in the image on which thisROIis defined.pixelXSize- pixel width for the image on which thisROIis defined.pixelYSize- pixel height for the image on which thisROIis defined.drawAnnotation- a flag to indicate whether annotation should be drawn.- Returns:
trueif theROIis visible and been drawn on screen;falseotherwise.
-
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:ROIDraws this ROI on top of an orthogonal view of an image.- Specified by:
drawInOrthoViewin classROI- Parameters:
orthoView- theImageinto which the ROI is to be drawn.orthoViewPosition- the coordinates (col, row, slice position) of the orthogonal view in the original image.imageToViewTx- theTransform3Dthat 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).
-
getFeret
Description copied from class:ROIReturns the minimum and maximum Feret's diameter for thisROI, in mm. -
getPerimeter
public double getPerimeter()Description copied from class:ROIReturns the perimeter length of thisROI.- Specified by:
getPerimeterin classROI- Returns:
- the perimeter length of this
ROI.
-
getCentroid
public org.jogamp.vecmath.Point2d getCentroid()Description copied from class:ROIReturns the centroid (centre of area) of thisROI.- Specified by:
getCentroidin classROI- Returns:
- the centroid of this
ROI.
-
getPrincipalAxisAngle
public double getPrincipalAxisAngle()Returns the angle between the major principal axis of thisROIand the x-axis. The angle returned will is either 0 or PI/2 radians, depending on whether the rectangle is wider than it is tall.- Returns:
- the main principal axis angle of this
ROI.
-
getCreateDialog
Returns a JDialog that can be used to create Rectangular 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 Rectangular ROIs.
-
contains
Indicates whether thisRectangularROIcontains anotherROIentirely within its borders. -
intersect
public List<ROI> intersect(ROI roi, IndeterminateProgressMonitor progressMonitor) throws ROIException, CancelledException Description copied from class:ROIPerforms an intersection operation on the shape of this ROI with another ROI.- Overrides:
intersectin classROI- 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.
-
equals
Description copied from class:ROI -
hashCode
public int hashCode()Returns a hash code value for thisRectangularROI.- Overrides:
hashCodein classROI- Returns:
- a hash code value for this
RectangularROI.
-
set
Description copied from class:ROI- Specified by:
setin classROI- Parameters:
roi- the ROI from which the shape is set.- Throws:
ClassCastException- if the sub-class of the argumentROIis not the same as thisROI.
-
getCopy
Description copied from class:ROIReturns 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:ROIReturn a description of this type ofROI.- Specified by:
getDescriptionin 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.
-