|
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.GeomLib
Miscellaneous geometry utilities.
This software is distributed under the Berkeley Software License.
Revisions: - GUIRLib-v1.3-1.0.0, July 17 2000, JH Created class - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH Touched for GUIRLib v1.4 release
Method Summary | |
static Point2D |
calcIntersectPoint(double xa1,
double ya1,
double xa2,
double ya2,
double xb1,
double yb1,
double xb2,
double yb2)
Figure out where these two lines intersect. |
static Point2D |
calcIntersectPoint(Line2D lAA,
Line2D lBB)
Figure out where these two lines intersect. |
static List |
calcIntersectPoints(Line2D l,
Shape s)
Get a list of all points where the line intersects with the Shape. |
static AffineTransform |
calcPassthrough(AffineTransform txA,
AffineTransform txB,
AffineTransform txOut)
Find txC, where [txA] * [txB] = [txB] * [txC] . |
static Polygon |
clonePolygon(Polygon p)
Got sick of writing this piece of code over and over. |
static Polygon |
cutPolygon(Polygon a,
Polygon b)
Cut polygon b out of the boundaries of polygon a. |
static float |
distance(double x1,
double y1,
double x2,
double y2)
Calculate the Euclidean distance from point 1 to point 2. |
static float |
distance(int x1,
int y1,
int x2,
int y2)
Calculate the Euclidean distance from point 1 to point 2. |
static float |
distance(Point2D p1,
Point2D p2)
|
static Polygon |
makePolygon(Rectangle rect)
Make a Polygon out of a Rectangle. |
static Polygon |
makePolygon(Rectangle2D rect)
Make a Polygon out of a Rectangle. |
static Polygon |
makePolygon(Shape s)
|
static Polygon |
mergePolygons(Polygon a,
Polygon b)
Merge two polygons together, if they intersect. |
static float |
minDistance(Polygon poly,
int x,
int y)
Calculate the minimum distance from all points in the Polygon to the specified point. |
static float |
minDistance(Polygon polyA,
Polygon polyB)
Figure out the min distance between two polygons. |
static double |
minDistance(Shape saa,
Shape sbb)
|
static float |
minDistanceToCenter(Rectangle r,
int x,
int y)
Calculate the distance from the (x,y) point to the center of the specified Rectangle. |
static Polygon |
pathIteratorToPolygon(PathIterator it)
Convert a path iterator into a polygon. |
static Polygon |
simplify(int[] xpoints,
int[] ypoints,
int npoints)
|
static Polygon |
simplify(Polygon p)
Given a polygon, return a "simpler" version of it. |
static Polygon |
transformPolygon(AffineTransform tx,
Polygon p)
Run the transformation on a polygon, returning a new polygon with transformed coordinates. |
static Polygon |
transformPolygonInPlace(AffineTransform tx,
Polygon p)
Run the transformation on a polygon, returning the same polygon with transformed coordinates. |
static Rectangle2D |
transformRectangle(AffineTransform tx,
Rectangle2D rSrc)
|
static Rectangle2D |
transformRectangle(AffineTransform tx,
Rectangle2D rSrc,
Rectangle2D rDst)
Apply a transform to a Rectangle. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static final Polygon clonePolygon(Polygon p)
public static final Polygon makePolygon(Rectangle rect)
rect
- is a Rectangle to make into a Polygon.public static final Polygon makePolygon(Rectangle2D rect)
rect
- is a Rectangle to make into a Polygon.public static final Polygon makePolygon(Shape s)
public static final Polygon simplify(int[] xpoints, int[] ypoints, int npoints)
public static final Polygon simplify(Polygon p)
public static AffineTransform calcPassthrough(AffineTransform txA, AffineTransform txB, AffineTransform txOut)
[txA] * [txB] = [txB] * [txC]
.
Used for calculating AffineTransforms and Sticky Graphical Objects.txA
- is as stated in the equation above.txB
- is as stated in the equation above.txOut
- is storage space, use null to create new storage.public static Polygon transformPolygonInPlace(AffineTransform tx, Polygon p)
tx
- is the AffineTransform to execute on the Polygon.p
- is Polygon to transform. p is modified.public static Polygon transformPolygon(AffineTransform tx, Polygon p)
tx
- is the AffineTransform to execute on the Polygon.p
- is Polygon to transform. p is NOT modified in any way.public static Rectangle2D transformRectangle(AffineTransform tx, Rectangle2D rSrc)
transformRectangle(AffineTransform, Rectangle2D, Rectangle2D)
public static Rectangle2D transformRectangle(AffineTransform tx, Rectangle2D rSrc, Rectangle2D rDst)
tx
- is the transform to apply.rSrc
- is the source rectangle to start with.rDst
- is the destination rectangle after transformation. Okay if
same as rSrc.public static final Polygon pathIteratorToPolygon(PathIterator it)
public static final Polygon mergePolygons(Polygon a, Polygon b)
This is useful for making Patch areas larger.
public static final Polygon cutPolygon(Polygon a, Polygon b)
public static final double minDistance(Shape saa, Shape sbb)
public static final float minDistance(Polygon poly, int x, int y)
Technically, this implementation is not correct, since we should really be checking the minimum distance from the specified point to all of the line segments in the Polygon. This was just easier to write and seems good enough for most purposes.
p
- is the Polygon to check.x
- is the x-coordinate to check from.y
- is the y-coordinate to check from.public static final float minDistance(Polygon polyA, Polygon polyB)
public static final float minDistanceToCenter(Rectangle r, int x, int y)
rect
- is the Rectangle whose center point we will use.x
- is the x-coordinate of the other point to use.y
- is the y-coordinate of the other point to use.public static final float distance(int x1, int y1, int x2, int y2)
x1
- is the x-coordinate of the first point.y1
- is the y-coordinate of the first point.x2
- is the x-coordinate of the second point.y2
- is the y-coordinate of the second point.public static final float distance(double x1, double y1, double x2, double y2)
x1
- is the x-coordinate of the first point.y1
- is the y-coordinate of the first point.x2
- is the x-coordinate of the second point.y2
- is the y-coordinate of the second point.public static final float distance(Point2D p1, Point2D p2)
public static final List calcIntersectPoints(Line2D l, Shape s)
public static final Point2D calcIntersectPoint(Line2D lAA, Line2D lBB)
public static final Point2D calcIntersectPoint(double xa1, double ya1, double xa2, double ya2, double xb1, double yb1, double xb2, double yb2)
|
Copyright Information | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |