Class Roi
java.lang.Object
org.micromanager.ndviewer.overlay.Roi
- All Implemented Interfaces:
Serializable,Cloneable
public class Roi extends Object implements Cloneable, Serializable
A rectangular region of interest and superclass for the other ROI classes.
This class implements
Iterable<Point> and can thus be used to iterate
over the contained coordinates. Usage example:
Roi roi = ...;
for (Point p : roi) {
// process p
}
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static intANGLEprotected doubleasp_bkprotected booleanaspectprotected booleancenterprotected intclipHeightprotected intclipWidthprotected intclipXprotected intclipYstatic intCOMPOSITEprotected booleanconstrainstatic intCONSTRUCTINGprotected static ColordefaultFillColorprotected ColorfillColorstatic intFREELINEstatic intFREEROIstatic intHANDLE_SIZEprotected ColorhandleColorprotected booleanignoreClipRectprotected ColorinstanceColorstatic intLINEprotected static intlineWidthprotected doublemagstatic intMOVINGstatic intMOVING_HANDLEprotected booleannonScalablestatic intNORMALstatic intNOT_PASTINGprotected intoldHeightprotected intoldWidthprotected intoldXprotected intoldYstatic BasicStrokeonePixelWidestatic intOVALprotected booleanoverlaystatic intPOINTstatic intPOLYGONstatic intPOLYLINEstatic RoipreviousRoistatic intRECTANGLEstatic intRESIZINGprotected static ColorROIColorprotected BasicStrokestrokeprotected ColorstrokeColorstatic intTRACED_ROIprotected inttypeprotected booleanupdateFullWindowprotected booleanwideLineprotected intxMaxprotected intyMax -
Constructor Summary
Constructors Constructor Description Roi(double x, double y, double width, double height)Creates a rectangular ROI using double arguments.Roi(double x, double y, double width, double height, int cornerDiameter)Creates a rounded rectangular ROI using double arguments.Roi(int x, int y, int width, int height)Creates a rectangular ROI.Roi(int x, int y, int width, int height, int cornerDiameter)Creates a new rounded rectangular ROI.Roi(Rectangle r)Creates a new rectangular Roi. -
Method Summary
Modifier and Type Method Description protected intclipRectMargin()booleancontains(int x, int y)voidcopyAttributes(Roi roi2)Copy the attributes (outline color, fill color, outline width) of 'roi2' to the this selection.voiddraw(Graphics g)voiddrawOverlay(Graphics g)voidenableSubPixelResolution()doublegetAngle()Overridden by PolygonRoi (angle between first two points), TextRoi (text angle) and Line (line angle).RectanglegetBoundingRect()Deprecated.replaced by getBounds()RectanglegetBounds()Return this selection's bounding rectangle.static ColorgetColor()Returns the default (global) color used for drawing ROI outlines.PolygongetConvexHull()intgetCornerDiameter()Returns the rounded rectangle corner diameter (pixels).intgetCPosition()Returns the channel position of this ROI, or zero if this ROI is not associated with a particular channel.StringgetDebugInfo()static ColorgetDefaultFillColor()booleangetDrawOffset()Returns true if this is a PolygonRoi that supports sub-pixel resolution and polygons are drawn on zoomed images offset down and to the right by 0.5 pixels..ColorgetFillColor()Returns the fill color used to display this ROI, or null if it is displayed transparently.Rectangle2D.DoublegetFloatBounds()Return this selection's bounding rectangle.doublegetFloatHeight()doublegetFloatWidth()intgetHashCode()Returns a hashcode for this Roi that typically changes if it is moved, even though it is still the same object.StringgetName()Returns the name of this ROI, or null.PolygongetPolygon()Returns the outline of this selection as a Polygon, or null if this is a straight line selection.intgetPosition()Returns the stack position (image number) of this ROI, or zero if the ROI is not associated with a particular stack image.StringgetProperties()StringgetProperty(String property)intgetPropertyCount()OverlaygetPrototypeOverlay()intgetRoundRectArcSize()Obsolete; replaced by getCornerDiameter().intgetState()BasicStrokegetStroke()Returns the Stroke used to draw this ROI, or null if no Stroke is used.ColorgetStrokeColor()Returns the the color used to draw the ROI outline or null if the default color is being used.floatgetStrokeWidth()Returns the lineWidth.intgetTPosition()Returns the frame position of this ROI, or zero if this ROI is not associated with a particular frame.intgetType()StringgetTypeAsString()Convenience method that converts Roi type to a human-readable form.doublegetXBase()doublegetYBase()intgetZPosition()Returns the slice position of this ROI, or zero if this ROI is not associated with a particular slice.booleanisArea()Returns 'true' if this is an area selection.booleanisCursor()booleanisDrawingTool()Returns 'true' if this is an ROI primarily used from drawing (e.g., TextRoi or Arrow).booleanisLine()Returns 'true' if this is a line selection.static voidsetColor(Color c)Sets the default (global) color used for ROI outlines.voidsetCornerDiameter(int cornerDiameter)Sets the rounded rectangle corner diameter (pixels).static voidsetDefaultFillColor(Color color)voidsetDrawOffset(boolean drawOffset)voidsetFillColor(Color color)Sets the fill color used to display this ROI, or set to null to display it transparently.voidsetIgnoreClipRect(boolean ignoreClipRect)voidsetIsCursor(boolean isCursor)voidsetLocation(double x, double y)Set the location of the ROI in image coordinates.voidsetLocation(int x, int y)Set the location of the ROI in image coordinates.voidsetName(String name)Sets the name of this ROI.voidsetNonScalable(boolean nonScalable)Set 'nonScalable' true to have TextRois in a display list drawn at a fixed location and size.voidsetPosition(int n)Sets the stack position (image number) of this ROI.voidsetPosition(int channel, int slice, int frame)Sets the hyperstack position of this ROI.voidsetProperty(String key, String value)voidsetPrototypeOverlay(Overlay overlay)voidsetRotationCenter(double x, double y)voidsetRoundRectArcSize(int cornerDiameter)Obsolete; replaced by setCornerDiameter().voidsetStroke(BasicStroke stroke)Sets the Stroke used to draw this ROI.voidsetStrokeColor(Color c)Sets the color used by this ROI to draw its outline.voidsetStrokeWidth(double width)This is a version of setStrokeWidth() that accepts a double argument.voidsetStrokeWidth(float width)Sets the width of the line used to draw this ROI.booleansubPixelResolution()Returns true if this is a slection that supports sub-pixel resolution.voidtemporarilyHide()Deprecatedstatic float[]toFloat(int[] arr)Converts an int array to a float array.static int[]toInt(float[] arr)Converts a float array to an int array using truncation.static int[]toInt(float[] arr, int[] arr2, int size)static int[]toIntR(float[] arr)Converts a float array to an int array using rounding.StringtoString()
-
Field Details
-
CONSTRUCTING
public static final int CONSTRUCTING- See Also:
- Constant Field Values
-
MOVING
public static final int MOVING- See Also:
- Constant Field Values
-
RESIZING
public static final int RESIZING- See Also:
- Constant Field Values
-
NORMAL
public static final int NORMAL- See Also:
- Constant Field Values
-
MOVING_HANDLE
public static final int MOVING_HANDLE- See Also:
- Constant Field Values
-
RECTANGLE
public static final int RECTANGLE- See Also:
- Constant Field Values
-
OVAL
public static final int OVAL- See Also:
- Constant Field Values
-
POLYGON
public static final int POLYGON- See Also:
- Constant Field Values
-
FREEROI
public static final int FREEROI- See Also:
- Constant Field Values
-
TRACED_ROI
public static final int TRACED_ROI- See Also:
- Constant Field Values
-
LINE
public static final int LINE- See Also:
- Constant Field Values
-
POLYLINE
public static final int POLYLINE- See Also:
- Constant Field Values
-
FREELINE
public static final int FREELINE- See Also:
- Constant Field Values
-
ANGLE
public static final int ANGLE- See Also:
- Constant Field Values
-
COMPOSITE
public static final int COMPOSITE- See Also:
- Constant Field Values
-
POINT
public static final int POINT- See Also:
- Constant Field Values
-
HANDLE_SIZE
public static final int HANDLE_SIZE- See Also:
- Constant Field Values
-
NOT_PASTING
public static final int NOT_PASTING- See Also:
- Constant Field Values
-
previousRoi
-
onePixelWide
-
lineWidth
protected static int lineWidth -
defaultFillColor
-
ROIColor
-
type
protected int type -
xMax
protected int xMax -
yMax
protected int yMax -
oldX
protected int oldX -
oldY
protected int oldY -
oldWidth
protected int oldWidth -
oldHeight
protected int oldHeight -
clipX
protected int clipX -
clipY
protected int clipY -
clipWidth
protected int clipWidth -
clipHeight
protected int clipHeight -
constrain
protected boolean constrain -
center
protected boolean center -
aspect
protected boolean aspect -
updateFullWindow
protected boolean updateFullWindow -
mag
protected double mag -
asp_bk
protected double asp_bk -
handleColor
-
strokeColor
-
instanceColor
-
fillColor
-
stroke
-
nonScalable
protected boolean nonScalable -
overlay
protected boolean overlay -
wideLine
protected boolean wideLine -
ignoreClipRect
protected boolean ignoreClipRect
-
-
Constructor Details
-
Roi
public Roi(int x, int y, int width, int height)Creates a rectangular ROI. -
Roi
public Roi(double x, double y, double width, double height)Creates a rectangular ROI using double arguments. -
Roi
public Roi(int x, int y, int width, int height, int cornerDiameter)Creates a new rounded rectangular ROI. -
Roi
public Roi(double x, double y, double width, double height, int cornerDiameter)Creates a rounded rectangular ROI using double arguments. -
Roi
Creates a new rectangular Roi.
-
-
Method Details
-
setLocation
public void setLocation(int x, int y)Set the location of the ROI in image coordinates. -
setLocation
public void setLocation(double x, double y)Set the location of the ROI in image coordinates. -
getType
public int getType() -
getState
public int getState() -
getConvexHull
-
getBounds
Return this selection's bounding rectangle. -
getFloatBounds
Return this selection's bounding rectangle. -
getBoundingRect
Deprecated.replaced by getBounds() -
getPolygon
Returns the outline of this selection as a Polygon, or null if this is a straight line selection. -
clipRectMargin
protected int clipRectMargin() -
draw
-
drawOverlay
-
setColor
Sets the default (global) color used for ROI outlines.- See Also:
getColor(),setStrokeColor(Color)
-
getColor
Returns the default (global) color used for drawing ROI outlines.- See Also:
setColor(Color),getStrokeColor()
-
contains
public boolean contains(int x, int y) -
setStrokeColor
Sets the color used by this ROI to draw its outline. This color, if not null, overrides the global color set by the static setColor() method.- See Also:
getStrokeColor(),setStrokeWidth(float)
-
getStrokeColor
Returns the the color used to draw the ROI outline or null if the default color is being used.- See Also:
setStrokeColor(Color)
-
setFillColor
Sets the fill color used to display this ROI, or set to null to display it transparently.- See Also:
getFillColor(),setStrokeColor(java.awt.Color)
-
getFillColor
Returns the fill color used to display this ROI, or null if it is displayed transparently.- See Also:
setFillColor(java.awt.Color),getStrokeColor()
-
setDefaultFillColor
-
getDefaultFillColor
-
copyAttributes
Copy the attributes (outline color, fill color, outline width) of 'roi2' to the this selection. -
setNonScalable
public void setNonScalable(boolean nonScalable)Set 'nonScalable' true to have TextRois in a display list drawn at a fixed location and size. -
setStrokeWidth
public void setStrokeWidth(float width)Sets the width of the line used to draw this ROI. Set the width to 0.0 and the ROI will be drawn using a a 1 pixel stroke width regardless of the magnification.- See Also:
setStrokeColor(Color)
-
setStrokeWidth
public void setStrokeWidth(double width)This is a version of setStrokeWidth() that accepts a double argument. -
getStrokeWidth
public float getStrokeWidth()Returns the lineWidth. -
setStroke
Sets the Stroke used to draw this ROI. -
getStroke
Returns the Stroke used to draw this ROI, or null if no Stroke is used. -
getName
Returns the name of this ROI, or null. -
setName
Sets the name of this ROI. -
setCornerDiameter
public void setCornerDiameter(int cornerDiameter)Sets the rounded rectangle corner diameter (pixels). -
getCornerDiameter
public int getCornerDiameter()Returns the rounded rectangle corner diameter (pixels). -
setRoundRectArcSize
public void setRoundRectArcSize(int cornerDiameter)Obsolete; replaced by setCornerDiameter(). -
getRoundRectArcSize
public int getRoundRectArcSize()Obsolete; replaced by getCornerDiameter(). -
setPosition
public void setPosition(int n)Sets the stack position (image number) of this ROI. In an overlay, this ROI is only displayed when the stack is at the specified position. Set to zero to have the ROI displayed on all images in the stack.- See Also:
Overlay
-
getPosition
public int getPosition()Returns the stack position (image number) of this ROI, or zero if the ROI is not associated with a particular stack image.- See Also:
Overlay
-
setPosition
public void setPosition(int channel, int slice, int frame)Sets the hyperstack position of this ROI. In an overlay, this ROI is only displayed when the hyperstack is at the specified position.- See Also:
Overlay
-
getCPosition
public final int getCPosition()Returns the channel position of this ROI, or zero if this ROI is not associated with a particular channel. -
getZPosition
public final int getZPosition()Returns the slice position of this ROI, or zero if this ROI is not associated with a particular slice. -
getTPosition
public final int getTPosition()Returns the frame position of this ROI, or zero if this ROI is not associated with a particular frame. -
setPrototypeOverlay
-
getPrototypeOverlay
-
isArea
public boolean isArea()Returns 'true' if this is an area selection. -
isLine
public boolean isLine()Returns 'true' if this is a line selection. -
isDrawingTool
public boolean isDrawingTool()Returns 'true' if this is an ROI primarily used from drawing (e.g., TextRoi or Arrow). -
getTypeAsString
Convenience method that converts Roi type to a human-readable form. -
subPixelResolution
public boolean subPixelResolution()Returns true if this is a slection that supports sub-pixel resolution. -
getDrawOffset
public boolean getDrawOffset()Returns true if this is a PolygonRoi that supports sub-pixel resolution and polygons are drawn on zoomed images offset down and to the right by 0.5 pixels.. -
setDrawOffset
public void setDrawOffset(boolean drawOffset) -
setIgnoreClipRect
public void setIgnoreClipRect(boolean ignoreClipRect) -
toInt
public static int[] toInt(float[] arr)Converts a float array to an int array using truncation. -
toInt
public static int[] toInt(float[] arr, int[] arr2, int size) -
toIntR
public static int[] toIntR(float[] arr)Converts a float array to an int array using rounding. -
toFloat
public static float[] toFloat(int[] arr)Converts an int array to a float array. -
setProperty
-
getProperty
-
getProperties
-
getPropertyCount
public int getPropertyCount() -
toString
-
temporarilyHide
public void temporarilyHide()Deprecated -
getXBase
public double getXBase() -
getYBase
public double getYBase() -
getFloatWidth
public double getFloatWidth() -
getFloatHeight
public double getFloatHeight() -
getAngle
public double getAngle()Overridden by PolygonRoi (angle between first two points), TextRoi (text angle) and Line (line angle). -
enableSubPixelResolution
public void enableSubPixelResolution() -
setIsCursor
public void setIsCursor(boolean isCursor) -
isCursor
public boolean isCursor() -
getDebugInfo
-
setRotationCenter
public void setRotationCenter(double x, double y) -
getHashCode
public int getHashCode()Returns a hashcode for this Roi that typically changes if it is moved, even though it is still the same object.
-