|
UC Berkeley Group for User Interface Research Updated November 17, 2000 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.berkeley.guir.lib.awt.geom.Polygon2D
Higher precision polygon. For Java2D purposes.
This software is distributed under the Berkeley Software License.
Revisions: - GUIRLib-v1.3-1.0.0, Feb 06 1999, JH Created class - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH Touched for GUIRLib release - GUIRLib-v1.4-1.0.1, Nov 02 2000, JH Added clearPoints() to set number of points to 0.
Field Summary | |
int |
npoints
|
float[] |
xpoints
|
float[] |
ypoints
|
Constructor Summary | |
Polygon2D()
|
|
Polygon2D(float[] xpoints,
float[] ypoints,
int npoints)
|
|
Polygon2D(int[] xpoints,
int[] ypoints,
int npoints)
|
|
Polygon2D(PathIterator it)
Create a new Polygon2D approximating the specified PathIterator. |
|
Polygon2D(Rectangle r)
|
|
Polygon2D(Shape s)
Create a new Polygon2D approximating the specified Shape. |
Method Summary | |
void |
addPoint(double x,
double y)
|
void |
addPoint(Point2D pt)
|
void |
clearPoints()
Remove all points from this polygon. |
Object |
clone()
|
Object |
clone(Polygon2D p)
Make p the same as the current Polygon. |
boolean |
contains(double x,
double y)
|
boolean |
contains(double x,
double y,
double w,
double h)
|
boolean |
contains(Point2D pt)
|
boolean |
contains(Rectangle2D r)
|
void |
cut(Polygon2D p)
Cut the specified Polygon2D out of the current Polygon2D. |
Rectangle |
getBounds()
Deprecated. should use getBounds2D in SATIN and DENIM instead. |
Rectangle2D |
getBounds2D()
|
PathIterator |
getPathIterator(AffineTransform tx)
|
PathIterator |
getPathIterator(AffineTransform tx,
double flatness)
Does same as other getPathIterator(AffineTransform) . |
boolean |
intersects(double x,
double y,
double w,
double h)
|
boolean |
intersects(Rectangle2D r)
|
boolean |
isClosed()
Check whether this polygon is a closed polygon or not. |
boolean |
isNormalized()
|
static void |
main(String[] argv)
|
float |
minDistance(double x,
double y)
Calculate the minimum distance from all points in the Polygon to the specified point. |
float |
minDistance(Polygon p)
Figure out the min distance between two polygons. |
Point2D |
normalize()
Force the top-right bounds to be at (0, 0). |
void |
paste(Polygon2D p)
Try to merge the current Polygon2D with the specified Polygon2D. |
double |
perimeter()
Calculate the length of the lines in the path. |
void |
setClosed(boolean flag)
Set whether this polygon is a closed polygon or not. |
void |
setPoly(Polygon poly)
Set this polygon to be the same as the specified one. |
void |
setPoly(Polygon2D poly)
Set this polygon to be the same as the specified one. |
void |
setToPathIterator(PathIterator it)
Clear out the old polygon, set the polygon to be the specified PathIterator. |
void |
setToShape(Shape s)
|
Polygon2D |
simplify()
Get a simpler-to-render polygon that looks like this polygon. |
String |
toString()
|
void |
transform(AffineTransform tx)
Transform this Polygon2D in place. |
Polygon2D |
transformCopy(AffineTransform tx)
Copy and then transform the new polygon. |
void |
translate(double dx,
double dy)
Translate by a certain amount. |
void |
trim()
Trim the size of the array for space purposes. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public int npoints
public float[] xpoints
public float[] ypoints
Constructor Detail |
public Polygon2D()
public Polygon2D(Rectangle r)
public Polygon2D(Shape s)
public Polygon2D(PathIterator it)
public Polygon2D(int[] xpoints, int[] ypoints, int npoints)
public Polygon2D(float[] xpoints, float[] ypoints, int npoints)
Method Detail |
public boolean contains(double x, double y)
contains
in interface Shape
public boolean contains(double x, double y, double w, double h)
contains
in interface Shape
public boolean contains(Point2D pt)
contains
in interface Shape
public boolean contains(Rectangle2D r)
contains
in interface Shape
public Rectangle getBounds()
getBounds
in interface Shape
public Rectangle2D getBounds2D()
getBounds2D
in interface Shape
public PathIterator getPathIterator(AffineTransform tx)
getPathIterator
in interface Shape
public PathIterator getPathIterator(AffineTransform tx, double flatness)
getPathIterator(AffineTransform)
.
Flatness is ignored.getPathIterator
in interface Shape
public boolean intersects(double x, double y, double w, double h)
intersects
in interface Shape
public boolean intersects(Rectangle2D r)
intersects
in interface Shape
public void setToShape(Shape s)
public void setToPathIterator(PathIterator it)
4 = PathIterator.SEG_CLOSE 3 = PathIterator.SEG_CUBICTO 2 = PathIterator.SEG_QUADTO 1 = PathIterator.SEG_LINETO 0 = PathIterator.SEG_MOVETO 1 = PathIterator.WIND_NON_ZERO 0 = PathIterator.WIND_EVEN_ODD
public void setPoly(Polygon2D poly)
public void setPoly(Polygon poly)
public void setClosed(boolean flag)
public boolean isClosed()
public void trim()
public void addPoint(Point2D pt)
public void addPoint(double x, double y)
public void clearPoints()
public void translate(double dx, double dy)
public Polygon2D simplify()
public void transform(AffineTransform tx)
public Polygon2D transformCopy(AffineTransform tx)
public boolean isNormalized()
public Point2D normalize()
public void paste(Polygon2D p)
public void cut(Polygon2D p)
public double perimeter()
public float minDistance(double x, double y)
If the polygon is closed, then the distance is 0 if the point is contained.
x
- is the x-coordinate to check from.y
- is the y-coordinate to check from.public float minDistance(Polygon p)
public String toString()
toString
in class Object
public Object clone()
clone
in class Object
public Object clone(Polygon2D p)
public static void main(String[] argv)
|
Copyright Information | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |