public class ShapeRoi extends Roi
ij.gui.Roi
(2D Regions Of Interest) implemented in terms of java.awt.Shape.
A ShapeRoi is constructed from a ij.gui.Roi
object, or as a result of logical operators
(i.e., union, intersection, exclusive or, and subtraction) provided by this class. These operators use the package
java.awt.geom
as a backend. ANGLE, asp_bk, aspect, cachedMask, center, clipboard, clipHeight, clipWidth, clipX, clipY, COMPOSITE, constrain, CONSTRUCTING, defaultColor, defaultFillColor, FERET_ARRAY_POINTOFFSET, FERET_ARRAYSIZE, fillColor, flattenScale, 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 and Description |
---|
ShapeRoi(float[] shapeArray)
Constructs a ShapeRoi from an array of variable length path segments.
|
ShapeRoi(int x,
int y,
java.awt.Shape s)
Constructs a ShapeRoi from a Shape.
|
ShapeRoi(Roi r)
Constructs a ShapeRoi from an Roi.
|
ShapeRoi(java.awt.Shape s)
Constructs a ShapeRoi from a Shape.
|
Modifier and Type | Method and Description |
---|---|
ShapeRoi |
and(ShapeRoi sr)
Unary intersection operator.
|
java.lang.Object |
clone()
Returns a deep copy of this.
|
boolean |
contains(int x,
int y)
Checks whether the center of the specified pixel inside of this ROI's shape boundaries.
|
boolean |
containsPoint(double x,
double y)
Returns whether coordinate (x,y) is contained in the Roi.
|
void |
draw(java.awt.Graphics g)
Non-destructively draws the shape of this object on the associated ImagePlus.
|
void |
drawPixels(ImageProcessor ip)
Draws the shape of this object onto the specified ImageProcessor.
|
void |
drawRoiBrush(java.awt.Graphics g) |
FloatPolygon |
getFloatConvexHull()
Returns the convex hull of this Roi as a FloatPolygon.
|
FloatPolygon |
getFloatPolygon()
Returns all vertex points of the shape as approximated by polygons,
in image pixel coordinates
|
FloatPolygon |
getFloatPolygon(double flatness,
boolean separateSubpaths,
boolean addPointForClose,
boolean absoluteCoord)
Returns a FloatPolygon with all vertices of the flattened shape, i.e., the shape approximated by
straight line segments.
|
FloatPolygon |
getFloatPolygon(java.awt.Shape shape,
double flatness,
boolean separateSubpaths,
boolean addPointForClose,
boolean absoluteCoord) |
FloatPolygon |
getFloatPolygon(java.lang.String options)
Returns all vertex points of the shape as approximated by polygons,
where options may include "close" to add points to close each subpath, and
"separate" to insert NaN values between subpaths (= individual polygons)
|
double |
getLength()
Returns the perimeter of this ShapeRoi.
|
ImageProcessor |
getMask()
Returns this ROI's mask pixels as a ByteProcessor with pixels "in" the mask
set to white (255) and pixels "outside" the mask set to black (0).
|
java.awt.Polygon |
getPolygon()
Returns the outline of this selection as a Polygon, or
null if this is a straight line selection.
|
Roi[] |
getRois()
Converts a Shape into Roi object(s).
|
FloatPolygon |
getSelectionCoordinates()
Used by the getSelectionCoordinates macro function
|
java.awt.Shape |
getShape()
Returns a reference to the Shape object encapsulated by this ShapeRoi.
|
float[] |
getShapeAsArray()
Retrieves the end points and control points of the path as a float array.
|
int |
isHandle(int sx,
int sy)
Always returns -1 since ShapeRois do not have handles.
|
ShapeRoi |
not(ShapeRoi sr)
Unary subtraction operator.
|
ShapeRoi |
or(ShapeRoi sr)
Unary union operator.
|
Roi |
shapeToRoi()
Attempts to convert this ShapeRoi into a single non-composite Roi.
|
int |
size()
Retuns the number of vertices, of this shape as approximated by straight lines.
|
Roi |
trySimplify()
Attempts to convert this ShapeRoi into a single non-composite Roi.
|
ShapeRoi |
xor(ShapeRoi sr)
Unary exclusive or operator.
|
abortModification, abortPaste, addRoiListener, clipRectMargin, convertLineToArea, convertToPolygon, copyAttributes, create, create, drawOverlay, drawPixels, enableSubPixelResolution, endPaste, equals, getAngle, getAngle, getAntiAlias, getBoundingRect, getBounds, getColor, getContainedFloatPoints, getContainedPoints, getContourCentroid, getConvexHull, getCornerDiameter, getCPosition, getCurrentPasteMode, getDebugInfo, getDefaultFillColor, getDefaultGroup, getDefaultHandleSize, getDefaultStrokeWidth, getDrawOffset, getFeretsDiameter, getFeretValues, getFillColor, getFloatAngle, getFloatBounds, getFloatHeight, getFloatWidth, getGroup, getGroupName, getGroupNames, getHandleSize, getHashCode, getImage, getImageID, getInterpolatedPolygon, getInterpolatedPolygon, getInterpolatedPolygon, getInverse, getListeners, getMagnification, getName, getPasteMode, getPosition, getPreviousRoi, getProperties, getProperty, getPropertyCount, getPrototypeOverlay, getRotationCenter, getRoundRectArcSize, getScaledStroke, getScaleStrokeWidth, getState, getStatistics, getStroke, getStrokeColor, getStrokeWidth, getTPosition, getType, getTypeAsString, getXBase, getYBase, getZPosition, grow, handleMouseDown, handleMouseDrag, handleMouseUp, hasHyperStackPosition, isActiveOverlayRoi, isArea, isCursor, isDrawingTool, isInteger, isLine, isLineOrPoint, isVisible, iterator, lineCircleIntersection, magnificationForSubPixel, magnificationForSubPixel, mouseDownInHandle, mouseDragged, mouseMoved, mouseReleased, moveHandle, notifyListeners, nudge, nudgeCorner, offScreenX, offScreenXD, offScreenY, offScreenYD, removeRoiListener, resetDefaultHandleSize, saveGroupNames, screenX, screenXD, screenY, screenYD, setAntiAlias, setBounds, setColor, setCornerDiameter, setDefaultColor, setDefaultFillColor, setDefaultGroup, setDefaultStrokeWidth, setDrawOffset, setFillColor, setFlattenScale, setGroup, setGroupName, setGroupNames, setHandleSize, setIgnoreClipRect, setImage, setInstanceColor, setIsCursor, setLineWidth, setLocation, setLocation, setName, setNonScalable, setPasteMode, setPosition, setPosition, setPosition, setPreviousRoi, setProperties, setProperty, setPrototypeOverlay, setRenderingHint, setRotationCenter, setRoundRectArcSize, setStroke, setStrokeColor, setStrokeWidth, setStrokeWidth, setUnscalableStrokeWidth, showStatus, startPaste, subPixelResolution, temporarilyHide, toFloat, toInt, toInt, toIntR, toString, update, updateClipRect, updateWideLine, useLineSubpixelConvention
public ShapeRoi(Roi r)
public ShapeRoi(java.awt.Shape s)
public ShapeRoi(int x, int y, java.awt.Shape s)
public ShapeRoi(float[] shapeArray)
public ShapeRoi or(ShapeRoi sr)
this
and sr
public ShapeRoi and(ShapeRoi sr)
this
and sr
public ShapeRoi xor(ShapeRoi sr)
this
and sr
public ShapeRoi not(ShapeRoi sr)
this
subtracted from sr
public Roi[] getRois()
Shape type | Roi class | Roi type |
---|---|---|
java.awt.geom.Rectangle2D.Double | ij.gui.Roi | Roi.RECTANGLE |
java.awt.geom.Ellipse2D.Double | ij.gui.OvalRoi | Roi.OVAL |
java.awt.geom.Line2D.Double | ij.gui.Line | Roi.LINE |
java.awt.Polygon | ij.gui.PolygonRoi | Roi.POLYGON |
java.awt.geom.GeneralPath
is converted following these rules:
Segment types | Number of segments |
Closed path | Value of forceAngle |
Value of forceTrace | Roi type |
---|---|---|---|---|---|
lines only: | 0 | ShapeRoi.NO_TYPE | |||
1 | ShapeRoi.NO_TYPE | ||||
2 | Y | ShapeRoi.NO_TYPE | |||
N | Roi.LINE | ||||
3 | Y | N | Roi.POLYGON | ||
N | Y | Roi.ANGLE | |||
N | N | Roi.POLYLINE | |||
4 | Y | Roi.RECTANGLE | |||
N | Roi.POLYLINE | ||||
<= MAXPOLY | Y | Roi.POLYGON | |||
N | Roi.POLYLINE | ||||
> MAXPOLY | Y | Y | Roi.TRACED_ROI | ||
N | Roi.FREEROI | ||||
N | Roi.FREELINE | ||||
anything else: | <= 2 | ShapeRoi.NO_TYPE | |||
> 2 | ShapeRoi.SHAPE_ROI |
public Roi shapeToRoi()
public Roi trySimplify()
public boolean contains(int x, int y)
public boolean containsPoint(double x, double y)
containsPoint
in class Roi
public double getLength()
public float[] getShapeAsArray()
public void draw(java.awt.Graphics g)
public void drawRoiBrush(java.awt.Graphics g)
public void drawPixels(ImageProcessor ip)
drawPixels
in class Roi
ImageProcessor.setColor(java.awt.Color)
,
ImageProcessor.setLineWidth(int)
public ImageProcessor getMask()
public java.awt.Shape getShape()
public int isHandle(int sx, int sy)
public FloatPolygon getSelectionCoordinates()
public FloatPolygon getFloatPolygon(double flatness, boolean separateSubpaths, boolean addPointForClose, boolean absoluteCoord)
flatness
- Roughly the maximum allowable distance between the shape and the approximate polygonseparateSubpaths
- whether individual subpaths should be separated by NaN coordinatesaddPointForClose
- whether the starting point of a closed subpath should be repeated at its end.
Note that with addPointForClose = false
, there is no distinction between open and closed subpaths.absoluteCoord
- specifies whether the coordinates should be with respect to image bounds, not Roi bounds.public FloatPolygon getFloatPolygon(java.awt.Shape shape, double flatness, boolean separateSubpaths, boolean addPointForClose, boolean absoluteCoord)
public FloatPolygon getFloatConvexHull()
Roi
getFloatConvexHull
in class Roi
public java.awt.Polygon getPolygon()
Roi
getPolygon
in class Roi
ImageProcessor.setRoi(java.awt.Rectangle)
,
ImageProcessor.drawPolygon(java.awt.Polygon)
,
ImageProcessor.fillPolygon(java.awt.Polygon)
public FloatPolygon getFloatPolygon()
getFloatPolygon
in class Roi
public FloatPolygon getFloatPolygon(java.lang.String options)
getFloatPolygon
in class Roi