From 926ed69c9c7d937de401ef96827295828bc14493 Mon Sep 17 00:00:00 2001
From: Florian Hoelzl <hoelzl@fortiss.org>
Date: Tue, 21 Jun 2011 11:45:24 +0000
Subject: [PATCH] edit part implementations for component structures

---
 .../trunk/META-INF/MANIFEST.MF                |   1 +
 .../base/ui/command/BendpointCommandBase.java |  50 ++++++
 .../ChangeBoundsRequestCommandBase.java       | 145 ++++++++++++++++++
 .../ui/command/CreateBendpointCommand.java    |  52 +++++++
 .../ui/command/DeleteBendpointCommand.java    |  41 +++++
 .../base/ui/command/MoveBendpointCommand.java |  56 +++++++
 .../RectangularConnectorEditPartBase.java     |  18 ++-
 .../editpart/figure/AntiAliasedEllipse.java   |  40 +++++
 .../base/ui/layout/IPointLayouter.java        |   1 -
 .../ui/layout/util/EditPartLayoutUtils.java   |   3 +-
 .../base/ui/layout/util/LayoutDataUtils.java  |  51 +++++-
 .../base/ui/layout/util/OrientationUtils.java |  25 ++-
 12 files changed, 463 insertions(+), 20 deletions(-)
 create mode 100644 org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/BendpointCommandBase.java
 create mode 100644 org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/ChangeBoundsRequestCommandBase.java
 create mode 100644 org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/CreateBendpointCommand.java
 create mode 100644 org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/DeleteBendpointCommand.java
 create mode 100644 org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/MoveBendpointCommand.java
 create mode 100644 org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/figure/AntiAliasedEllipse.java

diff --git a/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF b/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF
index a5a08282e..4d375a182 100644
--- a/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF
+++ b/org.fortiss.tooling.base.ui/trunk/META-INF/MANIFEST.MF
@@ -17,6 +17,7 @@ Export-Package: org.fortiss.tooling.base.ui,
  org.fortiss.tooling.base.ui.editor.gef,
  org.fortiss.tooling.base.ui.editpart,
  org.fortiss.tooling.base.ui.editpart.anchor,
+ org.fortiss.tooling.base.ui.editpart.connector,
  org.fortiss.tooling.base.ui.editpart.figure,
  org.fortiss.tooling.base.ui.editpart.policy,
  org.fortiss.tooling.base.ui.layout,
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/BendpointCommandBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/BendpointCommandBase.java
new file mode 100644
index 000000000..db539a0cd
--- /dev/null
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/BendpointCommandBase.java
@@ -0,0 +1,50 @@
+/*--------------------------------------------------------------------------+
+$Id$
+|                                                                          |
+| Copyright 2011 ForTISS GmbH                     |
+|                                                                          |
+| Licensed under the Apache License, Version 2.0 (the "License");          |
+| you may not use this file except in compliance with the License.         |
+| You may obtain a copy of the License at                                  |
+|                                                                          |
+|    http://www.apache.org/licenses/LICENSE-2.0                            |
+|                                                                          |
+| Unless required by applicable law or agreed to in writing, software      |
+| distributed under the License is distributed on an "AS IS" BASIS,        |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and      |
+| limitations under the License.                                           |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.base.ui.command;
+
+import org.eclipse.gef.commands.Command;
+import org.fortiss.tooling.base.model.layout.Point;
+import org.fortiss.tooling.base.model.layout.Points;
+
+/**
+ * Command that handles bend points.
+ * 
+ * @author hoelzl
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating RED Hash:
+ */
+public abstract class BendpointCommandBase extends Command {
+
+	/** The position where the point should be placed */
+	protected Point location;
+
+	/** The index of the bend point */
+	protected int index;
+
+	/** The connection where the bend point is added */
+	protected Points connection;
+
+	/** Creates a bend point command. */
+	public BendpointCommandBase(Points connection, int index, Point location) {
+		this.connection = connection;
+		this.index = index;
+		this.location = location;
+	}
+
+}
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/ChangeBoundsRequestCommandBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/ChangeBoundsRequestCommandBase.java
new file mode 100644
index 000000000..1ce4fc5fe
--- /dev/null
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/ChangeBoundsRequestCommandBase.java
@@ -0,0 +1,145 @@
+/*--------------------------------------------------------------------------+
+$Id$
+|                                                                          |
+| Copyright 2011 ForTISS GmbH                     |
+|                                                                          |
+| Licensed under the Apache License, Version 2.0 (the "License");          |
+| you may not use this file except in compliance with the License.         |
+| You may obtain a copy of the License at                                  |
+|                                                                          |
+|    http://www.apache.org/licenses/LICENSE-2.0                            |
+|                                                                          |
+| Unless required by applicable law or agreed to in writing, software      |
+| distributed under the License is distributed on an "AS IS" BASIS,        |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and      |
+| limitations under the License.                                           |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.base.ui.command;
+
+import java.util.List;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.fortiss.tooling.base.model.layout.Dimension;
+import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
+import org.fortiss.tooling.base.model.layout.Point;
+import org.fortiss.tooling.base.model.layout.Points;
+import org.fortiss.tooling.base.ui.editpart.ConnectorEditPartBase;
+import org.fortiss.tooling.base.ui.editpart.LayoutedConnectionEditPartBase;
+import org.fortiss.tooling.base.ui.layout.constants.LayoutKeyConstants;
+import org.fortiss.tooling.base.ui.layout.util.LayoutDataUtils;
+
+/**
+ * A {@link Command} storing a {@link ChangeBoundsRequest}.
+ * 
+ * @author wandinger
+ * @author hoelzl
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating RED Hash:
+ */
+public abstract class ChangeBoundsRequestCommandBase extends Command {
+
+	/** The creation request */
+	private final ChangeBoundsRequest request;
+
+	/** Constructor */
+	public ChangeBoundsRequestCommandBase(ChangeBoundsRequest request) {
+		this.request = request;
+	}
+
+	/** Returns the stored request. */
+	protected ChangeBoundsRequest getRequest() {
+		return request;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	@SuppressWarnings("unchecked")
+	public void execute() {
+		bendpointGroupMove(request.getEditParts());
+	}
+
+	/** Moves the given node using info from {@link #getRequest()}. */
+	protected void moveNode(ILayoutedModelElement layouted) {
+		Point p = LayoutDataUtils.getNodePosition(layouted);
+		int dx = getRequest().getMoveDelta().x;
+		int dy = getRequest().getMoveDelta().y;
+		LayoutDataUtils.setNodePosition(layouted,
+				LayoutDataUtils.translate(p, dx, dy));
+	}
+
+	/**
+	 * Moves and resizes the given node using info from {@link #getRequest()}.
+	 * The final size is returned.
+	 */
+	protected Dimension moveAndResizeNode(ILayoutedModelElement layouted,
+			int minWidth, int minHeight) {
+		int dx = getRequest().getMoveDelta().x;
+		int dy = getRequest().getMoveDelta().y;
+		Point pos = LayoutDataUtils.translate(
+				LayoutDataUtils.getNodePosition(layouted), dx, dy);
+
+		int dw = getRequest().getSizeDelta().width;
+		int dh = getRequest().getSizeDelta().height;
+		Dimension dim = LayoutDataUtils.expand(
+				LayoutDataUtils.getNodeSize(layouted), dw, dh);
+
+		if (dim.getWidth() < minWidth) {
+			if (getRequest().getMoveDelta().x > 0) {
+				pos.setX(pos.getX() - minWidth - dim.getWidth());
+			}
+			dim.setWidth(minWidth);
+		}
+
+		if (dim.getHeight() < minHeight) {
+			if (getRequest().getMoveDelta().y > 0) {
+				pos.setY(pos.getY() - minHeight - dim.getHeight());
+			}
+			dim.setHeight(minHeight);
+		}
+
+		LayoutDataUtils.setNodePosition(layouted, pos);
+		LayoutDataUtils.setNodeSize(layouted, dim);
+		return dim;
+	}
+
+	/** Move bend points along with a group of selected elements */
+	@SuppressWarnings({ "unchecked", "rawtypes" })
+	private void bendpointGroupMove(List<EditPart> parts) {
+		for (EditPart part : parts) {
+			// cover also sticky connectors
+			if (part.getChildren().size() > 0) {
+				bendpointGroupMove(part.getChildren());
+			}
+			// filter non connective edit parts
+			if (!(part instanceof ConnectorEditPartBase)) {
+				break;
+			}
+			ConnectorEditPartBase connector = (ConnectorEditPartBase) part;
+			for (LayoutedConnectionEditPartBase connection : (List<LayoutedConnectionEditPartBase>) connector
+					.getSourceConnections()) {
+				if (connection.getTarget().getSelected() != EditPart.SELECTED_NONE) {
+					// get all bendpoints of the currently selected connection
+					Points points = LayoutDataUtils.getPoints(
+							(ILayoutedModelElement) connection.getModel(),
+							LayoutKeyConstants.CONNECTION_POINTS);
+					for (int i = 0; i < points.getPointsLength(); i++) {
+						Point pos = LayoutDataUtils.createPoint(points
+								.getPoints(i).getX(), points.getPoints(i)
+								.getY());
+						LayoutDataUtils.translate(pos,
+								request.getMoveDelta().x,
+								request.getMoveDelta().y);
+						// create a command to move the bendpoints properly and
+						// execute it
+						(new MoveBendpointCommand(points, i, pos, null))
+								.execute();
+					}
+				}
+			}
+		}
+	}
+}
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/CreateBendpointCommand.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/CreateBendpointCommand.java
new file mode 100644
index 000000000..fdad1ae5c
--- /dev/null
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/CreateBendpointCommand.java
@@ -0,0 +1,52 @@
+/*--------------------------------------------------------------------------+
+$Id$
+|                                                                          |
+| Copyright 2011 ForTISS GmbH                     |
+|                                                                          |
+| Licensed under the Apache License, Version 2.0 (the "License");          |
+| you may not use this file except in compliance with the License.         |
+| You may obtain a copy of the License at                                  |
+|                                                                          |
+|    http://www.apache.org/licenses/LICENSE-2.0                            |
+|                                                                          |
+| Unless required by applicable law or agreed to in writing, software      |
+| distributed under the License is distributed on an "AS IS" BASIS,        |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and      |
+| limitations under the License.                                           |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.base.ui.command;
+
+import org.fortiss.tooling.base.model.layout.Point;
+import org.fortiss.tooling.base.model.layout.Points;
+import org.fortiss.tooling.base.ui.layout.IPointLayouter;
+
+/**
+ * Command that handles the creation of bend points.
+ * 
+ * @author hoelzl
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating RED Hash:
+ */
+public class CreateBendpointCommand extends BendpointCommandBase {
+
+	/** The {@link IPointLayouter}. */
+	private final IPointLayouter layouter;
+
+	/** Creates a bend point command. */
+	public CreateBendpointCommand(Points connection, int index, Point location,
+			IPointLayouter layouter) {
+		super(connection, index, location);
+		this.layouter = layouter;
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public void execute() {
+		if (layouter != null) {
+			layouter.doLayout(location);
+		}
+		connection.getPointsList().add(index, location);
+	}
+}
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/DeleteBendpointCommand.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/DeleteBendpointCommand.java
new file mode 100644
index 000000000..8f8ad814e
--- /dev/null
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/DeleteBendpointCommand.java
@@ -0,0 +1,41 @@
+/*--------------------------------------------------------------------------+
+$Id$
+|                                                                          |
+| Copyright 2011 ForTISS GmbH                     |
+|                                                                          |
+| Licensed under the Apache License, Version 2.0 (the "License");          |
+| you may not use this file except in compliance with the License.         |
+| You may obtain a copy of the License at                                  |
+|                                                                          |
+|    http://www.apache.org/licenses/LICENSE-2.0                            |
+|                                                                          |
+| Unless required by applicable law or agreed to in writing, software      |
+| distributed under the License is distributed on an "AS IS" BASIS,        |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and      |
+| limitations under the License.                                           |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.base.ui.command;
+
+import org.fortiss.tooling.base.model.layout.Points;
+
+/**
+ * Command that handles the deletion of bend points.
+ * 
+ * @author hoelzl
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating RED Hash:
+ */
+public class DeleteBendpointCommand extends BendpointCommandBase {
+	/** Creates a command to delete a bend point. */
+	public DeleteBendpointCommand(Points connection, int index) {
+		super(connection, index, null);
+	}
+
+	/** {@inheritDoc} */
+	@Override
+	public void execute() {
+		connection.getPointsList().remove(index);
+	}
+}
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/MoveBendpointCommand.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/MoveBendpointCommand.java
new file mode 100644
index 000000000..6b6d959f9
--- /dev/null
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/command/MoveBendpointCommand.java
@@ -0,0 +1,56 @@
+/*--------------------------------------------------------------------------+
+$Id$
+|                                                                          |
+| Copyright 2011 ForTISS GmbH                     |
+|                                                                          |
+| Licensed under the Apache License, Version 2.0 (the "License");          |
+| you may not use this file except in compliance with the License.         |
+| You may obtain a copy of the License at                                  |
+|                                                                          |
+|    http://www.apache.org/licenses/LICENSE-2.0                            |
+|                                                                          |
+| Unless required by applicable law or agreed to in writing, software      |
+| distributed under the License is distributed on an "AS IS" BASIS,        |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and      |
+| limitations under the License.                                           |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.base.ui.command;
+
+import org.fortiss.tooling.base.model.layout.Point;
+import org.fortiss.tooling.base.model.layout.Points;
+import org.fortiss.tooling.base.ui.layout.IPointLayouter;
+
+/**
+ * Command that handles move operations on bend points.
+ * 
+ * @author hoelzl
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating RED Hash:
+ */
+public class MoveBendpointCommand extends BendpointCommandBase {
+	/** The {@link IPointLayouter}. */
+	private final IPointLayouter layouter;
+
+	/** Create the move command. */
+	public MoveBendpointCommand(Points connection, int index, Point location,
+			IPointLayouter layouter) {
+		super(connection, index, location);
+		this.layouter = layouter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void execute() {
+		Point p = connection.getPoints(index);
+		p.setX(location.getX());
+		p.setY(location.getY());
+
+		if (layouter != null) {
+			layouter.doLayout(p);
+		}
+	}
+}
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/connector/RectangularConnectorEditPartBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/connector/RectangularConnectorEditPartBase.java
index 56094dbf9..5dfcdebf2 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/connector/RectangularConnectorEditPartBase.java
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/connector/RectangularConnectorEditPartBase.java
@@ -22,7 +22,9 @@ import java.util.List;
 
 import org.conqat.lib.commons.collections.CollectionUtils;
 import org.eclipse.draw2d.ChopboxAnchor;
+import org.eclipse.draw2d.ColorConstants;
 import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Ellipse;
 import org.eclipse.draw2d.Figure;
 import org.eclipse.draw2d.IFigure;
 import org.eclipse.draw2d.Label;
@@ -33,6 +35,7 @@ import org.fortiss.tooling.base.model.element.IConnector;
 import org.fortiss.tooling.base.model.element.IHierarchicElement;
 import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
 import org.fortiss.tooling.base.ui.editpart.ConnectorEditPartBase;
+import org.fortiss.tooling.base.ui.editpart.figure.AntiAliasedEllipse;
 import org.fortiss.tooling.base.ui.editpart.policy.ConnectionGraphicalNodeEditPolicy;
 import org.fortiss.tooling.base.ui.editpart.policy.RemoveEditPolicy;
 import org.fortiss.tooling.base.ui.layout.constants.RecommendedLayoutConstants;
@@ -85,7 +88,18 @@ public abstract class RectangularConnectorEditPartBase<T extends IConnector & IL
 	}
 
 	/** Creates the figure used for the connector. */
-	protected abstract IFigure createConnectorFigure();
+	protected IFigure createConnectorFigure() {
+		Ellipse connector = new AntiAliasedEllipse();
+
+		if (isReceiving()) {
+			connector.setBackgroundColor(ColorConstants.white);
+			connector.setForegroundColor(ColorConstants.black);
+		} else {
+			connector.setBackgroundColor(ColorConstants.black);
+			connector.setForegroundColor(ColorConstants.black);
+		}
+		return connector;
+	}
 
 	/** {@inheritDoc} */
 	@Override
@@ -94,7 +108,7 @@ public abstract class RectangularConnectorEditPartBase<T extends IConnector & IL
 	}
 
 	/** {@inheritDoc} */
-	@SuppressWarnings({ "unchecked", "rawtypes" })
+	@SuppressWarnings({ "unchecked" })
 	@Override
 	protected void refreshVisuals() {
 		super.refreshVisuals();
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/figure/AntiAliasedEllipse.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/figure/AntiAliasedEllipse.java
new file mode 100644
index 000000000..5d3441c65
--- /dev/null
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/editpart/figure/AntiAliasedEllipse.java
@@ -0,0 +1,40 @@
+/*--------------------------------------------------------------------------+
+$Id$
+|                                                                          |
+| Copyright 2011 ForTISS GmbH                     |
+|                                                                          |
+| Licensed under the Apache License, Version 2.0 (the "License");          |
+| you may not use this file except in compliance with the License.         |
+| You may obtain a copy of the License at                                  |
+|                                                                          |
+|    http://www.apache.org/licenses/LICENSE-2.0                            |
+|                                                                          |
+| Unless required by applicable law or agreed to in writing, software      |
+| distributed under the License is distributed on an "AS IS" BASIS,        |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and      |
+| limitations under the License.                                           |
++--------------------------------------------------------------------------*/
+package org.fortiss.tooling.base.ui.editpart.figure;
+
+import org.eclipse.draw2d.Ellipse;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.swt.SWT;
+
+/**
+ * An {@link Ellipse} with anti-aliasing enabled.
+ * 
+ * @author hoelzl
+ * @author $Author$
+ * @version $Rev$
+ * @ConQAT.Rating RED Hash:
+ */
+public class AntiAliasedEllipse extends Ellipse {
+
+	/** {@inheritDoc} */
+	@Override
+	public void paintFigure(Graphics graphics) {
+		graphics.setAntialias(SWT.ON);
+		super.paintFigure(graphics);
+	}
+}
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/IPointLayouter.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/IPointLayouter.java
index 9b03ec8f0..0f3482984 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/IPointLayouter.java
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/IPointLayouter.java
@@ -28,7 +28,6 @@ import org.fortiss.tooling.base.model.layout.Point;
  * @version $Rev$
  * @ConQAT.Rating RED Hash: D6B33EFB704B0CA151E1C945B5BC48C6
  */
-// TODO (FH): do we need this?
 public interface IPointLayouter {
 
 	/** Performs the layout task on the given {@link Point}. */
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/EditPartLayoutUtils.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/EditPartLayoutUtils.java
index f80cc4662..35d7e46c1 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/EditPartLayoutUtils.java
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/EditPartLayoutUtils.java
@@ -239,8 +239,7 @@ public class EditPartLayoutUtils {
 				.calculateRectangleBorderOrientation(position, d,
 						RecommendedLayoutConstants.RECTANGULAR_SHAPE_INSETS);
 		// snap to grid and store the value in the model
-		LayoutDataUtils.setConnectorOrientation(layouted,
-				orient.getOrientation());
+		LayoutDataUtils.setConnectorOrientation(layouted, orient);
 		LayoutDataUtils.setConnectorOffset(layouted,
 				EditPartLayoutUtils.snapToGrid(orient.getOffset()));
 	}
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/LayoutDataUtils.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/LayoutDataUtils.java
index 310c20212..6ccd45318 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/LayoutDataUtils.java
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/LayoutDataUtils.java
@@ -45,6 +45,36 @@ import org.fortiss.tooling.base.ui.layout.constants.RecommendedLayoutConstants;
  */
 public class LayoutDataUtils {
 
+	/** Creates a new {@link Point}. */
+	public static Point createPoint(int x, int y) {
+		Point p = LayoutFactory.eINSTANCE.createPoint();
+		p.setX(x);
+		p.setY(y);
+		return p;
+	}
+
+	/** Creates a new {@link Dimension}. */
+	public static Dimension createDimension(int w, int h) {
+		Dimension d = LayoutFactory.eINSTANCE.createDimension();
+		d.setWidth(w);
+		d.setHeight(h);
+		return d;
+	}
+
+	/** Translates the given point by moving it accordingly. */
+	public static Point translate(Point p, int dx, int dy) {
+		p.setX(p.getX() + dx);
+		p.setY(p.getY() + dy);
+		return p;
+	}
+
+	/** Expands the given dimension by resizing it accordingly. */
+	public static Dimension expand(Dimension d, int dw, int dh) {
+		d.setWidth(d.getWidth() + dw);
+		d.setHeight(d.getHeight() + dh);
+		return d;
+	}
+
 	/** Returns a {@link Point} layout data object with the given key or null. */
 	public static Point getPoint(ILayoutedModelElement lobject, String key) {
 		for (ILayoutData ld : lobject.getLayoutDataList()) {
@@ -210,6 +240,11 @@ public class LayoutDataUtils {
 		return null;
 	}
 
+	/** Returns a {@link Points} layout data object. */
+	public static Points getPoints(ILayoutedModelElement lobject) {
+		return getPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS);
+	}
+
 	/** Returns the bounds of the given layouted node. */
 	public static Rectangle getNodeBounds(ILayoutedModelElement layouted) {
 		Rectangle result = new Rectangle();
@@ -283,30 +318,30 @@ public class LayoutDataUtils {
 	}
 
 	/** Returns the layouted connector's orientation. */
-	public static EOrientation getConnectorOrientation(
+	public static Orientation getConnectorOrientation(
 			ILayoutedModelElement layouted) {
 		Orientation orientation = getOrientation(layouted,
 				LayoutKeyConstants.CONNECTOR_ORIENTATION);
 		if (orientation == null) {
-			return EOrientation.NORTH;
+			return OrientationUtils.createOrientation(EOrientation.NORTH);
 		}
-		return orientation.getOrientation();
+		return orientation;
 	}
 
 	/** Sets the layouted connector's orientation. */
 	public static void setConnectorOrientation(ILayoutedModelElement layouted,
-			EOrientation orientation) {
+			Orientation orientation) {
 		setOrientation(layouted, LayoutKeyConstants.CONNECTOR_ORIENTATION,
-				orientation);
+				orientation.getOrientation());
 	}
 
 	/** Returns the layouted connector's offset. */
-	public static int getConnectorOffset(ILayoutedModelElement layouted) {
+	public static Offset getConnectorOffset(ILayoutedModelElement layouted) {
 		Offset offset = getOffset(layouted, LayoutKeyConstants.CONNECTOR_OFFSET);
 		if (offset == null) {
-			return 0;
+			return OrientationUtils.createOffset(0);
 		}
-		return offset.getOffset();
+		return offset;
 	}
 
 	/** Sets the layouted connector's angle. */
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/OrientationUtils.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/OrientationUtils.java
index d1dc078c8..475a3f6f8 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/OrientationUtils.java
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/layout/util/OrientationUtils.java
@@ -17,13 +17,13 @@ $Id$
 +--------------------------------------------------------------------------*/
 package org.fortiss.tooling.base.ui.layout.util;
 
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
+import org.fortiss.tooling.base.model.layout.Dimension;
 import org.fortiss.tooling.base.model.layout.EOrientation;
 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.Orientation;
+import org.fortiss.tooling.base.model.layout.Point;
 import org.fortiss.tooling.base.ui.layout.constants.RecommendedLayoutConstants;
 
 /**
@@ -40,20 +40,24 @@ public class OrientationUtils {
 	/** Return the absolute position for a given orientation. */
 	public static Point getAbsolute(Orientation orientation, Offset offset,
 			Dimension parentSize, int parentInsets) {
-		Point pos = new Point(0, 0);
+		Point pos = LayoutDataUtils.createPoint(0, 0);
 		int offsetValue = offset.getOffset();
 		switch (orientation.getOrientation()) {
 		case NORTH:
-			pos.setLocation(offsetValue, 0);
+			pos.setX(offsetValue);
+			pos.setY(0);
 			break;
 		case WEST:
-			pos.setLocation(0, offsetValue);
+			pos.setX(0);
+			pos.setY(offsetValue);
 			break;
 		case SOUTH:
-			pos.setLocation(offsetValue, parentSize.height - 2 * parentInsets);
+			pos.setX(offsetValue);
+			pos.setY(parentSize.getHeight() - 2 * parentInsets);
 			break;
 		case EAST:
-			pos.setLocation(parentSize.width - 2 * parentInsets, offsetValue);
+			pos.setX(parentSize.getWidth() - 2 * parentInsets);
+			pos.setY(offsetValue);
 			break;
 		}
 
@@ -86,4 +90,11 @@ public class OrientationUtils {
 		o.setOrientation(orientation);
 		return o;
 	}
+
+	/** Returns a new Offset object with the given value. */
+	public static Offset createOffset(int offset) {
+		Offset o = LayoutFactory.eINSTANCE.createOffset();
+		o.setOffset(offset);
+		return o;
+	}
 }
-- 
GitLab