Package ij.gui
Class PolygonRoi
java.lang.Object
ij.gui.Roi
ij.gui.PolygonRoi
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
EllipseRoi
,FreehandRoi
,PointRoi
This class represents a polygon region of interest or polyline of interest.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected int
protected int
protected int[]
protected int[]
protected float[]
protected float[]
protected int[]
protected int[]
protected float[]
protected float[]
Fields inherited from class ij.gui.Roi
ANGLE, asp_bk, aspect, cachedMask, center, clipboard, clipHeight, clipWidth, clipX, clipY, COMPOSITE, constrain, CONSTRUCTING, defaultFillColor, fillColor, FREELINE, FREEROI, HANDLE_SIZE, handleColor, ic, ignoreClipRect, imp, instanceColor, LINE, lineWidth, mag, MOVING, MOVING_HANDLE, nonScalable, NORMAL, NOT_PASTING, oldHeight, oldWidth, oldX, oldY, onePixelWide, OVAL, overlay, pasteMode, POINT, POLYGON, POLYLINE, previousRoi, RECTANGLE, RESIZING, ROIColor, stroke, strokeColor, TRACED_ROI, type, updateFullWindow, wideLine, xMax, yMax
-
Constructor Summary
ConstructorsConstructorDescriptionPolygonRoi
(float[] xPoints, float[] yPoints, int type) Creates a new polygon or polyline ROI from float x and y arrays.PolygonRoi
(float[] xPoints, float[] yPoints, int nPoints, int type) Creates a new polygon or polyline ROI from float x and y arrays.PolygonRoi
(int[] xPoints, int[] yPoints, int nPoints, int type) Creates a new polygon or polyline ROI from x and y coordinate arrays.PolygonRoi
(int[] xPoints, int[] yPoints, int nPoints, ImagePlus imp, int type) Deprecated.PolygonRoi
(int sx, int sy, ImagePlus imp) Starts the process of creating a new user-generated polygon or polyline ROI.PolygonRoi
(FloatPolygon p, int type) Creates a new polygon or polyline ROI from a FloatPolygon.PolygonRoi
(Polygon p, int type) Creates a new polygon or polyline ROI from a Polygon. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected int
clone()
Returns a copy of this PolygonRoi.boolean
contains
(int x, int y) void
deleteHandle
(double ox, double oy) protected void
deletePoint
(int index) void
void
Draws the selection outline on the specified ImageProcessor.void
void
void
void
fitSpline
(int evaluationPoints) void
double
getAngle()
Returns the angle in degrees between the first two segments of this polyline.Uses the gift wrap algorithm to find the convex hull and returns it as a Polygon.boolean
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..Returns this polygon or polyline as float arrays.getInterpolatedPolygon
(double interval, boolean smooth) Returns, as a FloatPolygon, an interpolated version of this selection with points spaced 'interval' pixels apart.double
Returns the perimeter (for ROIs) or length (for lines).getMask()
Always returns null for rectangular Roi'sint
Returns the number of points that define this PolygonRoi.Returns this PolygonRoi as a Polygon.double
int[]
Obsolete; replaced by either getPolygon() or getFloatPolygon().int[]
Obsolete; replaced by either getPolygon() or getFloatPolygon().protected void
grow
(int sx, int sy) protected void
handleMouseUp
(int sx, int sy) With segmented selections, ignore first mouse up and finalize when user double-clicks, control-clicks or clicks in start box.int
isHandle
(int sx, int sy) Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1.boolean
Returns 'true' if this selection has been fitted with a spline.protected void
mouseDownInHandle
(int handle, int sx, int sy) void
protected void
moveHandle
(int sx, int sy) void
void
setDrawOffset
(boolean drawOffset) void
setLocation
(double x, double y) Set the location of the ROI in image coordinates.boolean
Returns true if this is a slection that supports sub-pixel resolution.protected void
protected void
wipeBack()
Methods inherited from class ij.gui.Roi
abortPaste, addRoiListener, copyAttributes, drawOverlay, drawPixels, endPaste, equals, getAngle, getBoundingRect, getBounds, getColor, getContourCentroid, getCornerDiameter, getCPosition, getCurrentPasteMode, getDefaultFillColor, getFeretsDiameter, getFeretValues, getFillColor, getFloatAngle, getFloatBounds, getFloatHeight, getFloatWidth, getHashCode, getImage, getImageID, getInterpolatedPolygon, getInterpolatedPolygon, getMagnification, getName, getPasteMode, getPosition, getProperties, getProperty, getPropertyCount, getPrototypeOverlay, getRotationCenter, getRoundRectArcSize, getScaledStroke, getState, getStatistics, getStroke, getStrokeColor, getStrokeWidth, getTPosition, getType, getTypeAsString, getXBase, getYBase, getZPosition, handleMouseDown, handleMouseDrag, isActiveOverlayRoi, isArea, isCursor, isDrawingTool, isLine, isVisible, lineCircleIntersection, mouseDragged, mouseReleased, notifyListeners, nudge, nudgeCorner, removeRoiListener, screenX, screenXD, screenY, screenYD, setColor, setCornerDiameter, setDefaultFillColor, setFillColor, setIgnoreClipRect, setImage, setInstanceColor, setIsCursor, setLineWidth, setLocation, setName, setNonScalable, setPasteMode, setPosition, setPosition, setProperties, setProperty, setPrototypeOverlay, setRotationCenter, setRoundRectArcSize, setStroke, setStrokeColor, setStrokeWidth, setStrokeWidth, showStatus, startPaste, temporarilyHide, toFloat, toInt, toInt, toIntR, toString, update, updateClipRect, updateWideLine
-
Field Details
-
maxPoints
protected int maxPoints -
xp
protected int[] xp -
yp
protected int[] yp -
xpf
protected float[] xpf -
ypf
protected float[] ypf -
xp2
protected int[] xp2 -
yp2
protected int[] yp2 -
nPoints
protected int nPoints -
xSpline
protected float[] xSpline -
ySpline
protected float[] ySpline -
splinePoints
protected int splinePoints
-
-
Constructor Details
-
PolygonRoi
public PolygonRoi(int[] xPoints, int[] yPoints, int nPoints, int type) Creates a new polygon or polyline ROI from x and y coordinate arrays. Type must be Roi.POLYGON, Roi.FREEROI, Roi.TRACED_ROI, Roi.POLYLINE, Roi.FREELINE or Roi.ANGLE. -
PolygonRoi
public PolygonRoi(float[] xPoints, float[] yPoints, int nPoints, int type) Creates a new polygon or polyline ROI from float x and y arrays. Type must be Roi.POLYGON, Roi.FREEROI, Roi.POLYLINE, Roi.FREELINE or Roi.ANGLE. -
PolygonRoi
public PolygonRoi(float[] xPoints, float[] yPoints, int type) Creates a new polygon or polyline ROI from float x and y arrays. Type must be Roi.POLYGON, Roi.FREEROI, Roi.POLYLINE, Roi.FREELINE or Roi.ANGLE. -
PolygonRoi
Creates a new polygon or polyline ROI from a Polygon. Type must be Roi.POLYGON, Roi.FREEROI, Roi.TRACED_ROI, Roi.POLYLINE, Roi.FREELINE or Roi.ANGLE. -
PolygonRoi
Creates a new polygon or polyline ROI from a FloatPolygon. Type must be Roi.POLYGON, Roi.FREEROI, Roi.TRACED_ROI, Roi.POLYLINE, Roi.FREELINE or Roi.ANGLE. -
PolygonRoi
Deprecated. -
PolygonRoi
Starts the process of creating a new user-generated polygon or polyline ROI.
-
-
Method Details
-
draw
-
drawPixels
Description copied from class:Roi
Draws the selection outline on the specified ImageProcessor.- Overrides:
drawPixels
in classRoi
- See Also:
-
grow
protected void grow(int sx, int sy) -
updatePolygon
protected void updatePolygon() -
mouseMoved
- Overrides:
mouseMoved
in classRoi
-
wipeBack
protected void wipeBack() -
exitConstructingMode
public void exitConstructingMode() -
moveHandle
protected void moveHandle(int sx, int sy) - Overrides:
moveHandle
in classRoi
-
mouseDownInHandle
protected void mouseDownInHandle(int handle, int sx, int sy) - Overrides:
mouseDownInHandle
in classRoi
-
deleteHandle
public void deleteHandle(double ox, double oy) -
deletePoint
protected void deletePoint(int index) -
fitSpline
public void fitSpline(int evaluationPoints) -
fitSpline
public void fitSpline() -
removeSplineFit
public void removeSplineFit() -
isSplineFit
public boolean isSplineFit()Returns 'true' if this selection has been fitted with a spline. -
fitSplineForStraightening
public void fitSplineForStraightening() -
getUncalibratedLength
public double getUncalibratedLength() -
handleMouseUp
protected void handleMouseUp(int sx, int sy) With segmented selections, ignore first mouse up and finalize when user double-clicks, control-clicks or clicks in start box.- Overrides:
handleMouseUp
in classRoi
-
addOffset
protected void addOffset() -
contains
public boolean contains(int x, int y) -
isHandle
public int isHandle(int sx, int sy) Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1. -
getMask
Description copied from class:Roi
Always returns null for rectangular Roi's -
getLength
public double getLength()Returns the perimeter (for ROIs) or length (for lines). -
getAngle
public double getAngle()Returns the angle in degrees between the first two segments of this polyline. -
getNCoordinates
public int getNCoordinates()Returns the number of points that define this PolygonRoi.- See Also:
-
getXCoordinates
public int[] getXCoordinates()Obsolete; replaced by either getPolygon() or getFloatPolygon(). -
getYCoordinates
public int[] getYCoordinates()Obsolete; replaced by either getPolygon() or getFloatPolygon(). -
getNonSplineCoordinates
-
getNonSplineFloatPolygon
-
getPolygon
Returns this PolygonRoi as a Polygon. -
getFloatPolygon
Returns this polygon or polyline as float arrays.- Overrides:
getFloatPolygon
in classRoi
-
subPixelResolution
public boolean subPixelResolution()Description copied from class:Roi
Returns true if this is a slection that supports sub-pixel resolution.- Overrides:
subPixelResolution
in classRoi
-
getConvexHull
Uses the gift wrap algorithm to find the convex hull and returns it as a Polygon.- Overrides:
getConvexHull
in classRoi
-
getInterpolatedPolygon
Description copied from class:Roi
Returns, as a FloatPolygon, an interpolated version of this selection with points spaced 'interval' pixels apart. If 'smooth' is true, traced and freehand selections are first smoothed using a 3 point running average.- Overrides:
getInterpolatedPolygon
in classRoi
-
clipRectMargin
protected int clipRectMargin()- Overrides:
clipRectMargin
in classRoi
-
clone
Returns a copy of this PolygonRoi. -
getDrawOffset
public boolean getDrawOffset()Description copied from class:Roi
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..- Overrides:
getDrawOffset
in classRoi
-
setDrawOffset
public void setDrawOffset(boolean drawOffset) - Overrides:
setDrawOffset
in classRoi
-
setLocation
public void setLocation(double x, double y) Description copied from class:Roi
Set the location of the ROI in image coordinates.- Overrides:
setLocation
in classRoi
-
enableSubPixelResolution
public void enableSubPixelResolution()- Overrides:
enableSubPixelResolution
in classRoi
-
getDebugInfo
- Overrides:
getDebugInfo
in classRoi
-