Skip to content
Snippets Groups Projects
Commit b3724a7b authored by Tiziano Munaro's avatar Tiziano Munaro
Browse files

Refactor base classes for curved links in LWFXEF-based diagrams

parent 12d93413
No related branches found
No related tags found
1 merge request!88[3873] Ellipses and Bezier curves
ContextMenuUtil.java 7be87ce47b775d90c533078e22d4d445d9864caf GREEN
CurvedLinkLayoutedContentAnchorangeController.java a26b82ad25e44ef14d8857f11b48087471a74c42 YELLOW
EObjectDiagramController.java 66b14c1c77953cad7caecae1e04f455958943f28 GREEN
EObjectEllipticResizableContentControllerBase.java 2af976ea7f426953f3f9238a735991aea0d0a66f YELLOW
EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN
......
/*-------------------------------------------------------------------------+
| Copyright 2020 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.editor.fx.controller;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.addConnectionPoint;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.DelegatingContentAnchorageController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
/**
* {@link DelegatingContentAnchorageController} for diagrams with curved links.
*
* @author munaro
*/
public class CurvedLinkLayoutedContentAnchorangeController<T extends IConnector & ILayoutedModelElement>
extends LayoutedContentAnchorageController<T> {
/** Constructor. */
public CurvedLinkLayoutedContentAnchorangeController(IContentAnchorageMVCBundle mvcb,
Class<T> modelType) {
super(mvcb, modelType);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected void link(IMVCBundle startBundle, DiagramCoordinate startLocation,
IMVCBundle endBundle, DiagramCoordinate endLocation) {
super.link(startBundle, startLocation, endBundle, endLocation);
// Fetch newly created connection by comparing incoming and outgoing connections of the
// given connectors. As only one connection is allowed between a pair of connectors, this
// 'findFirst' is safe.
T startConnector = (T)startBundle.getModel();
T endConnector = (T)endBundle.getModel();
IConnection connection = startConnector.getOutgoing().stream()
.filter(segment -> endConnector.getIncoming().contains(segment)).findFirst().get();
// Create handles
DiagramCoordinate startPosition =
new DiagramCoordinate(startBundle.getVisual().getCurrentBounds().getMaxX(),
startBundle.getVisual().getCurrentBounds().getMaxY());
DiagramCoordinate endPosition =
new DiagramCoordinate(endBundle.getVisual().getCurrentBounds().getMaxX(),
endBundle.getVisual().getCurrentBounds().getMaxY());
DiagramCoordinate middle =
new DiagramCoordinate((startPosition.getX() + endPosition.getX()) / 2,
(startPosition.getY() + endPosition.getY()) / 2);
addConnectionPoint((ILayoutedModelElement)connection, 0, (int)middle.getX(),
(int)middle.getY());
addConnectionPoint((ILayoutedModelElement)connection, 1, (int)middle.getX(),
(int)middle.getY());
}
}
CoordinateCorrections.java c5cc475b45de38c56fc2e888a2d3093cd2efb52a GREEN
LayoutedCircularAnchorageContentVisualBase.java 2aa292444671bf644e37bc923b877c92de0235b1 GREEN
LayoutedCircularAnchorageContentVisualBase.java 66c979798086b4022e65a550d503c0393afc15f5 YELLOW
LayoutedCircularAnchorageDiagramVisualBase.java f06e3b908020408e3cd268a3c63edcd75ef74f8b GREEN
LayoutedCurveLinkVisual.java 7344139cd451f8d9d3b57e9cc32482753e8e53ed YELLOW
LayoutedCurveLinkVisual.java b735e1918155c5bbe29d11b3b2ee220f15701bd9 YELLOW
LayoutedEllipticContentVisualBase.java a06403f2c2245e017dc76e902a2b71ed124fedd1 YELLOW
LayoutedLineLinkVisual.java 3f6fa536b3e767590e95faeaf07b72df16e5e718 YELLOW
LayoutedLineLinkVisual.java be64f9aacf04a500caded93fddeff43db6c59d88 YELLOW
LayoutedRectangularContentVisualBase.java c2a3937b99284713e0bbcd3ce458874567b25ac5 GREEN
NamedLayoutedCircularAnchorageContentVisual.java c680002469ce897679fa5a3f4af51d1b19cb53d6 GREEN
NamedLayoutedCircularAnchorageDiagramVisual.java 714a176a0569a2049efb4009f710ca66bf3a57fb GREEN
......
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx.visual;
import static java.lang.Math.toDegrees;
import static javafx.scene.paint.Color.BLACK;
import static javafx.scene.paint.Color.rgb;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_ALLOWED_TAG;
......@@ -22,8 +23,10 @@ import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramView
import static org.fortiss.tooling.base.ui.editor.fx.visual.CoordinateCorrections.ANCHOR_DIMENSION;
import static org.fortiss.tooling.base.ui.editor.fx.visual.CoordinateCorrections.ANCHOR_INSET;
import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.convertEOrientationToSide;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorAngleAsDouble;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorOffsetOrientation;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.IAngleLayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.ILayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.IOffsetLayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.ISideLayout;
......@@ -47,7 +50,8 @@ import javafx.scene.paint.Paint;
* @author munaro
*/
public abstract class LayoutedCircularAnchorageContentVisualBase<T extends ILayoutedModelElement>
extends CircularContentAnchorageVisualBase implements ISideLayout, IOffsetLayout {
extends CircularContentAnchorageVisualBase
implements ISideLayout, IOffsetLayout, IAngleLayout {
/** Constructor. */
public LayoutedCircularAnchorageContentVisualBase(IContentAnchorageMVCBundle mvcb,
......@@ -149,4 +153,11 @@ public abstract class LayoutedCircularAnchorageContentVisualBase<T extends ILayo
}
return super.getInteractionColor();
}
/** {@inheritDoc} */
@Override
public double getAngleInDegree() {
// in AF3 the unit circle goes clock-wise (for whatever reason)
return 360.0 - toDegrees(getConnectorAngleAsDouble(getModelElement()));
}
}
......@@ -35,8 +35,7 @@ import javafx.geometry.Rectangle2D;
*
* @author munaro
*/
public abstract class LayoutedCurveLinkVisual<T extends ILayoutedModelElement>
extends CurveLinkVisualBase {
public class LayoutedCurveLinkVisual<T extends ILayoutedModelElement> extends CurveLinkVisualBase {
/** Constructor. */
public LayoutedCurveLinkVisual(ILinkMVCBundle mvcb, Class<T> modelType) {
super(mvcb);
......
......@@ -36,8 +36,7 @@ import javafx.geometry.Rectangle2D;
*
* @author munaro
*/
public abstract class LayoutedLineLinkVisual<T extends ILayoutedModelElement>
extends LineLinkVisualBase {
public class LayoutedLineLinkVisual<T extends ILayoutedModelElement> extends LineLinkVisualBase {
/** Constructor. */
public LayoutedLineLinkVisual(ILinkMVCBundle mvcb, Class<T> modelType) {
......
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