Skip to content
Snippets Groups Projects
Commit f375bb14 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Kernel: JavaFX editor. Added circle location computation method.

parent a6f63aff
No related branches found
No related tags found
1 merge request!743815 LWFXEditorFramework integration and FX Component Editor
......@@ -5,7 +5,7 @@ DragAndDropBaseUtils.java d375377f9124f6113b2a295e6b0e09ac8966e564 GREEN
EllipseLayoutUIUtils.java 4dd9dbd96a45e8c455c019caa19e4a50f18336af GREEN
FontUtils.java a167a05bdaa8da9853705cc5134f30f6d81bc9f2 GREEN
GCStateManager.java 983973a92376b5c757c1253b32e33d0666ccdf7b GREEN
LWFXEditorUtils.java af4bb6efdc13e52996f6e23b95217e8b5947b478 YELLOW
LWFXEditorUtils.java c628e79fa43c1be8a7b87ee90db6e7264904eafc YELLOW
LayoutDataUIUtils.java c85886ac313a6efb122532218eb134047ffd6631 GREEN
PropertiesViewUtils.java d345b4501c4092228edf1c98e0189317d53aaf22 GREEN
RectangleLayoutUIUtils.java ef4b872bb5b4a51174e9a29d9ef05e7cb3bff3a1 GREEN
......
......@@ -15,9 +15,14 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.utils;
import static java.lang.Math.atan2;
import static java.lang.Math.cos;
import static java.lang.Math.sin;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.base.model.layout.EOrientation;
import javafx.geometry.Point2D;
import javafx.geometry.Rectangle2D;
import javafx.geometry.Side;
......@@ -79,6 +84,21 @@ public final class LWFXEditorUtils {
return null;
}
/**
* Returns the point on a circle centered in the current bounds intersecting with a line between
* the center point and the given point.
*/
public static DiagramCoordinate computeLinkToCircleLocation(Rectangle2D bounds,
Point2D target) {
double sx = bounds.getMinX() + bounds.getWidth() / 2;
double sy = bounds.getMinY() + bounds.getHeight() / 2;
double a = atan2(target.getY() - sy, target.getX() - sx);
double nx = sx + cos(a) * (bounds.getWidth() / 2 - 1);
double ny = sy + sin(a) * (bounds.getHeight() / 2 - 1);
return new DiagramCoordinate(nx, ny);
}
/** Constructor. */
private LWFXEditorUtils() {
// prevent instantiation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment