From 32f39c68df03184485c8ab22b2f4d8872c73f4d0 Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Fri, 27 Jan 2012 12:36:59 +0000 Subject: [PATCH] YELLOW refs 311 --- .../base/ui/utils/LayoutDataUtils.java | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/LayoutDataUtils.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/LayoutDataUtils.java index ecd4ec2da..042f7284d 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/LayoutDataUtils.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/utils/LayoutDataUtils.java @@ -51,8 +51,10 @@ import org.eclipse.gef.EditPart; import org.fortiss.tooling.base.layout.LayoutKeyConstants; import org.fortiss.tooling.base.model.layout.Angle; import org.fortiss.tooling.base.model.layout.Dimension; +import org.fortiss.tooling.base.model.layout.EOrientation; import org.fortiss.tooling.base.model.layout.ILayoutData; import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.base.model.layout.LayoutFactory; import org.fortiss.tooling.base.model.layout.Offset; import org.fortiss.tooling.base.model.layout.OffsetOrientation; import org.fortiss.tooling.base.model.layout.Point; @@ -75,10 +77,29 @@ import org.fortiss.tooling.base.utils.LayoutModelElementFactory; * @author hummel * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: BA085FEB69C66332C246D33F24D7D240 + * @ConQAT.Rating YELLOW Hash: 777A0B24A644B59F3A954FA349436062 */ public class LayoutDataUtils { + /** Sets node layout. */ + public static void setNodeLayoutData(ILayoutedModelElement layouted, + int xPos, int yPos, int width, int height) { + setNodeBounds(layouted, new Rectangle(xPos, yPos, width, height)); + } + + /** Sets free port layout data. */ + public static void setNodeLayoutData(ILayoutedModelElement layouted, + int xPos, int yPos) { + setNodePosition(layouted, xPos, yPos); + } + + /** Sets sticky connector layout data. */ + public static void setStickyConnectorLayoutData( + ILayoutedModelElement layouted, EOrientation orientation, int offset) { + setOffsetOrientation(layouted, CONNECTOR_OFFSET_ORIENTATION, offset, + orientation); + } + /** Returns the bounds rectangle of the given layouted element. */ public static Rectangle getNodeBounds(ILayoutedModelElement layouted) { Rectangle result = new Rectangle(); @@ -331,6 +352,27 @@ public class LayoutDataUtils { } } + /** + * Adds a {@link org.eclipse.draw2d.Bendpoint Bendpoint} defined by the x,y + * parameters to a channel + * + * @param conn + * the connection + * @param bendPointX + * the x coordinate of the Bendpoint + * @param bendPointY + * the y coordinate of the Bendpoint + */ + public static void addBendPointToConnection(ILayoutedModelElement conn, + int bendPointX, int bendPointY) { + // set middle point of transition + Point bendPoint = LayoutFactory.eINSTANCE.createPoint(); + bendPoint.setX(bendPointX); + bendPoint.setY(bendPointY); + + getConnectionPoints(conn).getPointsList().add(bendPoint); + } + /** Move bend points of self-connections, if theirs parent is resized */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static void bendpointGroupResize(ILayoutedModelElement layouted, -- GitLab