: Class Polygon

Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## Class Polygon

    java.lang.Object
      |
      +--java.awt.Polygon
            |
            +--Polygon

class Polygon
extends java.awt.Polygon
implements GeometricObject

This class represents a polygon described by its vertices. The polygon is closed by defauly (ie the last point is not connected to the first one.

See Also:
  Serialized Form

Inner classes inherited from class java.awt.Polygon
`java.awt.Polygon.PolygonPathIterator`

Field Summary
`java.awt.Graphics` | `graphics` Graphics context for this Geometric object.
`private Polygon` | `points` The original data points
`long` | `time_stamp` Time stamp of this object.

Fields inherited from class java.awt.Polygon
`bounds, npoints, serialVersionUID, xpoints, ypoints`

Fields inherited from interface GeometricObject
`CIRCLE, ELLIPSE, LINE, POINT, POLYGON, RECTANGLE, SQUARE`

Constructor Summary
`(package private)` | `Polygon()` The constructor.
`(package private)` | `Polygon(int[] xpoints, int[] ypoints, int npoints)` The constructor.
`(package private)` | `Polygon(Line line)` The constructor.
`(package private)` | `Polygon(Point[] points)` The constructor.
`(package private)` | `Polygon(java.awt.Polygon p)` The constructor.
`(package private)` | `Polygon(Polygon p)` The constructor.

Method Summary
`void` | `addPointDouble(double x, double y)` add point for doubles
`int` | `closestNeighborIndex(Point p)` Returns the index of the vertices that is closest to point p.
`boolean` | `containsGeometricObject(GeometricObject object)` Returns false if the argument is not completely inside this object.
`boolean` | `containsGeometricObjects(GeometricObject[] objects)` Returns false if the objects in the input array are completely inside this object.
`void` | `drawAngleAt(int i, Point reference_point)` Draws an arc (angle) on the ith vertex (start from 0) using the current graphics context.
`double[]` | `getAbsoluteAngles()` Returns an array containing the angles that each edge makes with the x axis.
`double[]` | `getAbsolutePositiveAngles()` Returns an array containing the angles that each edge makes with the x axis.
`Polygon` | `getDataPoints()` This method is used to get the original data points that forms this GeometricObject
`Line` | `getEdge(int n)` This method returns the nth edge of this Polygon.
`java.awt.Rectangle` | `getHorizontalBounds()` Supplied for completeness.
`double[]` | `getMajorAngles()` Return the major angles in this polygon
`Polygon` | `getPolygonalBounds()` This method should return a polygon that fully contains the current object.
`Rectangle` | `getRectangularBounds()` Supplied for completeness.
`Rectangle` | `getRectangularBounds(int steps)` Supplied for completeness.
`long` | `getTimeStamp()` Returns the time stamp of the current Terminal
`java.lang.String` | `getType()` Implement GeometricObject
`void` | `normalize(double[] angle_set)` Normalize the polygon edges so that the angles they make with the x axis are chosen from the given angle set.
`void` | `paint()` Draw the object
`void` | `paint(java.awt.Graphics g)` Draw the object
`void` | `paintOriginal(java.awt.Graphics g)` This method is used to paint the original data points that forms this GeometricObject
`Point` | `pointAt(int i)` Returns the ith point in this Polygon
`boolean` | `pointIsOn(Point p, int radius)` Returns true if the point is within +-radius distance from the curve defining the object.
`boolean` | `pointIsOnOriginal(Point p, int radius)` Returns true if the point is within +-radius distance from the original curve defining the object.
`void` | `rotate(double theta)` This method rotates the polygon by theta radians CCW.
`void` | `setDataPoints(Polygon points)` This method is used to set the original data points that forms this GeometricObject
`void` | `setGraphicsContext(java.awt.Graphics g)` Set graphics context for this Geometric object.
`void` | `setTimeStamp(long time_stamp)` Sets the time stamp of the current Terminal
`int` | `spatialRelation(GeometricObject object)` This method should return the spatial relation of the input parameter with respect to this object.
`java.lang.String` | `toString()` Override toString
`boolean` | `touches(GeometricObject object)` This method should return true if the input objects touch.
`boolean` | `tryCombining(java.lang.Object o, int tolerance)` Try combining the input object with this Polygon.

Methods inherited from class java.awt.Polygon
`addPoint, calculateBounds, contains, contains, contains, contains, contains, contains, getBoundingBox, getBounds, getBounds2D, getCrossings, getPathIterator, getPathIterator, inside, intersects, intersects, translate, updateBounds`

Methods inherited from class java.lang.Object
`, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait`

Field Detail

### points

    private Polygon points

  The original data points

### time_stamp

    public long time_stamp

  Time stamp of this object.

### graphics

    public java.awt.Graphics graphics

  Graphics context for this Geometric object.

Constructor Detail

### Polygon

    Polygon()

  The constructor.

### Polygon

    Polygon(java.awt.Polygon p)

  The constructor.

### Polygon

    Polygon(Point[] points)

  The constructor.

### Polygon

    Polygon(int[] xpoints,
            int[] ypoints,
            int npoints)

  The constructor.

### Polygon

    Polygon(Polygon p)

  The constructor.

### Polygon

    Polygon(Line line)

  The constructor.

Method Detail

### getType

    public java.lang.String getType()

  Implement GeometricObject

### addPointDouble

    public void addPointDouble(double x,
                               double y)

  add point for doubles

### toString

    public java.lang.String toString()

  Override toString
  Overrides:
    toString in class java.lang.Object

### paint

    public void paint()

  Draw the object

### paintOriginal

    public void paintOriginal(java.awt.Graphics g)

  This method is used to paint the original data points that forms this GeometricObject

### paint

    public void paint(java.awt.Graphics g)

  Draw the object

### pointIsOn

    public boolean pointIsOn(Point p,
                             int radius)

  Returns true if the point is within +-radius distance from the curve defining the object. Returns false o/w.
  Specified by:
    pointIsOn in interface GeometricObject

### pointIsOnOriginal

    public boolean pointIsOnOriginal(Point p,
                                     int radius)

  Returns true if the point is within +-radius distance from the original curve defining the object. Returns false o/w.
  Specified by:
    pointIsOnOriginal in interface GeometricObject

### closestNeighborIndex

    public int closestNeighborIndex(Point p)

  Returns the index of the vertices that is closest to point p.

### pointAt

    public Point pointAt(int i)

  Returns the ith point in this Polygon

### drawAngleAt

    public void drawAngleAt(int i,
                            Point reference_point)

  Draws an arc (angle) on the ith vertex (start from 0) using the current graphics context. Point p is used to determine which angle to paint ( internal or external ). Cosine theorem is applied here.

### setGraphicsContext

    public void setGraphicsContext(java.awt.Graphics g)

  Set graphics context for this Geometric object. Must be set at least once before doing any drawing.

### touches

    public boolean touches(GeometricObject object)

  This method should return true if the input objects touch. It should be optimized making use of the object type information.
  Specified by:
    touches in interface GeometricObject

### getHorizontalBounds

    public java.awt.Rectangle getHorizontalBounds()

  Supplied for completeness. Returns the bounding box with the smallest perimeter for steps = 9

### getRectangularBounds

    public Rectangle getRectangularBounds()

  Supplied for completeness. Returns the bounding box with the smallest perimeter for steps = 9
  Specified by:
    getRectangularBounds in interface GeometricObject

### containsGeometricObject

    public boolean containsGeometricObject(GeometricObject object)

  Returns false if the argument is not completely inside this object. Return true O/W.
  Specified by:
    containsGeometricObject in interface GeometricObject

### getRectangularBounds

    public Rectangle getRectangularBounds(int steps)

  Supplied for completeness. Returns the bounding box with the smallest perimeter for step angles of Math.PI/(2*steps) Should be optimized further. Should always return a Rectangle with an angle between 0.0 and Math.PI/2

### getEdge

    public Line getEdge(int n)

  This method returns the nth edge of this Polygon.

### getPolygonalBounds

    public Polygon getPolygonalBounds()

  This method should return a polygon that fully contains the current object. The polygon is implicity closed and the last point doesn't necessarily have to be the same as the first (zeroth) point.
  Specified by:
    getPolygonalBounds in interface GeometricObject

### rotate

    public void rotate(double theta)

  This method rotates the polygon by theta radians CCW.

### spatialRelation

    public int spatialRelation(GeometricObject object)

  This method should return the spatial relation of the input parameter with respect to this object. see the SpatialRelation class for a detailed list of possible spatial relations. Another version of this method should be implemented for handling spatial relations where a rotated coordinate system is to be used.
  Specified by:
    spatialRelation in interface GeometricObject

### setTimeStamp

    public void setTimeStamp(long time_stamp)

  Sets the time stamp of the current Terminal

### getTimeStamp

    public long getTimeStamp()

  Returns the time stamp of the current Terminal

### setDataPoints

    public void setDataPoints(Polygon points)

  This method is used to set the original data points that forms this GeometricObject
  Specified by:
    setDataPoints in interface GeometricObject

### getDataPoints

    public Polygon getDataPoints()

  This method is used to get the original data points that forms this GeometricObject
  Specified by:
    getDataPoints in interface GeometricObject

### containsGeometricObjects

    public boolean containsGeometricObjects(GeometricObject[] objects)

  Returns false if the objects in the input array are completely inside this object. Return true O/W.
  Specified by:
    containsGeometricObjects in interface GeometricObject

### getAbsoluteAngles

    public double[] getAbsoluteAngles()

  Returns an array containing the angles that each edge makes with the x axis.

### getAbsolutePositiveAngles

    public double[] getAbsolutePositiveAngles()

  Returns an array containing the angles that each edge makes with the x axis.

### tryCombining

    public boolean tryCombining(java.lang.Object o,
                                int tolerance)

  Try combining the input object with this Polygon. Return true is successful, false O/W. The input object may be a Line or a Polygon Two Polygons are combinable if their end points are sufficiently close to each other (determined by the tolerance).

### getMajorAngles

    public double[] getMajorAngles()

  Return the major angles in this polygon

### normalize

    public void normalize(double[] angle_set)

  Normalize the polygon edges so that the angles they make with the x axis are chosen from the given angle set.

Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD