|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bbn.openmap.proj.DrawUtil
public class DrawUtil
Drawing utility functions.
Method Summary | |
---|---|
static java.awt.Point[] |
bresenham_line(int x1,
int y1,
int x2,
int y2)
Bresenham's line algorithm. |
static java.awt.Point[] |
bresenham_line(java.awt.Point pt1,
java.awt.Point pt2)
Bresenham's line algorithm. |
static float |
closestPolyDistance(float[] xpts,
float[] ypts,
double ptx,
double pty,
boolean connected)
Returns the distance from Point (x,y) to the closest line segment in the Poly (int[] xpts, int[] ypts). |
static float |
distance_to_endpoint(int x1,
int y1,
int x2,
int y2,
int x,
int y)
Distance to closest endpoint. |
static double |
distance_to_line(double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
Computes the distance from a point to a line segment. |
static double |
distance(double x1,
double y1,
double x2,
double y2)
2D distance formula. |
static float |
distance(float x1,
float y1,
float x2,
float y2)
2D distance formula. |
static float |
distance(int x1,
int y1,
int x2,
int y2)
2D distance formula. |
static java.util.List<int[]> |
generateWideLine(int lw,
int x1,
int y1,
int x2,
int y2)
Generates a line with width lw, returns an ArrayList of 4 x-y coords. |
static java.util.List<int[]> |
generateWidePoly(int lw,
int[] xpts,
int[] ypts,
int[] altx,
boolean connect)
Generates a polygon or polyline with positive width lw. |
static java.util.List<int[]> |
generateWidePoly(int lw,
int len,
int[] xpts,
int[] ypts,
int[] altx,
boolean connect)
Generates a polygon or polyline with positive width lw. |
static boolean |
inside_polygon(float[] xpts,
float[] ypts,
double ptx,
double pty)
Tests if a point is inside a polygon. |
static int[] |
lineSegments(int x1,
int y1,
int x2,
int y2,
int n,
boolean include_last,
int[] ret_val)
Generate additional vertices between two points. |
static java.awt.Point[] |
lineSegments(java.awt.Point pt1,
java.awt.Point pt2,
int n,
boolean include_last)
Returns n or n+1 points along a line. |
static float |
OLD_distance_to_line(int x1,
int y1,
int x2,
int y2,
int x,
int y)
Deprecated. USE THE NEW FUNCTION |
static float |
perpendicular_distance_to_line(int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
Compute perpendicular distance from point to line. |
static int |
pixel_distance(int x1,
int y1,
int x2,
int y2)
Calculate the "pixel distance" between two points (squaring not involved). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static final int[] lineSegments(int x1, int y1, int x2, int y2, int n, boolean include_last, int[] ret_val)
x1
- x coordy1
- y coordx2
- x coordy2
- y coordn
- num segmentsinclude_last
- include the last one?ret_val
- the array to put them in
public static final java.awt.Point[] lineSegments(java.awt.Point pt1, java.awt.Point pt2, int n, boolean include_last)
pt1
- pointpt2
- pointn
- countinclude_last
- boolean
public static final java.awt.Point[] bresenham_line(java.awt.Point pt1, java.awt.Point pt2)
Returns an array of points to draw.
pt1
- pointpt2
- point
public static final java.awt.Point[] bresenham_line(int x1, int y1, int x2, int y2)
x1
- horizontal pixel window location of first point.y1
- vertical pixel window location of first point.x2
- horizontal pixel window location of second point.y2
- vertical pixel window location of second point.
public static final boolean inside_polygon(float[] xpts, float[] ypts, double ptx, double pty)
xpts
- horizontal pixel window points of polygon.ypts
- vertical pixel window points of polygon.ptx
- horizontal pixel window points of locationpty
- vertical pixel window points of location.
public static final float closestPolyDistance(float[] xpts, float[] ypts, double ptx, double pty, boolean connected)
This procedure assumes that xpts.length == ypts.length.
xpts
- X points of the polygonypts
- Y points of the polygonptx
- x location of the pointpty
- y location of the pointconnected
- polyline or polygonpublic static final float distance(float x1, float y1, float x2, float y2)
x1
- x coordy1
- y coordx2
- x coordy2
- y coord
public static final float distance(int x1, int y1, int x2, int y2)
x1
- x coordy1
- y coordx2
- x coordy2
- y coord
public static final double distance(double x1, double y1, double x2, double y2)
x1
- x coordy1
- y coordx2
- x coordy2
- y coord
public static final int pixel_distance(int x1, int y1, int x2, int y2)
x1
- x coordy1
- y coordx2
- x coordy2
- y coord
public static final float distance_to_endpoint(int x1, int y1, int x2, int y2, int x, int y)
x1
- x coordy1
- y coordx2
- x coordy2
- y coordx
- x coord of pointy
- y coord of point
public static final float OLD_distance_to_line(int x1, int y1, int x2, int y2, int x, int y)
Compute the distance from point (x,y) to a line by computing the perpendicular line from (x,y) to the line and finding the intersection of this perpendicular and the line. If the intersection is on the line segment, then the distance is the distance from the mouse to the intersection, otherwise it is the distance from (x,y) to the nearest endpoint.
Equations used to compute distance:
x1
- line x coord1y1
- line y coord1x2
- line x coord2y2
- line y coord2x
- point x coordy
- point y coord
public static final float perpendicular_distance_to_line(int x1, int y1, int x2, int y2, int x3, int y3)
x1
- line x coord1y1
- line y coord1x2
- line x coord2y2
- line y coord2x3
- point x coordy3
- point y coord
public static final double distance_to_line(double x1, double y1, double x2, double y2, double x3, double y3)
Variable usage as follows:
Compute D12, the length of the line segment. Compute pp, the distance to the perpendicular. If pp is negative, the intersection is before the start of the line segment, so return the distance from the start point. If pp exceeds the length of the line segment, then the intersection is beyond the end point so return the distance of the point from the end point. Otherwise, return the absolute value of the length of the perpendicular line. The sign of the length of the perpendicular line indicates whether the point lies to the right or left of the line as one travels from the start point to the end point.
x1
- line x coord1y1
- line y coord1x2
- line x coord2y2
- line y coord2x3
- point x coordy3
- point y coord
public static java.util.List<int[]> generateWideLine(int lw, int x1, int y1, int x2, int y2)
lw
- line widthx1
- line x coord1y1
- line y coord1x2
- line x coord2y2
- line y coord2
public static final java.util.List<int[]> generateWidePoly(int lw, int[] xpts, int[] ypts, int[] altx, boolean connect)
Returns ArrayList of x-y array pairs of coordinates of polygon segments. the parameter altx must either be null, or an alternate array of points to draw.
lw
- line widthxpts
- int[] x coordsypts
- int[] y coordsaltx
- int[] altx coordsconnect
- polygon or polyline?
public static final java.util.List<int[]> generateWidePoly(int lw, int len, int[] xpts, int[] ypts, int[] altx, boolean connect)
Returns ArrayList of x-y array pairs of coordinates of polygon segments. the parameter altx must either be null, or an alternate array of points to draw.
lw
- line widthlen
- numcoordsxpts
- int[] x coordsypts
- int[] y coordsaltx
- int[] altx coordsconnect
- polygon or polyline?
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |