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

soem cleanup

refs 311
parent 7146b43f
No related branches found
No related tags found
No related merge requests found
......@@ -17,11 +17,19 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.layout;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH;
import static org.fortiss.tooling.base.ui.utils.EllipseLayoutUtils.calculateEllipseBorderPoint;
import static org.fortiss.tooling.base.ui.utils.EllipseLayoutUtils.clampEllipseShapeSize;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.getConnectorAngleAsDouble;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUtils.getNodeSize;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
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.editpart.StickyConnectorEditPartBase;
......@@ -46,10 +54,12 @@ public class EllipseCurveLayoutDiagramConfiguration extends
/** Shared instance. */
public static final EllipseCurveLayoutDiagramConfiguration INSTANCE = new EllipseCurveLayoutDiagramConfiguration();
/** Half size of default connector. */
private static final int HALF_DEFAULT_CONNECTOR_SIZE = DEFAULT_CONNECTOR_SIZE / 2;
/** The minimal size. */
private static final Dimension MINIMUM_SIZE = new Dimension(
DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH,
DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT);
DEFAULT_SHAPE_MINIMUM_WIDTH, DEFAULT_SHAPE_MINIMUM_HEIGHT);
/** {@inheritDoc} */
@Override
......@@ -63,22 +73,21 @@ public class EllipseCurveLayoutDiagramConfiguration extends
StickyConnectorEditPartBase<? extends ILayoutedModelElement> connectorEditPart,
ChangeBoundsRequest request) {
ILayoutedModelElement connector = connectorEditPart.getModel();
double angle = LayoutDataUtils.getConnectorAngleAsDouble(connector);
double angle = getConnectorAngleAsDouble(connector);
Dimension stateSize = new Dimension(10, 10);
if (connector.eContainer() instanceof ILayoutedModelElement) {
org.fortiss.tooling.base.model.layout.Dimension parentSize = LayoutDataUtils
.getNodeSize((ILayoutedModelElement) connector.eContainer());
org.fortiss.tooling.base.model.layout.Dimension parentSize = getNodeSize((ILayoutedModelElement) connector
.eContainer());
stateSize.setWidth(parentSize.getWidth());
stateSize.setHeight(parentSize.getHeight());
}
Point oldPosition = EllipseLayoutUtils.calculateEllipseBorderPoint(
angle, stateSize,
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2);
Point oldPosition = calculateEllipseBorderPoint(angle, stateSize,
HALF_DEFAULT_CONNECTOR_SIZE);
Point newPosition = oldPosition.getTranslated(request.getMoveDelta())
.translate(DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2,
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2);
.translate(HALF_DEFAULT_CONNECTOR_SIZE,
HALF_DEFAULT_CONNECTOR_SIZE);
Dimension ellipseSize = connectorEditPart.getParentEditPart()
.getFigure().getSize();
newPosition.translate(ellipseSize.getScaled(-.5));
......@@ -108,23 +117,19 @@ public class EllipseCurveLayoutDiagramConfiguration extends
}
Point oldPosition = EllipseLayoutUtils.calculateEllipseBorderPoint(
angle, stateSize,
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2).translate(
-DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2,
-DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2);
angle, stateSize, HALF_DEFAULT_CONNECTOR_SIZE).translate(
-HALF_DEFAULT_CONNECTOR_SIZE, -HALF_DEFAULT_CONNECTOR_SIZE);
Point newPosition = oldPosition.getTranslated(request.getMoveDelta());
Dimension ellipseSize = connectorEditPart.getParentEditPart()
.getFigure().getSize();
newPosition.translate(ellipseSize.getScaled(-.5));
newPosition.translate(
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2,
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2);
newPosition.translate(HALF_DEFAULT_CONNECTOR_SIZE,
HALF_DEFAULT_CONNECTOR_SIZE);
newPosition = EllipseLayoutUtils.calculateEllipseBorderPoint(
new EllipseLayoutUtils.Polar(newPosition).angle, ellipseSize,
DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2).translate(
-DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2,
-DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE / 2);
HALF_DEFAULT_CONNECTOR_SIZE).translate(
-HALF_DEFAULT_CONNECTOR_SIZE, -HALF_DEFAULT_CONNECTOR_SIZE);
request.setMoveDelta(new Point().translate(newPosition
.getDifference(oldPosition)));
......@@ -135,6 +140,16 @@ public class EllipseCurveLayoutDiagramConfiguration extends
public void alterElementMoveAndResizeFeedbackRequest(
ChangeBoundsRequest request,
ElementEditPartBase<? extends ILayoutedModelElement> elementEditPart) {
// TODO (FH): aspect ratio computation
Dimension oldSizeDelta = request.getSizeDelta();
Rectangle elementBounds = elementEditPart.getFigure().getBounds();
Dimension oldSize = new Dimension(elementBounds.width
+ oldSizeDelta.width, elementBounds.height
+ oldSizeDelta.height);
Dimension newSize = clampEllipseShapeSize(oldSize,
request.getResizeDirection());
Dimension newSizeDelta = new Dimension(newSize.width
- elementBounds.width, newSize.height - elementBounds.height);
request.setSizeDelta(newSizeDelta);
}
}
......@@ -49,11 +49,11 @@ import org.fortiss.tooling.base.ui.utils.SnapToGridUtils;
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 27AF66FD6AE57B1AAC4B6D0C606378C2
*/
public class ManhattanLayoutDiagramConfiguration extends
public class RectangleGridLayoutDiagramConfiguration extends
DiagramLayoutConfigurationBase {
/** Shared instance. */
public static final ManhattanLayoutDiagramConfiguration INSTANCE = new ManhattanLayoutDiagramConfiguration();
public static final RectangleGridLayoutDiagramConfiguration INSTANCE = new RectangleGridLayoutDiagramConfiguration();
/** The minimal size. */
private static final Dimension MINIMUM_SIZE = new Dimension(
......
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