Package pamViewFX.fxNodes.connectionPane
Class ConnectionNodeUtils
java.lang.Object
pamViewFX.fxNodes.connectionPane.ConnectionNodeUtils
Useful functions for connection nodes.
- Author:
- Jamie Macaulay
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic javafx.geometry.Point2D
closestPointOnRect
(double x, double y, double width, double height, double xp, double yp) Get the closest point to the edge of a rectangle from another pointstatic javafx.geometry.Point2D
findClosestPoint
(double x1, double y1, double x2, double y2, double xp, double yp) Computes the closest point on a line to another point.static javafx.geometry.Point2D
findClosestPoint
(javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, javafx.geometry.Point2D p3) Computes the closest point on a line to another point.static javafx.geometry.Point2D
intersection
(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) Computes the intersection between two lines.
-
Constructor Details
-
ConnectionNodeUtils
public ConnectionNodeUtils()
-
-
Method Details
-
findClosestPoint
public static javafx.geometry.Point2D findClosestPoint(double x1, double y1, double x2, double y2, double xp, double yp) Computes the closest point on a line to another point.- Parameters:
x1
- - x start of line.y1
- - y start of line.x2
- - x end of line.y2
- - y end of line.xp
- - x point to test.yp
- - y point to test.- Returns:
- the closest point on line.
-
findClosestPoint
public static javafx.geometry.Point2D findClosestPoint(javafx.geometry.Point2D p1, javafx.geometry.Point2D p2, javafx.geometry.Point2D p3) Computes the closest point on a line to another point.- Parameters:
p1
- - start of the line.p2
- - end of the line.p3
- - point to measure closest point on line to.- Returns:
- the closest point on the line to p3. This will be somewhere between p1 and p2.
-
closestPointOnRect
public static javafx.geometry.Point2D closestPointOnRect(double x, double y, double width, double height, double xp, double yp) Get the closest point to the edge of a rectangle from another point- Parameters:
x
- - rectangle layout x (top left corner)y
- - rectangle layout y (top left corner)width
- - rectangle width.height
- - rectangle height.xp
- - the x position of point to test.yp
- - the y position of point to test.- Returns:
- - the closest point to (xp, yp) located on the rectangle's edge.
-
intersection
public static javafx.geometry.Point2D intersection(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) Computes the intersection between two lines. The calculated point is approximate, since integers are used. If you need a more precise result, use doubles everywhere. (c) 2007 Alexander Hristov. Use Freely (LGPL license). http://www.ahristov.com- Parameters:
x1
- Point 1 of Line 1y1
- Point 1 of Line 1x2
- Point 2 of Line 1y2
- Point 2 of Line 1x3
- Point 1 of Line 2y3
- Point 1 of Line 2x4
- Point 2 of Line 2y4
- Point 2 of Line 2- Returns:
- Point where the segments intersect, or null if they don't
-