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.DoublearrowEdges(Point2D arrowpoint, Point2D comesfrom, double len, double width) Calculate points for drawing arrow heads.protected static Point2D.DoublecalcCut(double tan, double centerx, double centery, double limitx, double limity) calculate:static Point2D.DoubleFind the center between two points.static Line2D.DoubleconnectCenters(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 intfindEdgeOrCorner(Rectangle2D rect, Point2D p, double eps) Find the edge or corner of a given rectangle, the given point is part of.protected static voidLINE(GeneralPath gp, Point2D p) static GeneralPathmakeDiamond(Rectangle2D rect) Deliver a path wich connects the centers of the borders of the rectanglestatic @Opt GeneralPathmakeRoundedPath(double radius, double epsCollinear, Point2D... points0) Creates a path with rounded edges which connect the given points.static GeneralPathmakeSquare(float cx, float cy, float radius) static GeneralPathmakeSquare(Point2D center, float radius) protected static voidMOVE(GeneralPath gp, Point2D p) static Point2D.DoubleAdd a difference vector to a point.static Point2D.DoubleAdd a difference vector to a point.static Point2D.Doubleconvert aPoint2Dto aPoint2D.Doublestatic Pointpointd2point(Point2D dp) static Point2D.Doublerectangle_p1(Rectangle2D rect) Get the lower left point of aRectangle2Dstatic Point2D.Doublerectangle_p2(Rectangle2D rect) Get the upper right point of aRectangle2Dstatic doublerectangle_x1(Rectangle2D rect) Get the lower x coordinate of aRectangle2Dstatic doublerectangle_x2(Rectangle2D rect) Get the upper x coordinate of aRectangle2Dstatic doublerectangle_y1(Rectangle2D rect) Get the lower y coordinate of aRectangle2Dstatic doublerectangle_y2(Rectangle2D rect) Get the upper y coordinate of aRectangle2Dprotected static voidSPLINE(GeneralPath gp, Point2D paux, Point2D p) static Point2D.DoubletowardsPoint(Point2D from, double len, Point2D to) static floattransposeCoordinate(float coordinate, float sourcemin, float sourcemax, float targetmin, float targetmax)
-
Method Details
-
pointd2point
-
point2pointd
convert aPoint2Dto 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 anintindex 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 epsCollinear, Point2D... points0) Creates a path with rounded edges which connect the given points.- Parameters:
radius- the radius of the rounded edgesepsCollinear- 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)
-