Package eu.bandm.tools.graficUtils
Class Geom
java.lang.Object
eu.bandm.tools.graficUtils.Geom
Provides static methods for geometrical calculations
-
Method Summary
Modifier and TypeMethodDescriptionstatic Line2D.Double
arrowEdges
(Point2D arrowpoint, Point2D comesfrom, double len, double width) Calculate points for drawing arrow heads.protected static Point2D.Double
calcCut
(double tan, double centerx, double centery, double limitx, double limity) calculate:static Point2D.Double
Find the center between two points.static Line2D.Double
connectCenters
(Rectangle2D from, Rectangle2D to, int xoff, int yoff) Calculate the segment of the straight line connecting the centers of two rectangles which end at their borders.static int
findEdgeOrCorner
(Rectangle2D rect, Point2D p, double eps) Find the edge or corner of a given rectangle, the given point is part of.protected static void
LINE
(GeneralPath gp, Point2D p) static GeneralPath
makeDiamond
(Rectangle2D rect) Deliver a path wich connects the centers of the borders of the rectanglestatic @Opt GeneralPath
makeRoundedPath
(double radius, double eps_collinear, Point2D... points0) Creates a path with rounded edges which connect the given points.static GeneralPath
makeSquare
(float cx, float cy, float radius) static GeneralPath
makeSquare
(Point2D center, float radius) protected static void
MOVE
(GeneralPath gp, Point2D p) static Point2D.Double
Add a difference vector to a point.static Point2D.Double
Add a difference vector to a point.static Point2D.Double
convert aPoint2D
to aPoint2D.Double
static Point
pointd2point
(Point2D dp) static Point2D.Double
rectangle_p1
(Rectangle2D rect) Get the lower left point of aRectangle2D
static Point2D.Double
rectangle_p2
(Rectangle2D rect) Get the upper right point of aRectangle2D
static double
rectangle_x1
(Rectangle2D rect) Get the lower x coordinate of aRectangle2D
static double
rectangle_x2
(Rectangle2D rect) Get the upper x coordinate of aRectangle2D
static double
rectangle_y1
(Rectangle2D rect) Get the lower y coordinate of aRectangle2D
static double
rectangle_y2
(Rectangle2D rect) Get the upper y coordinate of aRectangle2D
protected static void
SPLINE
(GeneralPath gp, Point2D paux, Point2D p) static Point2D.Double
towardsPoint
(Point2D from, double len, Point2D to) static float
transposeCoordinate
(float coordinate, float sourcemin, float sourcemax, float targetmin, float targetmax)
-
Method Details
-
pointd2point
-
point2pointd
convert aPoint2D
to aPoint2D.Double
-
movePoint
Add a difference vector to a point. -
movePoint
Add a difference vector to a point. -
center
Find the center between two points. -
rectangle_x1
Get the lower x coordinate of aRectangle2D
-
rectangle_x2
Get the upper x coordinate of aRectangle2D
-
rectangle_y1
Get the lower y coordinate of aRectangle2D
-
rectangle_y2
Get the upper y coordinate of aRectangle2D
-
rectangle_p1
Get the lower left point of aRectangle2D
-
rectangle_p2
Get the upper right point of aRectangle2D
-
findEdgeOrCorner
Find the edge or corner of a given rectangle, the given point is part of.
The returned result is anint
index according to the following number assignment:3=nw 2=n 1=ne +--------+ | p2| 4=w | | 0=e |p1 | +--------+ 5=sw 6=s 7=se
- Parameters:
rect
- the rectanglep
- the pointeps
- the granularity of the equality test- Returns:
- number code, as above, or -1 if no hit.
-
connectCenters
Calculate the segment of the straight line connecting the centers of two rectangles which end at their borders.
This can be depicted as+---------+ | * pt | +---. --- + / / / / +---------+/ | .| | . | | * | | pf | | | +-------- +
Additionally, the reference points can be shifted out of the centers by a per-axis offset.- Parameters:
from
- one rectangleto
- the otherxoff
- offset to the x coordinate, for both pointsyoff
- offset to the y coordinate, for both points
-
calcCut
protected static Point2D.Double calcCut(double tan, double centerx, double centery, double limitx, double limity) calculate:| * +---. --- + / / == OR == / ---------+/ .| . | |
-
arrowEdges
public static Line2D.Double arrowEdges(Point2D arrowpoint, Point2D comesfrom, double len, double width) Calculate points for drawing arrow heads./ p1 / |. / | . / w | ./ i | /p0 d | /=len . t |/ . h v----------p2 =len
(The algorithm is "analytical" and does not employ trigonometric functions !-)- Parameters:
arrowpoint
- where the tip of the arrowhead lies.comesfrom
- the other point of the linelen
- the length of the arrowline which falls into the head.width
- the opening width of half the arrow head (VERIFY FIXME ??)- Returns:
- the line which connects the two points of the head != arrowpoint
-
towardsPoint
-
MOVE
-
LINE
-
SPLINE
-
makeRoundedPath
@Opt public static @Opt GeneralPath makeRoundedPath(double radius, double eps_collinear, Point2D... points0) Creates a path with rounded edges which connect the given points.- Parameters:
radius
- the radius of the rounded edgeseps_collinear
- when two lines are considered "not an edge"points0
- the sequence of points.
-
makeDiamond
Deliver a path wich connects the centers of the borders of the rectangle+------+ | /\ | | / \ | |/ \| |\ /| | \ / | | \/ | +------+
-
makeSquare
-
makeSquare
-
transposeCoordinate
public static float transposeCoordinate(float coordinate, float sourcemin, float sourcemax, float targetmin, float targetmax)
-