From 579ccc19d9178e7cdca2af2b714c322b652f63da Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Tue, 18 Feb 2020 15:15:41 +0100 Subject: [PATCH] Kernel: external drag-and-drop mechanism for LWFXEF implemented. Issue-Ref: 3921 Issue-Url: https://af3-developer.fortiss.org/issues/3907 Signed-off-by: Florian Hoelzl <hoelzl@fortiss.org> --- .../tooling/common/ui/javafx/lwfxef/.ratings | 4 +- .../ui/javafx/lwfxef/DiagramViewer.java | 5 +- .../common/ui/javafx/lwfxef/MouseState.java | 43 +++++++++++++ .../ui/javafx/lwfxef/controller/.ratings | 2 +- .../javafx/lwfxef/controller/IController.java | 15 +++++ .../ui/javafx/lwfxef/controller/base/.ratings | 4 +- .../controller/base/ControllerBase.java | 13 ++++ .../controller/base/LinkControllerBase.java | 13 ++++ .../ui/javafx/lwfxef/visual/base/.ratings | 4 +- .../lwfxef/visual/base/ContentVisualBase.java | 1 - .../javafx/lwfxef/visual/base/VisualBase.java | 9 ++- .../ui/javafx/lwfxef/visual/elliptic/.ratings | 2 +- .../CircularContentAnchorageVisualBase.java | 6 +- .../javafx/lwfxef/visual/rectangular/.ratings | 8 +-- .../rectangular/DiamondContentVisualBase.java | 7 ++- .../rectangular/LineLinkVisualBase.java | 5 +- .../RectangularContentVisualBase.java | 63 ++++++++++--------- .../RhomboidContentVisualBase.java | 40 +++--------- .../tooling/kernel/ui/service/.ratings | 2 +- .../fortiss/tooling/kernel/service/.ratings | 2 +- 20 files changed, 165 insertions(+), 83 deletions(-) diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings index c412a38af..f455fa32c 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings @@ -1,6 +1,6 @@ DiagramCoordinate.java 6b00aec99054d4cd19003a72bd4e5e774ac6a641 GREEN DiagramLayers.java 155cbb47a5f0aaa0025320ae607e6777f3a2d2e8 GREEN -DiagramViewer.java e7c550be6443f798ba9399a35ab3059033a33e59 RED +DiagramViewer.java a96338d3d8e043564eb857920ade45f6e2d4ac18 YELLOW DiagramViewerDefaultTags.java 6230763252409c60009ab8887b4ef582cf883229 GREEN DiagramViewerFeatures.java 31e3fb61f915b0d8695005b083c47ce1c5be0b05 GREEN DiagramViewerSelection.java e833f592543bc97077907d980a39b123fc4044e6 GREEN @@ -8,5 +8,5 @@ EDragGesture.java 5cfa098d3877db11981c2750e5e103156d62fc5e GREEN FeedbackChange.java b088fa89af648f1674f2f9c1f7f99d585ce801ca GREEN GridCanvasVisual.java 734027d56af342cd01ff445ba9347b8dbb6c83c2 GREEN MVCBundleManager.java 2b4ab114c55b30a3d98d7135458f8f3ddd244d58 GREEN -MouseState.java ff90af6d1cca427ef6f3fded76367b535120a5df GREEN +MouseState.java 793fbc9628bb96c3359a3c496d3cc94f5ec2585d YELLOW SVGExporter.java 2211f06d81c7b0523ae52dc832410a76875a9e07 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java index e7c550be6..a96338d3d 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java @@ -71,6 +71,8 @@ import javafx.scene.shape.Rectangle; * for the purpose of source code size reduction. */ public class DiagramViewer { + /** The default dash stroke pattern. */ + private final Double[] DEFAULT_DASH_STROKE_PATTERN = new Double[] {15.0, 5.0}; /** The bundle manager helper class reference. */ private final MVCBundleManager viewerManager; /** The feature state helper class reference. */ @@ -118,8 +120,7 @@ public class DiagramViewer { // selection feedback rectangle mouseDragRectangle.setFill(Color.TRANSPARENT); mouseDragRectangle.setStroke(Color.ORANGERED); - // TODO (SB): Magic constant - mouseDragRectangle.getStrokeDashArray().addAll(15.0, 5.0); + mouseDragRectangle.getStrokeDashArray().addAll(DEFAULT_DASH_STROKE_PATTERN); mouseDragRectangle.setMouseTransparent(true); // viewer pane viewerPane = new Pane(); diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/MouseState.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/MouseState.java index ff90af6d1..793fbc962 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/MouseState.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/MouseState.java @@ -31,6 +31,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual; import javafx.event.EventHandler; import javafx.scene.Cursor; import javafx.scene.Node; +import javafx.scene.input.DragEvent; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; @@ -324,6 +325,44 @@ public final class MouseState { } }; + /** The drag over event handler. */ + private final EventHandler<DragEvent> dragOverHandler = new EventHandler<DragEvent>() { + @Override + public void handle(DragEvent event) { + if(!nodesToBundleMap.containsKey(event.getSource())) { + return; + } + // wild cast works, since source is in nodesMap + Node source = (Node)event.getSource(); + IMVCBundle bundle = nodesToBundleMap.get(source); + IController ctrl = bundle.getController(); + lastMouseLocation = + viewer.convertEventToDiagramCoordinates(event.getX(), event.getY(), source); + if(ctrl != null) { + ctrl.handleExternalDNDDragOver(event.getDragboard(), lastMouseLocation); + } + } + }; + + /** The drop event handler. */ + private final EventHandler<DragEvent> dropHandler = new EventHandler<DragEvent>() { + @Override + public void handle(DragEvent event) { + if(!nodesToBundleMap.containsKey(event.getSource())) { + return; + } + // wild cast works, since source is in nodesMap + Node source = (Node)event.getSource(); + IMVCBundle bundle = nodesToBundleMap.get(source); + IController ctrl = bundle.getController(); + lastMouseLocation = + viewer.convertEventToDiagramCoordinates(event.getX(), event.getY(), source); + if(ctrl != null) { + ctrl.handleExternalDNDDrop(event.getDragboard(), lastMouseLocation); + } + } + }; + /** Registers the mouse listeners on the given node. */ /* package */ void registerMouseListeners(Node node, IMVCBundle mvcb) { node.setOnMousePressed(mousePressedHandler); @@ -337,11 +376,15 @@ public final class MouseState { node.setOnMouseDragReleased(mouseDragCompletedHandler); node.setOnMouseMoved(mouseMotionHandler); node.setOnKeyReleased(keyEventHandler); + node.setOnDragOver(dragOverHandler); + node.setOnDragDropped(dropHandler); nodesToBundleMap.put(node, mvcb); } /** Unregisters the mouse listeners from the given node. */ /* package */ void unregisterMouseListeners(Node node) { + node.setOnDragDropped(null); + node.setOnDragOver(null); node.setOnKeyReleased(null); node.setOnMouseMoved(null); node.setOnMouseDragReleased(null); diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/.ratings index cfa9cb565..f1fe9b03d 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/.ratings @@ -1,5 +1,5 @@ IClickController.java c0270e99d918aef14612d46f3e84905d3a6bdd8c GREEN -IController.java 6ba069977e7588f97187916c23a0e37f7cb91059 GREEN +IController.java 443fe97dae2f8142e9ebc6df3267b505444c4bbe YELLOW IControllerFactory.java 85b86eda643489f2a03454eae5383915ecf27f83 GREEN IDragController.java c1f311d2ae9ed684c8a7cd85e9ed1f85e79658d1 GREEN IKeyPressController.java dc8fe2a7c441866122e8c7b3114fd12d17f0b051 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/IController.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/IController.java index 6ba069977..443fe97da 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/IController.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/IController.java @@ -23,6 +23,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.MVCBundleTag; import javafx.scene.Cursor; import javafx.scene.Node; import javafx.scene.control.MenuItem; +import javafx.scene.input.Dragboard; /** * Interface for controllers which are informed about gestures or clicks and provide context menus @@ -58,6 +59,20 @@ public interface IController extends IMVCBundlePart { */ List<MenuItem> contextMenuContributions(Node node, DiagramCoordinate diagramLocation); + /** + * Handles the external DND drag over event. The framework calls this method when a + * {@link Node#setOnDragOver(javafx.event.EventHandler)} event occurred at the given location. + * This method should return {@code true} if the event was processed. + */ + boolean handleExternalDNDDragOver(Dragboard db, DiagramCoordinate diagramLocation); + + /** + * Handles the external DND drop event. The framework calls this method when a + * {@link Node#setOnDragDropped(javafx.event.EventHandler)} event occurred at the given + * location. This method should return {@code true} if the drop event was completed. + */ + boolean handleExternalDNDDrop(Dragboard db, DiagramCoordinate diagramLocation); + /** * Returns whether this bundle represents a possible link target. If this method returns * {@code false} this bundle is considered neither when a new link gesture is started nor diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/.ratings index 6ffed36a0..5bd8084f3 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/.ratings @@ -1,11 +1,11 @@ AnchorageContentControllerBase.java da56b10cbf2711b5da69f0b59f43eacbe54f4eea GREEN ClickControllerBase.java 8e5861ed5f9318008ad0fdd5497ed320cd5bd647 GREEN ContentAnchorageMoveControllerBase.java c18e7915ce23e124757f5b736086ecc46694800a GREEN -ControllerBase.java 309e9ee3f3a255b5a06fed8f1b4d4ec8bf88f101 GREEN +ControllerBase.java c74e905a2b47dbf9b6443d94a877f1a9e56ba031 YELLOW DefaultDiagramController.java 0e083b89a08f63967102a384d66ebc1d64d203af GREEN DelegatingContentAnchorageController.java 2e3b1b4e14402a3503233f816b21ef3e4aa09edc GREEN DragControllerBase.java b15ff874304f679fe494d85f57cc8cbe4d0d1d15 GREEN DraggingUtils.java 95117e2ea4c36b6c6a31f8088bb95b484e0e6612 GREEN -LinkControllerBase.java 392cb79cb42e9f878c665d47053b0795c3768603 GREEN +LinkControllerBase.java 4b6239c10cbbc5a2226615f7c6775f11adf226ef YELLOW MoveControllerBase.java 38d632e31f5e27d112ecdd4933e3a331378180d0 GREEN ResizableContentControllerBase.java 898500d389b035f8138308d496d2d24be501c719 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/ControllerBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/ControllerBase.java index 309e9ee3f..c74e905a2 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/ControllerBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/ControllerBase.java @@ -32,6 +32,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.impl.MVCBundlePartBase; import javafx.scene.Cursor; import javafx.scene.Node; import javafx.scene.control.MenuItem; +import javafx.scene.input.Dragboard; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; @@ -104,6 +105,18 @@ public abstract class ControllerBase extends MVCBundlePartBase implements IContr return true; } + /** {@inheritDoc} */ + @Override + public boolean handleExternalDNDDragOver(Dragboard db, DiagramCoordinate diagramLocation) { + return false; + } + + /** {@inheritDoc} */ + @Override + public boolean handleExternalDNDDrop(Dragboard db, DiagramCoordinate diagramLocation) { + return false; + } + /** {@inheritDoc} */ @Override public IDragController getDragController(EDragGesture gesture, Node node, diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/LinkControllerBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/LinkControllerBase.java index 392cb79cb..4b6239c10 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/LinkControllerBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/LinkControllerBase.java @@ -42,6 +42,7 @@ import javafx.geometry.Point2D; import javafx.scene.Cursor; import javafx.scene.Node; import javafx.scene.control.MenuItem; +import javafx.scene.input.Dragboard; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; @@ -467,4 +468,16 @@ public abstract class LinkControllerBase extends MVCBundlePartBase implements IC /** Returns the number of bend-points in the model. */ protected abstract int getNumerOfBendPoints(); + + /** {@inheritDoc} */ + @Override + public boolean handleExternalDNDDragOver(Dragboard db, DiagramCoordinate diagramLocation) { + return false; + } + + /** {@inheritDoc} */ + @Override + public boolean handleExternalDNDDrop(Dragboard db, DiagramCoordinate diagramLocation) { + return false; + } } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/.ratings index f25afc4fc..472dda5cd 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/.ratings @@ -1,6 +1,6 @@ ContentAnchorageVisualBase.java 6722629a940e9f8d973d2176bc3855932d7fa35a GREEN -ContentVisualBase.java d232c6cb7bc54b2430379379eb2985f5a2e12cd3 RED +ContentVisualBase.java 6c9c508803874db2f5ffffb723c1df5664827a5d YELLOW DiagramAnchorageVisualBase.java 05c235152bc79187f0fc9b041435da7968654a78 GREEN LinkVisualBase.java 909b933b38b7651cac901d767115e173983bef26 GREEN MVCBundlePartWithEffectsBase.java 6f6fbbb065950ad3acd4dc1fbfdd1348874e51d2 GREEN -VisualBase.java 8d6e74d5c74703dad12847cd5c913fa72707a84a RED +VisualBase.java 276f4f5a881bd3a89c312522f9006e6f0cfd57c9 YELLOW diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/ContentVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/ContentVisualBase.java index d232c6cb7..6c9c50880 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/ContentVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/ContentVisualBase.java @@ -41,7 +41,6 @@ public abstract class ContentVisualBase extends VisualBase implements IContentVi protected final Text text = new Text(); /** The icon of this visual. */ protected final ImageView icon = new ImageView(); - // TODO (SB): Magic constant /** The expanded / collapsed indicator widget. */ protected final ExpandCollapseWidget expandCollapseWidget = new ExpandCollapseWidget(0, 0, 20, 20, 3); diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/VisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/VisualBase.java index 8d6e74d5c..276f4f5a8 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/VisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/VisualBase.java @@ -49,6 +49,11 @@ import javafx.scene.text.TextAlignment; * This implementation provides a simple {@link DropShadow} hover effect and a hover label. */ public abstract class VisualBase extends MVCBundlePartWithEffectsBase implements IVisual { + /** The default drop shadow radius. */ + private static final double DEFAULT_DROP_SHADOW_RAIDUS = 10; + /** The default drop shadow radius. */ + private static final double DEFAULT_DROP_SHADOW_OFFSET = 3; + /** The visible shape of this visual. */ private final Shape visualShape; /** The invisible hit area of this visual. */ @@ -85,8 +90,8 @@ public abstract class VisualBase extends MVCBundlePartWithEffectsBase implements protected void createHoverEffect(DiagramLayers layers) { Color shadow = getHoverShadowColor(); if(shadow != null && visualShape != null) { - // TODO (SB): Magic constant - visualShape.setEffect(new DropShadow(10, 3, 3, shadow)); + visualShape.setEffect(new DropShadow(DEFAULT_DROP_SHADOW_RAIDUS, + DEFAULT_DROP_SHADOW_OFFSET, DEFAULT_DROP_SHADOW_OFFSET, shadow)); } // handle hover text String text = getHoverText(); diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/.ratings index 1b4320c71..8355a1358 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/.ratings @@ -1,4 +1,4 @@ -CircularContentAnchorageVisualBase.java e1d3f982239beb38120c7eda6ecf319ab2779f9c RED +CircularContentAnchorageVisualBase.java c72fb8b95ef1e3650378f1c580c9362ebb852f46 YELLOW CircularContentVisualBase.java cc3caea328e36e90069b915e413c8e7e9522a939 GREEN CircularDiagramAnchorageVisualBase.java 7a3b92fb1b135c218b9a5e16506acfc74a6b5468 YELLOW CurveLinkVisualBase.java 5ce3086769004a9eb6800d7eb58379d831ff74b1 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CircularContentAnchorageVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CircularContentAnchorageVisualBase.java index e1d3f9822..c72fb8b95 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CircularContentAnchorageVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CircularContentAnchorageVisualBase.java @@ -26,6 +26,9 @@ import javafx.scene.shape.Circle; /** Base class for {@link IContentAnchorageVisual}s depicted as circles. */ public abstract class CircularContentAnchorageVisualBase extends ContentAnchorageVisualBase { + /** The default insets. */ + private static final double DEFAULT_INSET = 2; + /** Constructor. */ public CircularContentAnchorageVisualBase(IContentAnchorageMVCBundle mvcb) { super(mvcb, new Circle(), new Circle()); @@ -84,8 +87,7 @@ public abstract class CircularContentAnchorageVisualBase extends ContentAnchorag /** Returns the insets of the filled circle subtracted from {@link #getDimensions()}. */ protected double getInset() { - // TODO (SB): Magic constant - return 2; + return DEFAULT_INSET; } /** {@inheritDoc} */ diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings index 3c07cda2d..d37a0fc3e 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings @@ -1,9 +1,9 @@ -DiamondContentVisualBase.java de349d41b84b2063f74c03ff5ad7290855e997f7 RED +DiamondContentVisualBase.java a81e76e85706ad38b6c22bbcd1cc5a5696737e3d YELLOW LineLinkGraph.java 85a06a553f88f7b9fb4bd9c06411725d9fb160fc GREEN -LineLinkVisualBase.java 5529031f89a96ad0322f011e89dad1ece785bc03 RED +LineLinkVisualBase.java 74968c18bb68859bc795ed9a3b0693d1787e0806 YELLOW LineSegment.java a8658ec5bcd930d417a148861831b9ebb70bb37d GREEN RectangularBorderLocation.java 824472c353534d1094ae4f735a30a231b885f050 GREEN RectangularContentAnchorageVisualBase.java 39981dc29cac42d77c6ffe855ecc8ccad1689230 GREEN -RectangularContentVisualBase.java aee9ac3dbd53ce89539252d9984ed103d955be2f RED +RectangularContentVisualBase.java aeeda282f330180b1f339e3230810eccea2e7e7b YELLOW RectangularDiagramAnchorageVisualBase.java 1259d6d110becca9ae02c754036c6693f00de683 GREEN -RhomboidContentVisualBase.java 0c3820cbfd3763c3cb6b1a0cba5cc71d8eecea73 RED +RhomboidContentVisualBase.java 7f4d72e17d58a950814d76509a6d6402bbd7bba7 YELLOW diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/DiamondContentVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/DiamondContentVisualBase.java index de349d41b..a81e76e85 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/DiamondContentVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/DiamondContentVisualBase.java @@ -34,6 +34,9 @@ import javafx.scene.shape.PathElement; /** Base class for {@link ContentVisualBase content visuals} depicted by a diamond shape. */ public abstract class DiamondContentVisualBase extends ContentVisualBase { + /** The default text anchor location. */ + private static final double DEFAULT_TEXTANCHOR_DIVIDER = 5; + /** Constructor. */ public DiamondContentVisualBase(IContentMVCBundle mvcb) { super(mvcb, new Path(), new Path()); @@ -190,7 +193,7 @@ public abstract class DiamondContentVisualBase extends ContentVisualBase { @Override protected DiagramCoordinate getTextAnchorLocation() { DiagramCoordinate textAnchorLocation = super.getTextAnchorLocation(); - // TODO (SB): Magic constant - return textAnchorLocation.add(getCurrentBounds().getWidth() / 5, 0); + return textAnchorLocation.add(getCurrentBounds().getWidth() / DEFAULT_TEXTANCHOR_DIVIDER, + 0); } } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java index 5529031f8..74968c18b 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java @@ -36,6 +36,8 @@ import javafx.scene.paint.Paint; /** Base class for {@link LinkVisualBase link visuals} with straight lines. */ public abstract class LineLinkVisualBase extends LinkVisualBase { + /** The default arrow length. */ + private static final double DEFAULT_ARROW_LENGTH = 10.0; /** Stores the visual segments. */ private final List<LineSegment> segments = new LinkedList<>(); /** Flag storing if the lines have been added. */ @@ -339,8 +341,7 @@ public abstract class LineLinkVisualBase extends LinkVisualBase { /** Returns the length of the arrow. */ protected double getArrowLength() { - // TODO (SB): Magic constant - return 10; + return DEFAULT_ARROW_LENGTH; } /** Returns the width of the invisible selection line. */ diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RectangularContentVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RectangularContentVisualBase.java index aee9ac3db..aeeda282f 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RectangularContentVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RectangularContentVisualBase.java @@ -28,9 +28,11 @@ import javafx.scene.Node; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; -// TODO (SB): Check potential code duplication with RectangularContentVisualBase (dragGestureHitTest) /** Base class for {@link ContentVisualBase content visuals} depicted by rectangles. */ public abstract class RectangularContentVisualBase extends ContentVisualBase { + /** The default corner arc. */ + private static final Dimension2D DEFAULT_CORNER_ARC = new Dimension2D(15, 15); + /** Constructor. */ public RectangularContentVisualBase(IContentMVCBundle mvcb) { super(mvcb, new Rectangle(), new Rectangle()); @@ -99,39 +101,15 @@ public abstract class RectangularContentVisualBase extends ContentVisualBase { /** Returns the dimensions of the corner arcs. */ protected Dimension2D getCornerArcDimensions() { - // TODO (SB): Magic constant - return new Dimension2D(15, 15); + return DEFAULT_CORNER_ARC; } /** {@inheritDoc} */ @Override protected EDragGesture dragGestureHitTest(Node node, DiagramCoordinate diagramLocation) { if(node == getHitAreaShape()) { - double x = diagramLocation.getLocalX(node); - double y = diagramLocation.getLocalY(node); - double l = getHitAreaStartLinkSize(); - double r = getHitAreaResizeSize(); - Bounds bounds = node.getBoundsInLocal(); - // check for move area - double inset = l + r; - Rectangle2D moveArea = new Rectangle2D(inset, inset, bounds.getWidth() - 2 * inset, - bounds.getHeight() - 2 * inset); - if(moveArea.contains(x, y)) { - return EDragGesture.MOVE; - } - if(x < l || y < l || x > bounds.getWidth() - l || y > bounds.getHeight() - l) { - return EDragGesture.NEW_LINK; - } - if(x > bounds.getWidth() - inset && y >= l && y <= bounds.getHeight() - inset) { - return EDragGesture.RESIZE_H; - } - if(y > bounds.getHeight() - inset && x >= l && x <= bounds.getWidth() - inset) { - return EDragGesture.RESIZE_V; - } - if(x > bounds.getWidth() - inset && y > bounds.getHeight() - inset) { - return EDragGesture.RESIZE_VH; - } - return EDragGesture.NONE; + return getRectangularShapeDragGesture(node, diagramLocation, getHitAreaStartLinkSize(), + getHitAreaResizeSize()); } if(node == getVisualShape() || node == text) { return EDragGesture.MOVE; @@ -139,6 +117,35 @@ public abstract class RectangularContentVisualBase extends ContentVisualBase { return EDragGesture.NONE; } + /** Computes the {@link EDragGesture} for the rectangular shape case. */ + /* package */ static EDragGesture getRectangularShapeDragGesture(Node node, + DiagramCoordinate diagramLocation, double startLinkSize, double resizeAreaSize) { + double x = diagramLocation.getLocalX(node); + double y = diagramLocation.getLocalY(node); + Bounds bounds = node.getBoundsInLocal(); + // check for move area + double inset = startLinkSize + resizeAreaSize; + Rectangle2D moveArea = new Rectangle2D(inset, inset, bounds.getWidth() - 2 * inset, + bounds.getHeight() - 2 * inset); + if(moveArea.contains(x, y)) { + return EDragGesture.MOVE; + } + if(x < startLinkSize || y < startLinkSize || x > bounds.getWidth() - startLinkSize || + y > bounds.getHeight() - startLinkSize) { + return EDragGesture.NEW_LINK; + } + if(x > bounds.getWidth() - inset && y >= startLinkSize && y <= bounds.getHeight() - inset) { + return EDragGesture.RESIZE_H; + } + if(y > bounds.getHeight() - inset && x >= startLinkSize && x <= bounds.getWidth() - inset) { + return EDragGesture.RESIZE_V; + } + if(x > bounds.getWidth() - inset && y > bounds.getHeight() - inset) { + return EDragGesture.RESIZE_VH; + } + return EDragGesture.NONE; + } + /** Returns the visual rectangle shape. */ protected final Rectangle getVisualRectangleShape() { // wild cast works: see constructor diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RhomboidContentVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RhomboidContentVisualBase.java index 0c3820cbf..7f4d72e17 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RhomboidContentVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RhomboidContentVisualBase.java @@ -10,6 +10,7 @@ package org.fortiss.tooling.common.ui.javafx.lwfxef.visual.rectangular; import static org.fortiss.tooling.common.ui.javafx.lwfxef.visual.rectangular.RectangularBorderLocation.getClosestLocationOnBounds; +import static org.fortiss.tooling.common.ui.javafx.lwfxef.visual.rectangular.RectangularContentVisualBase.getRectangularShapeDragGesture; import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate; import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramLayers; @@ -21,7 +22,6 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IContentAnchorageVisua import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.base.ContentVisualBase; import javafx.collections.ObservableList; -import javafx.geometry.Bounds; import javafx.geometry.Dimension2D; import javafx.geometry.Rectangle2D; import javafx.geometry.Side; @@ -35,6 +35,11 @@ import javafx.scene.shape.PathElement; /** Base class for {@link ContentVisualBase content visuals} depicted by a rhomboid. */ public abstract class RhomboidContentVisualBase extends ContentVisualBase { + /** The default horizontal offset multiplier. */ + private static final double DEFAULT_OFFSET_MULTIPLIER = 3.0; + /** The default corner arc. */ + private static final Dimension2D DEFAULT_CORNER_ARC = new Dimension2D(15, 15); + /** Constructor. */ public RhomboidContentVisualBase(IContentMVCBundle mvcb) { super(mvcb, new Path(), new Path()); @@ -86,8 +91,7 @@ public abstract class RhomboidContentVisualBase extends ContentVisualBase { /** Returns the offset of the upper and lower rhomboid line (0 = rectangle). */ public double getOffset() { - // TODO (SB): Magic constant - return 3.0 * getViewer().getFeatures().getHorizontalSpacing(); + return DEFAULT_OFFSET_MULTIPLIER * getViewer().getFeatures().getHorizontalSpacing(); } /** {@inheritDoc} */ @@ -124,39 +128,15 @@ public abstract class RhomboidContentVisualBase extends ContentVisualBase { /** Returns the dimensions of the corner arcs. */ protected Dimension2D getCornerArcDimensions() { - // TODO (SB): Magic constant - return new Dimension2D(15, 15); + return DEFAULT_CORNER_ARC; } /** {@inheritDoc} */ @Override protected EDragGesture dragGestureHitTest(Node node, DiagramCoordinate diagramLocation) { if(node == getHitAreaShape()) { - double x = diagramLocation.getLocalX(node); - double y = diagramLocation.getLocalY(node); - double l = getHitAreaStartLinkSize(); - double r = getHitAreaResizeSize(); - Bounds bounds = node.getBoundsInLocal(); - // check for move area - double inset = l + r; - Rectangle2D moveArea = new Rectangle2D(inset, inset, bounds.getWidth() - 2 * inset, - bounds.getHeight() - 2 * inset); - if(moveArea.contains(x, y)) { - return EDragGesture.MOVE; - } - if(x < l || y < l || x > bounds.getWidth() - l || y > bounds.getHeight() - l) { - return EDragGesture.NEW_LINK; - } - if(x > bounds.getWidth() - inset && y >= l && y <= bounds.getHeight() - inset) { - return EDragGesture.RESIZE_H; - } - if(y > bounds.getHeight() - inset && x >= l && x <= bounds.getWidth() - inset) { - return EDragGesture.RESIZE_V; - } - if(x > bounds.getWidth() - inset && y > bounds.getHeight() - inset) { - return EDragGesture.RESIZE_VH; - } - return EDragGesture.NONE; + return getRectangularShapeDragGesture(node, diagramLocation, getHitAreaStartLinkSize(), + getHitAreaResizeSize()); } if(node == getVisualShape() || node == text) { return EDragGesture.MOVE; diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings index 5cc6adbc8..4b34dc38b 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings @@ -4,6 +4,6 @@ IContextMenuService.java cfb6b8237b6cd2b0e461991a9ceb95969f330265 GREEN IEditPartFactoryService.java c448bff63fb81f57037c9f1dc5319859c12d0c4d GREEN IMarkerService.java d433e838e387dd2fe61b8dea7395ebb7203ae39b GREEN IModelEditorBindingService.java ce2ae1957e2232bb0fac1d1d262103f9adfc5266 GREEN -IModelElementHandlerService.java 580f526ed495ae474b3cf8e6851acd64322417da RED +IModelElementHandlerService.java 748ffd22d6836a5599f8785f023469eb58c80ece YELLOW INavigatorService.java 8d2ffeb6f075d3abea904b84d8a40090d97837fd GREEN ITutorialUIService.java 72707c60c3d23d8ffc5c579cb9b022bb614eb094 GREEN diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/service/.ratings b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/service/.ratings index 66f5be3ce..6ca47090d 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/service/.ratings +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/service/.ratings @@ -8,6 +8,6 @@ ILibraryService.java e1e2ec72b1db892478ed20c7fbb7dcf94472a1cd GREEN ILoggingService.java 1ee9723af5a79299249e8db345e8419f814ff6d1 GREEN IMigrationService.java 7cfa6268b97f0c38c838905791e065655c6d6a04 GREEN IPersistencyService.java 2b2eeb329e3040e75f4352d9c374855583e27538 GREEN -IPrototypeService.java 3f11fc887f729ab739736081af9e663d67d3131f YELLOW +IPrototypeService.java d2b66742bea8bd6d394157985def6f8ea39c8d20 YELLOW ITransformationService.java 71f175e94d7257713cb14c8148de5a309b03788a GREEN ITutorialService.java 22a490516e38536203b1edd32711b615b77a4728 GREEN -- GitLab