diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/EllipseLayoutUtils.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/EllipseLayoutUtils.java index c23124cdfe92f36a6a49ee8f3ea4e466b72db810..f5de5c166c5fb895c03d42821ce6e9f46d42438d 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/EllipseLayoutUtils.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/EllipseLayoutUtils.java @@ -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. *