Skip to content
Snippets Groups Projects
Commit c319597e authored by Daniel Ratiu's avatar Daniel Ratiu
Browse files

Added the method "getAbsoluteConnectorBounds"

refs 352
parent 501033b5
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@ package org.fortiss.tooling.base.ui.utils;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
......@@ -123,6 +124,36 @@ public final class EllipseLayoutUtils {
return newSize;
}
/** Returns the bounds rectangle of the connector given its parent bounds. */
public static Rectangle getAbsoluteConnectorBounds(
ILayoutedModelElement connector, ILayoutedModelElement parent) {
Rectangle result = new Rectangle(0, 0,
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE,
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE);
final double angle = LayoutDataUtils
.getConnectorAngleAsDouble(connector);
org.fortiss.tooling.base.model.layout.Dimension parentSize = LayoutDataUtils
.getNodeSize(parent);
Dimension parentDim = new Dimension(parentSize.getWidth(),
parentSize.getHeight());
final Point position = calculateEllipseBorderPoint(angle, parentDim,
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2).translate(
-DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2,
-DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2);
org.fortiss.tooling.base.model.layout.Point parentPos = LayoutDataUtils
.getNodePosition(parent);
result.x = position.x + parentPos.getX();
result.y = position.y + parentPos.getY();
return result;
}
/**
* Class for storing polar coordinates.
*
......
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