edu.umd.cs.jazz.util
Class ZUtil

java.lang.Object
  |
  +--edu.umd.cs.jazz.util.ZUtil
All Implemented Interfaces:
java.io.Serializable

public class ZUtil
extends java.lang.Object
implements java.io.Serializable

ZUtil provides some generic, useful routines.

Warning: Serialized and ZSerialized objects of this class will not be compatible with future Jazz releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Jazz. A future release of Jazz will provide support for long term persistence.

Author:
Ben Bederson
See Also:
Serialized Form

Constructor Summary
ZUtil()
           
 
Method Summary
static double angleBetweenPoints(double x, double y, double ax, double ay, double bx, double by)
          Returns the angle in radians between point a and point b from point pt, that is the angle between a-pt-b.
static double angleBetweenPoints(java.awt.geom.Point2D pt, java.awt.geom.Point2D a, java.awt.geom.Point2D b)
          Returns the angle in radians between point a and point b from point pt, that is the angle between a-pt-b.
static boolean intersectsPolygon(java.awt.geom.Rectangle2D rect, double[] xp, double[] yp)
          Determines if any part of the rectangle is inside this polygon.
static boolean isInsidePolygon(double x, double y, int np, double[] xp, double[] yp)
          Determines if the point is inside the polygon.
static boolean isInsidePolygon(java.awt.geom.Rectangle2D rect, int np, double[] xp, double[] yp)
          Determines if a rectangle is inside a polygon.
static boolean rectIntersectsLine(java.awt.geom.Rectangle2D rect, double x1, double y1, double x2, double y2)
          Tests if the specified line segment intersects the interior of the specified Rectangle2D.
static boolean rectIntersectsPolyline(java.awt.geom.Rectangle2D rect, double[] xp, double[] yp, double penWidth)
          Determine if the specified rectangle intersects the specified polyline.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZUtil

public ZUtil()
Method Detail

rectIntersectsLine

public static boolean rectIntersectsLine(java.awt.geom.Rectangle2D rect,
                                         double x1,
                                         double y1,
                                         double x2,
                                         double y2)
Tests if the specified line segment intersects the interior of the specified Rectangle2D.
Parameters:
x1, y1 - the first endpoint of the specified line segment
x2, y2 - the second endpoint of the specified line segment
Returns:
true if the specified line segment intersects the interior of this Rectangle2D; false otherwise.

rectIntersectsPolyline

public static boolean rectIntersectsPolyline(java.awt.geom.Rectangle2D rect,
                                             double[] xp,
                                             double[] yp,
                                             double penWidth)
Determine if the specified rectangle intersects the specified polyline.
Parameters:
rect - The rectangle that is being tested for intersection
xp - The array of X-coordinates that determines the polyline
yp - The array of Y-coordinates that determines the polyline
penWidth - The width of the polyline
Returns:
true if the rectangle intersects the polyline.

angleBetweenPoints

public static double angleBetweenPoints(java.awt.geom.Point2D pt,
                                        java.awt.geom.Point2D a,
                                        java.awt.geom.Point2D b)
Returns the angle in radians between point a and point b from point pt, that is the angle between a-pt-b.
Parameters:
pt,a,b - The points that specify the angle
Returns:
the angle

angleBetweenPoints

public static double angleBetweenPoints(double x,
                                        double y,
                                        double ax,
                                        double ay,
                                        double bx,
                                        double by)
Returns the angle in radians between point a and point b from point pt, that is the angle between a-pt-b.
Parameters:
x,y - The central point
ax,ay - The point a
bx,by - The point b
Returns:
the angle

intersectsPolygon

public static boolean intersectsPolygon(java.awt.geom.Rectangle2D rect,
                                        double[] xp,
                                        double[] yp)
Determines if any part of the rectangle is inside this polygon.
Parameters:
rect - The rectangle being tested for intersecting this polygon
Returns:
true if the rectangle intersects the polygon

isInsidePolygon

public static boolean isInsidePolygon(double x,
                                      double y,
                                      int np,
                                      double[] xp,
                                      double[] yp)
Determines if the point is inside the polygon.
Parameters:
x,y - The point being tested for containment within a polygon
Returns:
true if the point is inside the polygon

isInsidePolygon

public static boolean isInsidePolygon(java.awt.geom.Rectangle2D rect,
                                      int np,
                                      double[] xp,
                                      double[] yp)
Determines if a rectangle is inside a polygon. Warning: this code only works for simple convex polygons.
Parameters:
rect - The rectangle being tested for containment within a polygon
Returns:
true if the rectangle is inside the polygon


Copyright © 2001 by University of Maryland, College Park, MD 20742, USA All rights reserved.