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

rework of layout data utils

refs 214
parent a87ee6cc
No related branches found
No related tags found
No related merge requests found
Showing
with 100 additions and 88 deletions
......@@ -21,6 +21,5 @@ Export-Package: org.fortiss.tooling.base.ui,
org.fortiss.tooling.base.ui.editpart.figure,
org.fortiss.tooling.base.ui.editpart.policy,
org.fortiss.tooling.base.ui.layout,
org.fortiss.tooling.base.ui.layout.constants,
org.fortiss.tooling.base.ui.layout.util,
org.fortiss.tooling.base.ui.preferences
org.fortiss.tooling.base.ui.preferences,
org.fortiss.tooling.base.ui.utils
......@@ -25,7 +25,7 @@ import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.editpart.ConnectorEditPartBase;
import org.fortiss.tooling.base.ui.editpart.LayoutedConnectionEditPartBase;
import org.fortiss.tooling.base.ui.layout.util.LayoutDataUtils;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
/**
* A {@link Command} storing a {@link ChangeBoundsRequest}.
......
......@@ -20,7 +20,7 @@ package org.fortiss.tooling.base.ui.command;
import org.eclipse.draw2d.geometry.Point;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.layout.IPointLayouter;
import org.fortiss.tooling.base.ui.layout.util.LayoutDataUtils;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
/**
* Command that handles the creation of bend points.
......
......@@ -18,7 +18,7 @@ $Id$
package org.fortiss.tooling.base.ui.command;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.layout.util.LayoutDataUtils;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
/**
* Command that handles the deletion of bend points.
......
......@@ -20,7 +20,7 @@ package org.fortiss.tooling.base.ui.command;
import org.eclipse.draw2d.geometry.Point;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.layout.IPointLayouter;
import org.fortiss.tooling.base.ui.layout.util.LayoutDataUtils;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
/**
* Command that handles move operations on bend points.
......
......@@ -21,12 +21,12 @@ import java.util.List;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.fortiss.tooling.base.layout.LayoutKeyConstants;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.OffsetOrientation;
import org.fortiss.tooling.base.ui.editpart.FreeConnectorEditPartBase;
import org.fortiss.tooling.base.ui.editpart.StickyConnectorEditPartBase;
import org.fortiss.tooling.base.ui.layout.constants.LayoutKeyConstants;
import org.fortiss.tooling.base.ui.layout.util.LayoutDataUtils;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
/**
* A command to move connectors. The operation is performed differently for
......
......@@ -21,9 +21,9 @@ import java.util.List;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.editpart.ElementEditPartBase;
import org.fortiss.tooling.base.ui.layout.constants.DefaultLayoutConstants;
/**
* A command to move the elements within a diagram.
......
......@@ -23,6 +23,7 @@ import java.util.List;
import org.conqat.ide.commons.gef.editpart.EditPartUtils;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditDomain;
import org.eclipse.gef.EditPart;
......@@ -66,6 +67,7 @@ import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.ui.ToolingBaseUIActivator;
import org.fortiss.tooling.base.ui.action.CopyModelElementsAction;
import org.fortiss.tooling.base.ui.action.CutModelElementsAction;
......@@ -74,7 +76,6 @@ import org.fortiss.tooling.base.ui.action.PasteModelElementAction;
import org.fortiss.tooling.base.ui.dnd.DropTargetListener;
import org.fortiss.tooling.base.ui.editpart.ExtendedLayerRootEditPart;
import org.fortiss.tooling.base.ui.editpart.figure.EVisualStyle;
import org.fortiss.tooling.base.ui.layout.constants.DefaultLayoutConstants;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
import org.fortiss.tooling.kernel.ui.service.IEditPartFactoryService;
......@@ -175,8 +176,9 @@ public class GraphicalViewerEditorBase<T extends EObject> extends EditorBase<T>
viewer.getControl().setBackground(parent.getBackground());
viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);
viewer.setProperty(SnapToGrid.PROPERTY_GRID_ORIGIN,
DefaultLayoutConstants.DEFAULT_GRID_ORIGIN);
viewer.setProperty(SnapToGrid.PROPERTY_GRID_ORIGIN, new Point(
DefaultLayoutConstants.DEFAULT_GRID_ORIGIN_X,
DefaultLayoutConstants.DEFAULT_GRID_ORIGIN_Y));
Dimension gridSpacing = new Dimension(
DefaultLayoutConstants.DEFAULT_GRID_SIZE,
......
......@@ -34,6 +34,7 @@ import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.swt.graphics.Color;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
......@@ -43,8 +44,7 @@ import org.fortiss.tooling.base.ui.editpart.figure.AntiAliasedEllipse;
import org.fortiss.tooling.base.ui.editpart.figure.TransparentLabel;
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.DefaultLayoutConstants;
import org.fortiss.tooling.base.ui.layout.util.LayoutDataUtils;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
......
......@@ -46,7 +46,7 @@ import org.eclipse.gef.tools.MarqueeDragTracker;
import org.eclipse.swt.SWT;
import org.fortiss.tooling.base.ui.editpart.policy.ConnectionGraphicalNodeEditPolicy;
import org.fortiss.tooling.base.ui.editpart.policy.DiagramLayoutEditPolicy;
import org.fortiss.tooling.base.ui.layout.util.SnapToGridUtils;
import org.fortiss.tooling.base.ui.utils.SnapToGridUtils;
/**
* The base class for graphical diagrams.
......
......@@ -19,6 +19,7 @@ package org.fortiss.tooling.base.ui.editpart;
import java.util.List;
import org.conqat.ide.commons.ui.swt.FontUtils;
import org.conqat.lib.commons.string.StringUtils;
import org.eclipse.draw2d.ChopboxAnchor;
import org.eclipse.draw2d.ConnectionAnchor;
......@@ -30,14 +31,17 @@ import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.SnapToHelper;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.editpart.figure.TransparentLabel;
import org.fortiss.tooling.base.ui.editpart.policy.ConnectionGraphicalNodeEditPolicy;
import org.fortiss.tooling.base.ui.editpart.policy.ElementLayoutEditPolicy;
import org.fortiss.tooling.base.ui.editpart.policy.RemoveEditPolicy;
import org.fortiss.tooling.base.ui.layout.constants.DefaultLayoutConstants;
import org.fortiss.tooling.base.ui.layout.util.LayoutDataUtils;
import org.fortiss.tooling.base.ui.layout.util.SnapToGridUtils;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
import org.fortiss.tooling.base.ui.utils.SnapToGridUtils;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
......@@ -58,6 +62,10 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
public abstract class ElementEditPartBase<T extends ILayoutedModelElement & INamedCommentedElement>
extends PositionedEditPartBase<T> {
/** The default font for titles. */
public static Font DEFAULT_TITLE_FONT = FontUtils.derive(
JFaceResources.getDefaultFont(), 0, SWT.BOLD);
/** Constructor. */
protected ElementEditPartBase(T modelObject) {
super(modelObject);
......@@ -68,7 +76,7 @@ public abstract class ElementEditPartBase<T extends ILayoutedModelElement & INam
public Label createLabelFigure() {
Label nameLabel = new TransparentLabel();
nameLabel.setForegroundColor(getForegroundColor());
nameLabel.setFont(DefaultLayoutConstants.TITLE_FONT);
nameLabel.setFont(DEFAULT_TITLE_FONT);
nameLabel.setTextAlignment(PositionConstants.LEFT
| PositionConstants.TOP);
nameLabel.setTextPlacement(PositionConstants.EAST);
......
......@@ -32,13 +32,13 @@ import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.model.base.ConnectionSegmentBase;
import org.fortiss.tooling.base.model.layout.LayoutPackage;
import org.fortiss.tooling.base.model.layout.Point;
import org.fortiss.tooling.base.model.layout.Points;
import org.fortiss.tooling.base.ui.editpart.policy.RemoveEditPolicy;
import org.fortiss.tooling.base.ui.layout.constants.DefaultLayoutConstants;
import org.fortiss.tooling.base.ui.layout.util.LayoutDataUtils;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
/**
* The base class for all layouted connection edit parts. This makes sure the
......
......@@ -18,11 +18,11 @@ $Id$
package org.fortiss.tooling.base.ui.editpart;
import org.eclipse.draw2d.geometry.Rectangle;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.model.base.EntryConnectorBase;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.layout.constants.DefaultLayoutConstants;
import org.fortiss.tooling.base.ui.layout.util.RectangleLayoutUtils;
import org.fortiss.tooling.base.ui.utils.RectangleLayoutUtils;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
......
......@@ -28,7 +28,7 @@ import org.fortiss.tooling.base.ui.command.DeleteBendpointCommand;
import org.fortiss.tooling.base.ui.command.MoveBendpointCommand;
import org.fortiss.tooling.base.ui.editpart.ConnectionEditPartBase;
import org.fortiss.tooling.base.ui.layout.IPointLayouter;
import org.fortiss.tooling.base.ui.layout.util.SnapToGridUtils;
import org.fortiss.tooling.base.ui.utils.SnapToGridUtils;
/**
* An edit policy for bend points of connections.
......
......@@ -24,15 +24,15 @@ import org.eclipse.gef.Request;
import org.eclipse.gef.editparts.ScalableRootEditPart;
import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.layout.LayoutKeyConstants;
import org.fortiss.tooling.base.model.layout.Dimension;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.OffsetOrientation;
import org.fortiss.tooling.base.ui.editpart.ElementEditPartBase;
import org.fortiss.tooling.base.ui.layout.constants.DefaultLayoutConstants;
import org.fortiss.tooling.base.ui.layout.constants.LayoutKeyConstants;
import org.fortiss.tooling.base.ui.layout.util.LayoutDataUtils;
import org.fortiss.tooling.base.ui.layout.util.RectangleLayoutUtils;
import org.fortiss.tooling.base.ui.layout.util.SnapToGridUtils;
import org.fortiss.tooling.base.ui.utils.LayoutDataUtils;
import org.fortiss.tooling.base.ui.utils.RectangleLayoutUtils;
import org.fortiss.tooling.base.ui.utils.SnapToGridUtils;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
......
......@@ -26,7 +26,7 @@ import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.fortiss.tooling.base.ui.command.MoveWithinDiagramCommand;
import org.fortiss.tooling.base.ui.editpart.ElementEditPartBase;
import org.fortiss.tooling.base.ui.layout.util.ZoomUtils;
import org.fortiss.tooling.base.ui.utils.ZoomUtils;
/**
* The layout policy for diagrams.
......
......@@ -27,7 +27,7 @@ import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.command.MoveConnectorCommand;
import org.fortiss.tooling.base.ui.editpart.ElementEditPartBase;
import org.fortiss.tooling.base.ui.editpart.StickyConnectorEditPartBase;
import org.fortiss.tooling.base.ui.layout.util.ZoomUtils;
import org.fortiss.tooling.base.ui.utils.ZoomUtils;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
......
......@@ -22,7 +22,7 @@ import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.gef.Request;
import org.eclipse.gef.editpolicies.ResizableEditPolicy;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.fortiss.tooling.base.ui.layout.util.RectangleLayoutUtils;
import org.fortiss.tooling.base.ui.utils.RectangleLayoutUtils;
/**
* EditPolicy for child resizing without a fixed aspect ratio.
......
......@@ -15,13 +15,13 @@ $Id$
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.layout.util;
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.fortiss.tooling.base.layout.DefaultLayoutConstants;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.ui.layout.constants.DefaultLayoutConstants;
/**
* Utility methods for ellipse-shaped edit part layout.
......@@ -29,7 +29,7 @@ import org.fortiss.tooling.base.ui.layout.constants.DefaultLayoutConstants;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: 29FAC994522C13BC65F8538F36B6CFDA
* @ConQAT.Rating YELLOW Hash: 80B631B5B2032BFAD1D1161DC0549957
*/
public final class EllipseLayoutUtils {
/**
......@@ -154,8 +154,9 @@ public final class EllipseLayoutUtils {
/** Returns a cartesian representation. */
public Point toCartesian() {
return new Point(distance * Math.cos(angle), distance
* Math.sin(angle));
int x = (int) (distance * Math.cos(angle));
int y = (int) (distance * Math.sin(angle));
return new Point(x, y);
}
}
}
......@@ -15,22 +15,27 @@ $Id$
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.layout.util;
package org.fortiss.tooling.base.ui.utils;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
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;
import org.fortiss.tooling.base.model.layout.Points;
import org.fortiss.tooling.base.ui.layout.constants.DefaultLayoutConstants;
import org.fortiss.tooling.base.ui.layout.constants.LayoutKeyConstants;
import org.fortiss.tooling.base.utils.AngleUtils;
import org.fortiss.tooling.base.utils.DimensionUtils;
import org.fortiss.tooling.base.utils.LayoutModelElementFactory;
import org.fortiss.tooling.base.utils.OffsetOrientationUtils;
import org.fortiss.tooling.base.utils.PointUtils;
import org.fortiss.tooling.base.utils.PointsUtils;
/**
* Utility methods for {@link ILayoutedModelElement} and {@link ILayoutData}.
......@@ -68,14 +73,14 @@ public class LayoutDataUtils {
/** Returns the position of the given layouted node. */
public static Point getNodePosition(ILayoutedModelElement layouted) {
return PointUtil
.getPosition(layouted, LayoutKeyConstants.NODE_POSITION);
return PointUtils.getPosition(layouted,
LayoutKeyConstants.NODE_POSITION);
}
/** Sets the layouted node's position. */
public static void setNodePosition(ILayoutedModelElement layouted, int x,
int y) {
PointUtil.setPoint(layouted, LayoutKeyConstants.NODE_POSITION, x, y);
PointUtils.setPoint(layouted, LayoutKeyConstants.NODE_POSITION, x, y);
}
/**
......@@ -83,14 +88,14 @@ public class LayoutDataUtils {
* the given element a new dimension with the default size is returned.
*/
public static Dimension getNodeSize(ILayoutedModelElement layouted) {
Dimension size = DimensionUtil.getDimension(layouted,
Dimension size = DimensionUtils.getDimension(layouted,
LayoutKeyConstants.NODE_DIMENSION);
if (size == null) {
Dimension result = DimensionUtil.createDimension(
Dimension result = LayoutModelElementFactory.createDimension(
DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH,
DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT);
result.setKey(LayoutKeyConstants.NODE_DIMENSION);
DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT,
LayoutKeyConstants.NODE_DIMENSION);
return result;
}
return EcoreUtil.copy(size);
......@@ -98,8 +103,8 @@ public class LayoutDataUtils {
/** Sets the layouted node's size. */
public static void setNodeSize(ILayoutedModelElement layouted, int w, int h) {
DimensionUtil.setDimension(layouted, LayoutKeyConstants.NODE_DIMENSION,
w, h);
DimensionUtils.setDimension(layouted,
LayoutKeyConstants.NODE_DIMENSION, w, h);
}
/** Moves the given node. */
......@@ -139,25 +144,26 @@ public class LayoutDataUtils {
/** Returns the layouted connector's position. */
public static Point getConnectorPosition(ILayoutedModelElement layouted) {
return PointUtil.getPosition(layouted,
return PointUtils.getPosition(layouted,
LayoutKeyConstants.CONNECTOR_POSITION);
}
/** Sets the layouted connector's position. */
public static void setConnectorPosition(ILayoutedModelElement layouted,
int x, int y) {
PointUtil.setPoint(layouted, LayoutKeyConstants.CONNECTOR_POSITION, x,
PointUtils.setPoint(layouted, LayoutKeyConstants.CONNECTOR_POSITION, x,
y);
}
/** Returns the layouted connector's orientation. */
public static OffsetOrientation getConnectorOffsetOrientation(
ILayoutedModelElement layouted) {
OffsetOrientation oo = OffsetOrientationUtil.getOffsetOrientation(
OffsetOrientation oo = OffsetOrientationUtils.getOffsetOrientation(
layouted, LayoutKeyConstants.CONNECTOR_OFFSET_ORIENTATION);
if (oo == null) {
return OffsetOrientationUtil.createOffsetOrientation(0,
EOrientation.NORTH);
return LayoutModelElementFactory.createOffsetOrientation(0,
EOrientation.NORTH,
LayoutKeyConstants.CONNECTOR_OFFSET_ORIENTATION);
}
return oo;
}
......@@ -165,18 +171,18 @@ public class LayoutDataUtils {
/** Sets the layouted connector's offset and orientation. */
public static void setConnectorOffsetOrientation(
ILayoutedModelElement layouted, OffsetOrientation orientation) {
OffsetOrientationUtil.setOffsetOrientation(layouted,
OffsetOrientationUtils.setOffsetOrientation(layouted,
LayoutKeyConstants.CONNECTOR_OFFSET_ORIENTATION,
orientation.getOffset(), orientation.getOrientation());
}
/** Returns the layouted connector's offset. */
public static Offset getConnectorOffset(ILayoutedModelElement layouted) {
OffsetOrientation offset = OffsetOrientationUtil.getOffsetOrientation(
OffsetOrientation offset = OffsetOrientationUtils.getOffsetOrientation(
layouted, LayoutKeyConstants.CONNECTOR_OFFSET);
if (offset == null) {
return OffsetOrientationUtil.createOffsetOrientation(0,
EOrientation.NORTH);
return LayoutModelElementFactory.createOffsetOrientation(0,
EOrientation.NORTH, LayoutKeyConstants.CONNECTOR_OFFSET);
}
return offset;
}
......@@ -184,15 +190,17 @@ public class LayoutDataUtils {
/** Sets the layouted connector's angle. */
public static void setConnectorAngle(ILayoutedModelElement layouted,
double angle) {
AngleUtil.setAngle(layouted, LayoutKeyConstants.CONNECTOR_ANGLE, angle);
AngleUtils
.setAngle(layouted, LayoutKeyConstants.CONNECTOR_ANGLE, angle);
}
/** Returns the layouted connector's angle. */
public static Angle getConnectorAngle(ILayoutedModelElement layouted) {
Angle angle = AngleUtil.getAngle(layouted,
Angle angle = AngleUtils.getAngle(layouted,
LayoutKeyConstants.CONNECTOR_ANGLE);
if (angle == null) {
return AngleUtil.createAngle(0.0);
return LayoutModelElementFactory.createAngle(0.0,
LayoutKeyConstants.CONNECTOR_ANGLE);
}
return angle;
}
......@@ -202,24 +210,17 @@ public class LayoutDataUtils {
return getConnectorAngle(lobject).getAngle();
}
/** Creates a new connection layout. */
public static void createConnectionLayout(ILayoutedModelElement lo) {
Points points = PointsUtil.createPoints();
points.setKey(LayoutKeyConstants.CONNECTION_POINTS);
lo.getLayoutDataList().add(points);
}
/** Creates a new connector layout. */
public static void createConnectorLayout(ILayoutedModelElement lo) {
setNodePosition(lo, 0, 0);
setNodeSize(lo, DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH,
DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT);
Point cpos = LayoutFactory.eINSTANCE.createPoint();
cpos.setKey(LayoutKeyConstants.CONNECTOR_POSITION);
Point cpos = LayoutModelElementFactory.createPoint(0, 0,
LayoutKeyConstants.CONNECTOR_POSITION);
Dimension cdim = LayoutFactory.eINSTANCE.createDimension();
cdim.setKey(LayoutKeyConstants.CONNECTOR_DIMENSION);
Dimension cdim = LayoutModelElementFactory.createDimension(0, 0,
LayoutKeyConstants.CONNECTOR_DIMENSION);
lo.getLayoutDataList().add(cpos);
lo.getLayoutDataList().add(cdim);
......@@ -228,7 +229,7 @@ public class LayoutDataUtils {
/** Return the absolute position for a given offset, orientation and insets. */
public static Point getAbsolute(OffsetOrientation oo, Dimension parentSize,
int parentInsets) {
Point pos = PointUtil.createPoint(0, 0);
Point pos = LayoutModelElementFactory.createPoint(0, 0, null);
int offsetValue = oo.getOffset();
switch (oo.getOrientation()) {
case NORTH:
......@@ -253,7 +254,7 @@ public class LayoutDataUtils {
/** Returns the {@link Points} layout data object for the given connection. */
public static Points getConnectionPoints(ILayoutedModelElement lobject) {
return PointsUtil.getPoints(lobject,
return PointsUtils.getPoints(lobject,
LayoutKeyConstants.CONNECTION_POINTS);
}
......@@ -261,33 +262,34 @@ public class LayoutDataUtils {
public static void addConnectionPoint(ILayoutedModelElement lobject, int x,
int y) {
Points pts = getConnectionPoints(lobject);
Point np = PointUtil.createPoint(x, y);
Point np = LayoutModelElementFactory.createPoint(x, y, null);
pts.getPointsList().add(np);
PointsUtil
.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS, pts);
PointsUtils.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS,
pts);
}
/** Changes the point of the layout data at the given index. */
public static void changeConnectionPoint(ILayoutedModelElement lobject,
int index, int x, int y) {
Points pts = getConnectionPoints(lobject);
Point np = PointUtil.createPoint(x, y);
Point np = LayoutModelElementFactory.createPoint(x, y, null);
pts.getPointsList().set(index, np);
PointsUtil
.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS, pts);
PointsUtils.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS,
pts);
}
/** Changes all the point layout data of the given element. */
public static void changeAllConnectionPoints(ILayoutedModelElement lobject,
int dx, int dy) {
Points pts = getConnectionPoints(lobject);
Points npts = PointsUtil.createPoints();
Points npts = LayoutModelElementFactory.createPoints(null);
for (Point p : pts.getPointsList()) {
Point np = PointUtil.createPoint(p.getX() + dx, p.getY() + dy);
Point np = LayoutModelElementFactory.createPoint(p.getX() + dx,
p.getY() + dy, null);
npts.getPointsList().add(np);
}
PointsUtil
.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS, pts);
PointsUtils.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS,
pts);
}
/**
......@@ -298,8 +300,8 @@ public class LayoutDataUtils {
int index) {
Points pts = getConnectionPoints(lobject);
pts.getPointsList().remove(index);
PointsUtil
.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS, pts);
PointsUtils.setPoints(lobject, LayoutKeyConstants.CONNECTION_POINTS,
pts);
}
}
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