

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object org.opensourcephysics.display.GraphicsLib
public class GraphicsLib
Library of useful computer graphics routines such as geometry routines for computing the intersection of different shapes and rendering methods for computing bounds and performing optimized drawing.
Field Summary  

static int 
COINCIDENT
Indicates intersection between shapes 
static int 
NO_INTERSECTION
Indicates no intersection between shapes 
static int 
PARALLEL
Indicates two lines are parallel 
Constructor Summary  

GraphicsLib()

Method Summary  

static java.awt.geom.GeneralPath 
cardinalSpline(float[] pts,
float slack,
boolean closed)
Compute a cardinal spline, a series of cubic Bezier splines smoothly connecting a set of points. 
static java.awt.geom.GeneralPath 
cardinalSpline(float[] pts,
int start,
int npoints,
float slack,
boolean closed)
Compute a cardinal spline, a series of cubic Bezier splines smoothly connecting a set of points. 
static java.awt.geom.GeneralPath 
cardinalSpline(java.awt.geom.GeneralPath p,
float[] pts,
float slack,
boolean closed,
float tx,
float ty)
Compute a cardinal spline, a series of cubic Bezier splines smoothly connecting a set of points. 
static java.awt.geom.GeneralPath 
cardinalSpline(java.awt.geom.GeneralPath p,
float[] pts,
int start,
int npoints,
float slack,
boolean closed,
float tx,
float ty)
Compute a cardinal spline, a series of cubic Bezier splines smoothly connecting a set of points. 
static float[] 
centroid(float[] pts,
int len)
Computes the mean, or centroid, of a set of points 
static double[] 
convexHull(double[] pts,
int len)
Computes the 2D convex hull of a set of points using Graham's scanning algorithm. 
static double[] 
convexHull(double[] pts,
int len,
float[] angles,
int[] idx,
int[] stack)
Computes the 2D convex hull of a set of points using Graham's scanning algorithm. 
static void 
expand(java.awt.geom.Rectangle2D r,
double amount)
Expand a rectangle by the given amount. 
static void 
growPolygon(float[] pts,
int len,
float amt)
Expand a polygon by adding the given distance along the line from the centroid of the polyong. 
static int 
intersectLineLine(double a1x,
double a1y,
double a2x,
double a2y,
double b1x,
double b1y,
double b2x,
double b2y,
java.awt.geom.Point2D intersect)
Compute the intersection of two line segments. 
static int 
intersectLineLine(java.awt.geom.Line2D a,
java.awt.geom.Line2D b,
java.awt.geom.Point2D intersect)
Compute the intersection of two line segments. 
static int 
intersectLineRectangle(java.awt.geom.Line2D l,
java.awt.geom.Rectangle2D r,
java.awt.geom.Point2D[] pts)
Compute the intersection of a line and a rectangle. 
static int 
intersectLineRectangle(java.awt.geom.Point2D a1,
java.awt.geom.Point2D a2,
java.awt.geom.Rectangle2D r,
java.awt.geom.Point2D[] pts)
Compute the intersection of a line and a rectangle. 
static java.awt.geom.GeneralPath 
stackSpline(java.awt.geom.GeneralPath p,
float[] pts,
float epsilon,
float slack,
boolean closed,
float tx,
float ty)
Computes a set of curves using the cardinal spline approach, but using straight lines for completely horizontal or vertical segments. 
static java.awt.geom.GeneralPath 
stackSpline(java.awt.geom.GeneralPath p,
float[] pts,
int start,
int npoints,
float epsilon,
float slack,
boolean closed,
float tx,
float ty)
Computes a set of curves using the cardinal spline approach, but using straight lines for completely horizontal or vertical segments. 
Methods inherited from class java.lang.Object 

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Field Detail 

public static final int NO_INTERSECTION
public static final int COINCIDENT
public static final int PARALLEL
Constructor Detail 

public GraphicsLib()
Method Detail 

public static int intersectLineLine(java.awt.geom.Line2D a, java.awt.geom.Line2D b, java.awt.geom.Point2D intersect)
a
 the first line segmentb
 the second line segmentintersect
 a Point in which to store the intersection point
NO_INTERSECTION
,
COINCIDENT
, or PARALLEL
.public static int intersectLineLine(double a1x, double a1y, double a2x, double a2y, double b1x, double b1y, double b2x, double b2y, java.awt.geom.Point2D intersect)
a1x
 the xcoordinate of the first endpoint of the first linea1y
 the ycoordinate of the first endpoint of the first linea2x
 the xcoordinate of the second endpoint of the first linea2y
 the ycoordinate of the second endpoint of the first lineb1x
 the xcoordinate of the first endpoint of the second lineb1y
 the ycoordinate of the first endpoint of the second lineb2x
 the xcoordinate of the second endpoint of the second lineb2y
 the ycoordinate of the second endpoint of the second lineintersect
 a Point in which to store the intersection point
