ij.gui
Class PolygonRoi

java.lang.Object
  extended by ij.gui.AbstractRoi
      extended by ij.gui.AttributeRoi
          extended by ij.gui.Roi
              extended by ij.gui.PolygonRoi
All Implemented Interfaces:
RoiBeans, RoiConstance, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
EllipseRoi, FreehandRoi, PointRoi

public class PolygonRoi
extends Roi

This class represents a polygon region of interest or polyline of interest.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class ij.gui.Roi
onePixelWide, previousRoi, roundRect
 
Fields inherited from interface ij.gui.RoiConstance
ADD_TO_ROI, ANGLE, COMPOSITE, CONSTRUCTING, DRAW_HANDLE, DUPLICATE_HANDLE, EVT_HANDLE_SIZE, FILL_HANDLE, FREELINE, FREEROI, HANDLE_SIZE, LINE, MAG_HANDLE, MOVING, MOVING_HANDLE, MOVING_ROUNDRECT_HANDLE, NO_MODS, NORMAL, NOT_PASTING, OVAL, POINT, POLYGON, POLYLINE, RECTANGLE, RESIZING, SUBTRACT_FROM_ROI, TRACED_ROI, UNDO_HANDLE
 
Constructor Summary
PolygonRoi(float[] xPoints, float[] yPoints, int nPoints, int type)
          Creates a new polygon or polyline ROI from float x and y arrays.
PolygonRoi(FloatPolygon p, int type)
          Creates a new polygon or polyline ROI from a FloatPolygon.
PolygonRoi(int[] xPoints, int[] yPoints, int nPoints, ImagePlus imp, int type)
          Deprecated.  
PolygonRoi(int[] xPoints, int[] yPoints, int nPoints, int type)
          Creates a new polygon or polyline ROI from x and y coordinate arrays.
PolygonRoi(int sx, int sy, ImagePlus imp)
          Starts the process of creating a new user-generated polygon or polyline ROI.
PolygonRoi(java.awt.Polygon p, int type)
          Creates a new polygon or polyline ROI from a Polygon.
 
Method Summary
 java.lang.Object clone()
          Returns a copy of this PolygonRoi.
 boolean contains(int x, int y)
           
 void deleteHandle(double ox, double oy)
           
 void draw(java.awt.Graphics g)
           
 void drawPixels(ImageProcessor ip)
          Draws the selection outline on the specified ImageProcessor.
 void exitConstructingMode()
           
 void fitSpline()
           
 void fitSpline(int evaluationPoints)
           
 void fitSplineForStraightening()
           
 double getAngle()
          Returns the angle in degrees between the first two segments of this polyline.
 java.awt.Polygon getConvexHull()
          Uses the gift wrap algorithm to find the convex hull and returns it as a Polygon.
 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..
 FloatPolygon getFloatPolygon()
          Returns this polygon or polyline as float arrays.
 double getLength()
          Returns the perimeter (for ROIs) or length (for lines).
 ImageProcessor getMask()
          Override Roi.nudge() to support splines.
 int getNCoordinates()
          Returns the number of XY coordinates.
 java.awt.Polygon getNonSplineCoordinates()
           
 FloatPolygon getNonSplineFloatCoordinates()
           
 java.awt.Polygon getPolygon()
          Returns this PolygonRoi as a Polygon.
 double getUncalibratedLength()
           
 int[] getXCoordinates()
          Obsolete; replaced by either getPolygon() or getFloatPolygon().
 int[] getYCoordinates()
          Obsolete; replaced by either getPolygon() or getFloatPolygon().
 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 isSplineFit()
          Returns 'true' if this selection has been fitted with a spline.
 void removeSplineFit()
           
 void setDrawOffset(boolean drawOffset)
           
 boolean subPixelResolution()
          Returns true if this is a PolygonRoi that supports sub-pixel resolution.
 
Methods inherited from class ij.gui.Roi
abortPaste, appRoiHandle, drawfillOverlay, drawHandle, drawOverlay, drawPixels, drawPixels, drawRoiHandle, drawStroke, endPaste, equals, fillRoiHandle, getBoundingRect, getBounds, getCornerDiameter, getCurrentPasteMode, getFloatBounds, getHandleSize, getPasteMode, getPrototypeOverlay, getRoundRectArcSize, getState, getTypeAsString, isArea, isDrawingTool, isLine, isVisible, magRoiHandle, nudge, nudgeCorner, setCornerDiameter, setImage, setInstanceColor, setLineWidth, setLocation, setNonScalable, setPasteMode, setPrototypeOverlay, setRoundRectArcSize, startPaste, temporarilyHide, toFloat, toInt, toInt, toIntR, toString, undoRoiHandle, update, updateWideLine
 
Methods inherited from class ij.gui.AttributeRoi
copyAttributes, getAngle, getColor, getCPosition, getDefaultFillColor, getFeretsDiameter, getFeretValues, getFillColor, getImage, getImageID, getName, getPosition, getStroke, getStrokeColor, getStrokeWidth, getTPosition, getType, getZPosition, setColor, setDefaultFillColor, setFillColor, setName, setPosition, setPosition, setStroke, setStrokeColor, setStrokeWidth, setStrokeWidth
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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(java.awt.Polygon p,
                  int type)
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

public PolygonRoi(FloatPolygon p,
                  int type)
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

public PolygonRoi(int[] xPoints,
                  int[] yPoints,
                  int nPoints,
                  ImagePlus imp,
                  int type)
Deprecated. 


PolygonRoi

public PolygonRoi(int sx,
                  int sy,
                  ImagePlus imp)
Starts the process of creating a new user-generated polygon or polyline ROI.

Method Detail

draw

public void draw(java.awt.Graphics g)
Specified by:
draw in interface RoiBeans
Overrides:
draw in class Roi

drawPixels

public void drawPixels(ImageProcessor ip)
Description copied from class: Roi
Draws the selection outline on the specified ImageProcessor.

Specified by:
drawPixels in interface RoiBeans
Overrides:
drawPixels in class Roi
See Also:
ImageProcessor.setColor(java.awt.Color), ImageProcessor.setLineWidth(int)

exitConstructingMode

public void exitConstructingMode()

deleteHandle

public void deleteHandle(double ox,
                         double oy)

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()

contains

public boolean contains(int x,
                        int y)
Specified by:
contains in interface RoiBeans
Overrides:
contains in class Roi

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.

Specified by:
isHandle in interface RoiBeans
Overrides:
isHandle in class Roi

getMask

public ImageProcessor getMask()
Override Roi.nudge() to support splines.

Specified by:
getMask in interface RoiBeans
Overrides:
getMask in class Roi

getLength

public double getLength()
Returns the perimeter (for ROIs) or length (for lines).

Specified by:
getLength in interface RoiBeans
Overrides:
getLength in class Roi

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 XY coordinates.


getXCoordinates

public int[] getXCoordinates()
Obsolete; replaced by either getPolygon() or getFloatPolygon().


getYCoordinates

public int[] getYCoordinates()
Obsolete; replaced by either getPolygon() or getFloatPolygon().


getNonSplineCoordinates

public java.awt.Polygon getNonSplineCoordinates()

getNonSplineFloatCoordinates

public FloatPolygon getNonSplineFloatCoordinates()

getPolygon

public java.awt.Polygon getPolygon()
Returns this PolygonRoi as a Polygon.

Specified by:
getPolygon in interface RoiBeans
Overrides:
getPolygon in class Roi
See Also:
ImageProcessor.setRoi(java.awt.Rectangle), ImageProcessor.drawPolygon(java.awt.Polygon), ImageProcessor.fillPolygon(java.awt.Polygon)

getFloatPolygon

public FloatPolygon getFloatPolygon()
Returns this polygon or polyline as float arrays.

Specified by:
getFloatPolygon in interface RoiBeans
Overrides:
getFloatPolygon in class Roi

subPixelResolution

public boolean subPixelResolution()
Description copied from class: Roi
Returns true if this is a PolygonRoi that supports sub-pixel resolution.

Specified by:
subPixelResolution in interface RoiBeans
Overrides:
subPixelResolution in class Roi

getConvexHull

public java.awt.Polygon getConvexHull()
Uses the gift wrap algorithm to find the convex hull and returns it as a Polygon.

Specified by:
getConvexHull in interface RoiBeans
Overrides:
getConvexHull in class AttributeRoi

clone

public java.lang.Object clone()
Returns a copy of this PolygonRoi.

Overrides:
clone in class Roi

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..

Specified by:
getDrawOffset in interface RoiBeans
Overrides:
getDrawOffset in class Roi

setDrawOffset

public void setDrawOffset(boolean drawOffset)
Specified by:
setDrawOffset in interface RoiBeans
Overrides:
setDrawOffset in class Roi