Module ij
Package ij.process

Class FloatPolygon

java.lang.Object
ij.process.FloatPolygon

public class FloatPolygon
extends java.lang.Object
Used by the Roi classes to return float coordinate arrays and to determine if a point is inside or outside of spline fitted selections.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    int npoints
    The number of points.
    float[] xpoints  
    float[] ypoints  
  • Constructor Summary

    Constructors 
    Constructor Description
    FloatPolygon()
    Constructs an empty FloatPolygon.
    FloatPolygon​(float[] xpoints, float[] ypoints)
    Constructs a FloatPolygon from x and y arrays.
    FloatPolygon​(float[] xpoints, float[] ypoints, int npoints)
    Constructs a FloatPolygon from x and y arrays.
  • Method Summary

    Modifier and Type Method Description
    void addPoint​(double x, double y)  
    void addPoint​(float x, float y)  
    boolean contains​(double x, double y)
    Returns 'true' if the point (x,y) is inside this polygon.
    boolean contains​(float x, float y)
    A version of contains() that accepts float arguments.
    FloatPolygon duplicate()  
    java.awt.Rectangle getBounds()  
    FloatPolygon getConvexHull()
    Uses the gift wrap algorithm to find the convex hull of all points in this FloatPolygon and returns it as a new FloatPolygon.
    java.awt.geom.Rectangle2D.Double getFloatBounds()  
    double getLength​(boolean isLine)  
    java.lang.String toString()  
    void translate​(double x, double y)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • npoints

      public int npoints
      The number of points.
    • xpoints

      public float[] xpoints
    • ypoints

      public float[] ypoints
  • Constructor Details

    • FloatPolygon

      public FloatPolygon()
      Constructs an empty FloatPolygon.
    • FloatPolygon

      public FloatPolygon​(float[] xpoints, float[] ypoints)
      Constructs a FloatPolygon from x and y arrays.
    • FloatPolygon

      public FloatPolygon​(float[] xpoints, float[] ypoints, int npoints)
      Constructs a FloatPolygon from x and y arrays.
  • Method Details

    • contains

      public boolean contains​(double x, double y)
      Returns 'true' if the point (x,y) is inside this polygon. This is a Java version of the remarkably small C program by W. Randolph Franklin at http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html#The%20C%20Code In the absence of numerical errors, x coordinates exactly at a boundary are taken as if in the area immediately at the left of the boundary. For horizontal boundaries, y coordinates exactly at the border are taken as if in the area immediately above it (i.e., in decreasing y direction). The ImageJ convention of an offset of 0.5 pixels between pixel centers and outline coordinates is not taken into consideration; this method returns the purely geometrical relationship.
    • contains

      public boolean contains​(float x, float y)
      A version of contains() that accepts float arguments.
    • getBounds

      public java.awt.Rectangle getBounds()
    • getFloatBounds

      public java.awt.geom.Rectangle2D.Double getFloatBounds()
    • addPoint

      public void addPoint​(float x, float y)
    • addPoint

      public void addPoint​(double x, double y)
    • duplicate

      public FloatPolygon duplicate()
    • getLength

      public double getLength​(boolean isLine)
    • getConvexHull

      public FloatPolygon getConvexHull()
      Uses the gift wrap algorithm to find the convex hull of all points in this FloatPolygon and returns it as a new FloatPolygon. The sequence of the points on the convex hull is counterclockwise.
    • translate

      public void translate​(double x, double y)
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object