NO_INTERSECTION
,
COINCIDENT
, or PARALLEL
.public static int intersectLineRectangle(java.awt.geom.Point2D a1, java.awt.geom.Point2D a2, java.awt.geom.Rectangle2D r, java.awt.geom.Point2D[] pts)
a1
 the first endpoint of the linea2
 the second endpoint of the liner
 the rectanglepts
 a length 2 or greater array of points in which to store
the results
NO_INTERSECTION
,
COINCIDENT
, or PARALLEL
.public static int intersectLineRectangle(java.awt.geom.Line2D l, java.awt.geom.Rectangle2D r, java.awt.geom.Point2D[] pts)
l
 the liner
 the rectanglepts
 a length 2 or greater array of points in which to store
the results
NO_INTERSECTION
,
COINCIDENT
, or PARALLEL
.public static double[] convexHull(double[] pts, int len)
pts
 the input points in [x0,y0,x1,y1,...] orderlen
 the length of the pts array to consider (2 * #points)
public static double[] convexHull(double[] pts, int len, float[] angles, int[] idx, int[] stack)
pts

public static float[] centroid(float[] pts, int len)
pts
 the points array, in x1, y1, x2, y2, ... arrangement.len
 the length of the array to consider
public static void growPolygon(float[] pts, int len, float amt)
pts
 the polygon to expand, a set of points in a float arraylen
 the length of the range of the array to consideramt
 the amount by which to expand the polygon, each point
will be moved this distance along the line from the centroid of the
polygon to the given point.public static java.awt.geom.GeneralPath cardinalSpline(float[] pts, float slack, boolean closed)
pts
 the points to interpolate with a cardinal splineslack
 a parameter controlling the "tightness" of the spline to
the control points, 0.10 is a typically suitable valueclosed
 true if the cardinal spline should be closed (i.e. return
to the starting point), false for an open curve
GeneralPath
instance.public static java.awt.geom.GeneralPath cardinalSpline(float[] pts, int start, int npoints, float slack, boolean closed)
pts
 the points to interpolate with a cardinal splinestart
 the starting index from which to read pointsnpoints
 the number of points to considerslack
 a parameter controlling the "tightness" of the spline to
the control points, 0.10 is a typically suitable valueclosed
 true if the cardinal spline should be closed (i.e. return
to the starting point), false for an open curve
GeneralPath
instance.public static java.awt.geom.GeneralPath cardinalSpline(java.awt.geom.GeneralPath p, float[] pts, float slack, boolean closed, float tx, float ty)
p
 the GeneralPath instance to use to store the resultpts
 the points to interpolate with a cardinal splineslack
 a parameter controlling the "tightness" of the spline to
the control points, 0.10 is a typically suitable valueclosed
 true if the cardinal spline should be closed (i.e. return
to the starting point), false for an open curvetx
 a value by which to translate the curve along the xdimensionty
 a value by which to translate the curve along the ydimension
GeneralPath
instance.public static java.awt.geom.GeneralPath cardinalSpline(java.awt.geom.GeneralPath p, float[] pts, int start, int npoints, float slack, boolean closed, float tx, float ty)
p
 the GeneralPath instance to use to store the resultpts
 the points to interpolate with a cardinal splinestart
 the starting index from which to read pointsnpoints
 the number of points to considerslack
 a parameter controlling the "tightness" of the spline to
the control points, 0.10 is a typically suitable valueclosed
 true if the cardinal spline should be closed (i.e. return
to the starting point), false for an open curvetx
 a value by which to translate the curve along the xdimensionty
 a value by which to translate the curve along the ydimension
GeneralPath
instance.public static java.awt.geom.GeneralPath stackSpline(java.awt.geom.GeneralPath p, float[] pts, float epsilon, float slack, boolean closed, float tx, float ty)
p
 the GeneralPath instance to use to store the resultpts
 the points to interpolate with the splineepsilon
 threshold value under which to treat the difference
between two values to be zero. Used to determine which segments to
treat as lines rather than curves.slack
 a parameter controlling the "tightness" of the spline to
the control points, 0.10 is a typically suitable valueclosed
 true if the spline should be closed (i.e. return
to the starting point), false for an open curvetx
 a value by which to translate the curve along the xdimensionty
 a value by which to translate the curve along the ydimension
GeneralPath
instance.public static java.awt.geom.GeneralPath stackSpline(java.awt.geom.GeneralPath p, float[] pts, int start, int npoints, float epsilon, float slack, boolean closed, float tx, float ty)
p
 the GeneralPath instance to use to store the resultpts
 the points to interpolate with the splinestart
 the starting index from which to read pointsnpoints
 the number of points to considerepsilon
 threshold value under which to treat the difference
between two values to be zero. Used to determine which segments to
treat as lines rather than curves.slack
 a parameter controlling the "tightness" of the spline to
the control points, 0.10 is a typically suitable valueclosed
 true if the spline should be closed (i.e. return
to the starting point), false for an open curvetx
 a value by which to translate the curve along the xdimensionty
 a value by which to translate the curve along the ydimension
GeneralPath
instance.public static void expand(java.awt.geom.Rectangle2D r, double amount)
r
 the rectangle to expandamount
 the amount by which to expand the rectangle


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 