|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.awt.Polygon
|
+--edu.mit.sketch.geom.Polygon
This class represents a polygon described by its vertices. The polygon should be closed explicitly if needed.
| Field Summary | |
Graphics |
graphics
Graphics context for this Geometric object. |
long |
time_stamp
Time stamp of this object. |
| Fields inherited from class java.awt.Polygon |
bounds, npoints, xpoints, ypoints |
| Fields inherited from interface edu.mit.sketch.geom.GeometricObject |
CIRCLE, ELLIPSE, LINE, POINT, POLYGON, RECTANGLE, SQUARE |
| Constructor Summary | |
Polygon()
The constructor. |
|
Polygon(int[] xpoints,
int[] ypoints,
int npoints)
The constructor. |
|
Polygon(Point[] points)
The constructor. |
|
Polygon(Polygon p)
The constructor. |
|
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. |
void |
combineEndPoints(double error)
Combines the ends of the polygon if they are sufficiently close. |
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 |
copyVerticesFrom(Polygon p)
Copy the vertices. |
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. |
double |
getAngle(int n)
get the nth angle as a positive value between 0 and 2*PI |
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. |
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 |
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(Graphics g)
Draw the object |
void |
paintOriginal(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 |
rotateAboutCOM(double theta)
This method rotates the polygon by theta radians CCW. |
void |
rotateAboutOrigin(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(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. |
String |
toString()
Override toString |
boolean |
touches(GeometricObject object)
This method should return true if the input objects touch. |
void |
translate(double x,
double y)
Add the arguments to the (x, y) position of the object. |
boolean |
tryCombining(Object o,
int tolerance)
Try combining the input object with this Polygon. |
| Methods inherited from class java.awt.Polygon |
addPoint, contains, contains, contains, contains, contains, contains, getBoundingBox, getBounds, getBounds2D, getPathIterator, getPathIterator, inside, intersects, intersects, translate |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public long time_stamp
public transient Graphics graphics
| Constructor Detail |
public Polygon()
public Polygon(Polygon p)
public Polygon(Point[] points)
public Polygon(int[] xpoints,
int[] ypoints,
int npoints)
public Polygon(Polygon p)
| Method Detail |
public void copyVerticesFrom(Polygon p)
public String getType()
getType in interface Paintable
public void addPointDouble(double x,
double y)
public String toString()
toString in class Objectpublic void paint()
paint in interface Paintablepublic void paintOriginal(Graphics g)
paintOriginal in interface Paintablepublic void paint(Graphics g)
paint in interface Paintable
public boolean pointIsOn(Point p,
int radius)
pointIsOn in interface Translatable
public boolean pointIsOnOriginal(Point p,
int radius)
pointIsOnOriginal in interface Translatable
public void translate(double x,
double y)
translate in interface Translatablepublic int closestNeighborIndex(Point p)
public Point pointAt(int i)
public void drawAngleAt(int i,
Point reference_point)
public void setGraphicsContext(Graphics g)
setGraphicsContext in interface Paintablepublic boolean touches(GeometricObject object)
touches in interface GeometricObjectpublic Rectangle getHorizontalBounds()
public Rectangle getRectangularBounds()
getRectangularBounds in interface GeometricObjectpublic boolean containsGeometricObject(GeometricObject object)
containsGeometricObject in interface GeometricObjectpublic Rectangle getRectangularBounds(int steps)
public Line getEdge(int n)
public double getAngle(int n)
public Polygon getPolygonalBounds()
getPolygonalBounds in interface GeometricObjectpublic void rotateAboutOrigin(double theta)
public void rotateAboutCOM(double theta)
public void rotate(double theta)
public int spatialRelation(GeometricObject object)
spatialRelation in interface GeometricObjectpublic void setTimeStamp(long time_stamp)
setTimeStamp in interface Terminalpublic long getTimeStamp()
getTimeStamp in interface Terminalpublic void setDataPoints(Polygon points)
setDataPoints in interface GeometricObjectpublic Polygon getDataPoints()
getDataPoints in interface GeometricObjectpublic boolean containsGeometricObjects(GeometricObject[] objects)
containsGeometricObjects in interface GeometricObjectpublic double[] getAbsoluteAngles()
public double[] getAbsolutePositiveAngles()
public boolean tryCombining(Object o,
int tolerance)
public void combineEndPoints(double error)
public double[] getMajorAngles()
public void normalize(double[] angle_set)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||