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

Kernel: external drag-and-drop mechanism for LWFXEF implemented.

parent a3de447e
No related branches found
No related tags found
1 merge request!923921
Showing
with 165 additions and 83 deletions
DiagramCoordinate.java 6b00aec99054d4cd19003a72bd4e5e774ac6a641 GREEN DiagramCoordinate.java 6b00aec99054d4cd19003a72bd4e5e774ac6a641 GREEN
DiagramLayers.java 155cbb47a5f0aaa0025320ae607e6777f3a2d2e8 GREEN DiagramLayers.java 155cbb47a5f0aaa0025320ae607e6777f3a2d2e8 GREEN
DiagramViewer.java e7c550be6443f798ba9399a35ab3059033a33e59 RED DiagramViewer.java a96338d3d8e043564eb857920ade45f6e2d4ac18 YELLOW
DiagramViewerDefaultTags.java 6230763252409c60009ab8887b4ef582cf883229 GREEN DiagramViewerDefaultTags.java 6230763252409c60009ab8887b4ef582cf883229 GREEN
DiagramViewerFeatures.java 31e3fb61f915b0d8695005b083c47ce1c5be0b05 GREEN DiagramViewerFeatures.java 31e3fb61f915b0d8695005b083c47ce1c5be0b05 GREEN
DiagramViewerSelection.java e833f592543bc97077907d980a39b123fc4044e6 GREEN DiagramViewerSelection.java e833f592543bc97077907d980a39b123fc4044e6 GREEN
...@@ -8,5 +8,5 @@ EDragGesture.java 5cfa098d3877db11981c2750e5e103156d62fc5e GREEN ...@@ -8,5 +8,5 @@ EDragGesture.java 5cfa098d3877db11981c2750e5e103156d62fc5e GREEN
FeedbackChange.java b088fa89af648f1674f2f9c1f7f99d585ce801ca GREEN FeedbackChange.java b088fa89af648f1674f2f9c1f7f99d585ce801ca GREEN
GridCanvasVisual.java 734027d56af342cd01ff445ba9347b8dbb6c83c2 GREEN GridCanvasVisual.java 734027d56af342cd01ff445ba9347b8dbb6c83c2 GREEN
MVCBundleManager.java 2b4ab114c55b30a3d98d7135458f8f3ddd244d58 GREEN MVCBundleManager.java 2b4ab114c55b30a3d98d7135458f8f3ddd244d58 GREEN
MouseState.java ff90af6d1cca427ef6f3fded76367b535120a5df GREEN MouseState.java 793fbc9628bb96c3359a3c496d3cc94f5ec2585d YELLOW
SVGExporter.java 2211f06d81c7b0523ae52dc832410a76875a9e07 GREEN SVGExporter.java 2211f06d81c7b0523ae52dc832410a76875a9e07 GREEN
...@@ -71,6 +71,8 @@ import javafx.scene.shape.Rectangle; ...@@ -71,6 +71,8 @@ import javafx.scene.shape.Rectangle;
* for the purpose of source code size reduction. * for the purpose of source code size reduction.
*/ */
public class DiagramViewer { 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. */ /** The bundle manager helper class reference. */
private final MVCBundleManager viewerManager; private final MVCBundleManager viewerManager;
/** The feature state helper class reference. */ /** The feature state helper class reference. */
...@@ -118,8 +120,7 @@ public class DiagramViewer { ...@@ -118,8 +120,7 @@ public class DiagramViewer {
// selection feedback rectangle // selection feedback rectangle
mouseDragRectangle.setFill(Color.TRANSPARENT); mouseDragRectangle.setFill(Color.TRANSPARENT);
mouseDragRectangle.setStroke(Color.ORANGERED); mouseDragRectangle.setStroke(Color.ORANGERED);
// TODO (SB): Magic constant mouseDragRectangle.getStrokeDashArray().addAll(DEFAULT_DASH_STROKE_PATTERN);
mouseDragRectangle.getStrokeDashArray().addAll(15.0, 5.0);
mouseDragRectangle.setMouseTransparent(true); mouseDragRectangle.setMouseTransparent(true);
// viewer pane // viewer pane
viewerPane = new Pane(); viewerPane = new Pane();
......
...@@ -31,6 +31,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual; ...@@ -31,6 +31,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.scene.Cursor; import javafx.scene.Cursor;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.input.DragEvent;
import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton; import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
...@@ -324,6 +325,44 @@ public final class MouseState { ...@@ -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. */ /** Registers the mouse listeners on the given node. */
/* package */ void registerMouseListeners(Node node, IMVCBundle mvcb) { /* package */ void registerMouseListeners(Node node, IMVCBundle mvcb) {
node.setOnMousePressed(mousePressedHandler); node.setOnMousePressed(mousePressedHandler);
...@@ -337,11 +376,15 @@ public final class MouseState { ...@@ -337,11 +376,15 @@ public final class MouseState {
node.setOnMouseDragReleased(mouseDragCompletedHandler); node.setOnMouseDragReleased(mouseDragCompletedHandler);
node.setOnMouseMoved(mouseMotionHandler); node.setOnMouseMoved(mouseMotionHandler);
node.setOnKeyReleased(keyEventHandler); node.setOnKeyReleased(keyEventHandler);
node.setOnDragOver(dragOverHandler);
node.setOnDragDropped(dropHandler);
nodesToBundleMap.put(node, mvcb); nodesToBundleMap.put(node, mvcb);
} }
/** Unregisters the mouse listeners from the given node. */ /** Unregisters the mouse listeners from the given node. */
/* package */ void unregisterMouseListeners(Node node) { /* package */ void unregisterMouseListeners(Node node) {
node.setOnDragDropped(null);
node.setOnDragOver(null);
node.setOnKeyReleased(null); node.setOnKeyReleased(null);
node.setOnMouseMoved(null); node.setOnMouseMoved(null);
node.setOnMouseDragReleased(null); node.setOnMouseDragReleased(null);
......
IClickController.java c0270e99d918aef14612d46f3e84905d3a6bdd8c GREEN IClickController.java c0270e99d918aef14612d46f3e84905d3a6bdd8c GREEN
IController.java 6ba069977e7588f97187916c23a0e37f7cb91059 GREEN IController.java 443fe97dae2f8142e9ebc6df3267b505444c4bbe YELLOW
IControllerFactory.java 85b86eda643489f2a03454eae5383915ecf27f83 GREEN IControllerFactory.java 85b86eda643489f2a03454eae5383915ecf27f83 GREEN
IDragController.java c1f311d2ae9ed684c8a7cd85e9ed1f85e79658d1 GREEN IDragController.java c1f311d2ae9ed684c8a7cd85e9ed1f85e79658d1 GREEN
IKeyPressController.java dc8fe2a7c441866122e8c7b3114fd12d17f0b051 GREEN IKeyPressController.java dc8fe2a7c441866122e8c7b3114fd12d17f0b051 GREEN
...@@ -23,6 +23,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.MVCBundleTag; ...@@ -23,6 +23,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.MVCBundleTag;
import javafx.scene.Cursor; import javafx.scene.Cursor;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.MenuItem; import javafx.scene.control.MenuItem;
import javafx.scene.input.Dragboard;
/** /**
* Interface for controllers which are informed about gestures or clicks and provide context menus * Interface for controllers which are informed about gestures or clicks and provide context menus
...@@ -58,6 +59,20 @@ public interface IController extends IMVCBundlePart { ...@@ -58,6 +59,20 @@ public interface IController extends IMVCBundlePart {
*/ */
List<MenuItem> contextMenuContributions(Node node, DiagramCoordinate diagramLocation); 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 * 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 * {@code false} this bundle is considered neither when a new link gesture is started nor
......
AnchorageContentControllerBase.java da56b10cbf2711b5da69f0b59f43eacbe54f4eea GREEN AnchorageContentControllerBase.java da56b10cbf2711b5da69f0b59f43eacbe54f4eea GREEN
ClickControllerBase.java 8e5861ed5f9318008ad0fdd5497ed320cd5bd647 GREEN ClickControllerBase.java 8e5861ed5f9318008ad0fdd5497ed320cd5bd647 GREEN
ContentAnchorageMoveControllerBase.java c18e7915ce23e124757f5b736086ecc46694800a GREEN ContentAnchorageMoveControllerBase.java c18e7915ce23e124757f5b736086ecc46694800a GREEN
ControllerBase.java 309e9ee3f3a255b5a06fed8f1b4d4ec8bf88f101 GREEN ControllerBase.java c74e905a2b47dbf9b6443d94a877f1a9e56ba031 YELLOW
DefaultDiagramController.java 0e083b89a08f63967102a384d66ebc1d64d203af GREEN DefaultDiagramController.java 0e083b89a08f63967102a384d66ebc1d64d203af GREEN
DelegatingContentAnchorageController.java 2e3b1b4e14402a3503233f816b21ef3e4aa09edc GREEN DelegatingContentAnchorageController.java 2e3b1b4e14402a3503233f816b21ef3e4aa09edc GREEN
DragControllerBase.java b15ff874304f679fe494d85f57cc8cbe4d0d1d15 GREEN DragControllerBase.java b15ff874304f679fe494d85f57cc8cbe4d0d1d15 GREEN
DraggingUtils.java 95117e2ea4c36b6c6a31f8088bb95b484e0e6612 GREEN DraggingUtils.java 95117e2ea4c36b6c6a31f8088bb95b484e0e6612 GREEN
LinkControllerBase.java 392cb79cb42e9f878c665d47053b0795c3768603 GREEN LinkControllerBase.java 4b6239c10cbbc5a2226615f7c6775f11adf226ef YELLOW
MoveControllerBase.java 38d632e31f5e27d112ecdd4933e3a331378180d0 GREEN MoveControllerBase.java 38d632e31f5e27d112ecdd4933e3a331378180d0 GREEN
ResizableContentControllerBase.java 898500d389b035f8138308d496d2d24be501c719 GREEN ResizableContentControllerBase.java 898500d389b035f8138308d496d2d24be501c719 GREEN
...@@ -32,6 +32,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.impl.MVCBundlePartBase; ...@@ -32,6 +32,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.impl.MVCBundlePartBase;
import javafx.scene.Cursor; import javafx.scene.Cursor;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.MenuItem; import javafx.scene.control.MenuItem;
import javafx.scene.input.Dragboard;
import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
...@@ -104,6 +105,18 @@ public abstract class ControllerBase extends MVCBundlePartBase implements IContr ...@@ -104,6 +105,18 @@ public abstract class ControllerBase extends MVCBundlePartBase implements IContr
return true; 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} */ /** {@inheritDoc} */
@Override @Override
public IDragController getDragController(EDragGesture gesture, Node node, public IDragController getDragController(EDragGesture gesture, Node node,
......
...@@ -42,6 +42,7 @@ import javafx.geometry.Point2D; ...@@ -42,6 +42,7 @@ import javafx.geometry.Point2D;
import javafx.scene.Cursor; import javafx.scene.Cursor;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.MenuItem; import javafx.scene.control.MenuItem;
import javafx.scene.input.Dragboard;
import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
...@@ -467,4 +468,16 @@ public abstract class LinkControllerBase extends MVCBundlePartBase implements IC ...@@ -467,4 +468,16 @@ public abstract class LinkControllerBase extends MVCBundlePartBase implements IC
/** Returns the number of bend-points in the model. */ /** Returns the number of bend-points in the model. */
protected abstract int getNumerOfBendPoints(); 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;
}
} }
ContentAnchorageVisualBase.java 6722629a940e9f8d973d2176bc3855932d7fa35a GREEN ContentAnchorageVisualBase.java 6722629a940e9f8d973d2176bc3855932d7fa35a GREEN
ContentVisualBase.java d232c6cb7bc54b2430379379eb2985f5a2e12cd3 RED ContentVisualBase.java 6c9c508803874db2f5ffffb723c1df5664827a5d YELLOW
DiagramAnchorageVisualBase.java 05c235152bc79187f0fc9b041435da7968654a78 GREEN DiagramAnchorageVisualBase.java 05c235152bc79187f0fc9b041435da7968654a78 GREEN
LinkVisualBase.java 909b933b38b7651cac901d767115e173983bef26 GREEN LinkVisualBase.java 909b933b38b7651cac901d767115e173983bef26 GREEN
MVCBundlePartWithEffectsBase.java 6f6fbbb065950ad3acd4dc1fbfdd1348874e51d2 GREEN MVCBundlePartWithEffectsBase.java 6f6fbbb065950ad3acd4dc1fbfdd1348874e51d2 GREEN
VisualBase.java 8d6e74d5c74703dad12847cd5c913fa72707a84a RED VisualBase.java 276f4f5a881bd3a89c312522f9006e6f0cfd57c9 YELLOW
...@@ -41,7 +41,6 @@ public abstract class ContentVisualBase extends VisualBase implements IContentVi ...@@ -41,7 +41,6 @@ public abstract class ContentVisualBase extends VisualBase implements IContentVi
protected final Text text = new Text(); protected final Text text = new Text();
/** The icon of this visual. */ /** The icon of this visual. */
protected final ImageView icon = new ImageView(); protected final ImageView icon = new ImageView();
// TODO (SB): Magic constant
/** The expanded / collapsed indicator widget. */ /** The expanded / collapsed indicator widget. */
protected final ExpandCollapseWidget expandCollapseWidget = protected final ExpandCollapseWidget expandCollapseWidget =
new ExpandCollapseWidget(0, 0, 20, 20, 3); new ExpandCollapseWidget(0, 0, 20, 20, 3);
......
...@@ -49,6 +49,11 @@ import javafx.scene.text.TextAlignment; ...@@ -49,6 +49,11 @@ import javafx.scene.text.TextAlignment;
* This implementation provides a simple {@link DropShadow} hover effect and a hover label. * This implementation provides a simple {@link DropShadow} hover effect and a hover label.
*/ */
public abstract class VisualBase extends MVCBundlePartWithEffectsBase implements IVisual { 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. */ /** The visible shape of this visual. */
private final Shape visualShape; private final Shape visualShape;
/** The invisible hit area of this visual. */ /** The invisible hit area of this visual. */
...@@ -85,8 +90,8 @@ public abstract class VisualBase extends MVCBundlePartWithEffectsBase implements ...@@ -85,8 +90,8 @@ public abstract class VisualBase extends MVCBundlePartWithEffectsBase implements
protected void createHoverEffect(DiagramLayers layers) { protected void createHoverEffect(DiagramLayers layers) {
Color shadow = getHoverShadowColor(); Color shadow = getHoverShadowColor();
if(shadow != null && visualShape != null) { if(shadow != null && visualShape != null) {
// TODO (SB): Magic constant visualShape.setEffect(new DropShadow(DEFAULT_DROP_SHADOW_RAIDUS,
visualShape.setEffect(new DropShadow(10, 3, 3, shadow)); DEFAULT_DROP_SHADOW_OFFSET, DEFAULT_DROP_SHADOW_OFFSET, shadow));
} }
// handle hover text // handle hover text
String text = getHoverText(); String text = getHoverText();
......
CircularContentAnchorageVisualBase.java e1d3f982239beb38120c7eda6ecf319ab2779f9c RED CircularContentAnchorageVisualBase.java c72fb8b95ef1e3650378f1c580c9362ebb852f46 YELLOW
CircularContentVisualBase.java cc3caea328e36e90069b915e413c8e7e9522a939 GREEN CircularContentVisualBase.java cc3caea328e36e90069b915e413c8e7e9522a939 GREEN
CircularDiagramAnchorageVisualBase.java 7a3b92fb1b135c218b9a5e16506acfc74a6b5468 YELLOW CircularDiagramAnchorageVisualBase.java 7a3b92fb1b135c218b9a5e16506acfc74a6b5468 YELLOW
CurveLinkVisualBase.java 5ce3086769004a9eb6800d7eb58379d831ff74b1 GREEN CurveLinkVisualBase.java 5ce3086769004a9eb6800d7eb58379d831ff74b1 GREEN
......
...@@ -26,6 +26,9 @@ import javafx.scene.shape.Circle; ...@@ -26,6 +26,9 @@ import javafx.scene.shape.Circle;
/** Base class for {@link IContentAnchorageVisual}s depicted as circles. */ /** Base class for {@link IContentAnchorageVisual}s depicted as circles. */
public abstract class CircularContentAnchorageVisualBase extends ContentAnchorageVisualBase { public abstract class CircularContentAnchorageVisualBase extends ContentAnchorageVisualBase {
/** The default insets. */
private static final double DEFAULT_INSET = 2;
/** Constructor. */ /** Constructor. */
public CircularContentAnchorageVisualBase(IContentAnchorageMVCBundle mvcb) { public CircularContentAnchorageVisualBase(IContentAnchorageMVCBundle mvcb) {
super(mvcb, new Circle(), new Circle()); super(mvcb, new Circle(), new Circle());
...@@ -84,8 +87,7 @@ public abstract class CircularContentAnchorageVisualBase extends ContentAnchorag ...@@ -84,8 +87,7 @@ public abstract class CircularContentAnchorageVisualBase extends ContentAnchorag
/** Returns the insets of the filled circle subtracted from {@link #getDimensions()}. */ /** Returns the insets of the filled circle subtracted from {@link #getDimensions()}. */
protected double getInset() { protected double getInset() {
// TODO (SB): Magic constant return DEFAULT_INSET;
return 2;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
......
DiamondContentVisualBase.java de349d41b84b2063f74c03ff5ad7290855e997f7 RED DiamondContentVisualBase.java a81e76e85706ad38b6c22bbcd1cc5a5696737e3d YELLOW
LineLinkGraph.java 85a06a553f88f7b9fb4bd9c06411725d9fb160fc GREEN LineLinkGraph.java 85a06a553f88f7b9fb4bd9c06411725d9fb160fc GREEN
LineLinkVisualBase.java 5529031f89a96ad0322f011e89dad1ece785bc03 RED LineLinkVisualBase.java 74968c18bb68859bc795ed9a3b0693d1787e0806 YELLOW
LineSegment.java a8658ec5bcd930d417a148861831b9ebb70bb37d GREEN LineSegment.java a8658ec5bcd930d417a148861831b9ebb70bb37d GREEN
RectangularBorderLocation.java 824472c353534d1094ae4f735a30a231b885f050 GREEN RectangularBorderLocation.java 824472c353534d1094ae4f735a30a231b885f050 GREEN
RectangularContentAnchorageVisualBase.java 39981dc29cac42d77c6ffe855ecc8ccad1689230 GREEN RectangularContentAnchorageVisualBase.java 39981dc29cac42d77c6ffe855ecc8ccad1689230 GREEN
RectangularContentVisualBase.java aee9ac3dbd53ce89539252d9984ed103d955be2f RED RectangularContentVisualBase.java aeeda282f330180b1f339e3230810eccea2e7e7b YELLOW
RectangularDiagramAnchorageVisualBase.java 1259d6d110becca9ae02c754036c6693f00de683 GREEN RectangularDiagramAnchorageVisualBase.java 1259d6d110becca9ae02c754036c6693f00de683 GREEN
RhomboidContentVisualBase.java 0c3820cbfd3763c3cb6b1a0cba5cc71d8eecea73 RED RhomboidContentVisualBase.java 7f4d72e17d58a950814d76509a6d6402bbd7bba7 YELLOW
...@@ -34,6 +34,9 @@ import javafx.scene.shape.PathElement; ...@@ -34,6 +34,9 @@ import javafx.scene.shape.PathElement;
/** Base class for {@link ContentVisualBase content visuals} depicted by a diamond shape. */ /** Base class for {@link ContentVisualBase content visuals} depicted by a diamond shape. */
public abstract class DiamondContentVisualBase extends ContentVisualBase { public abstract class DiamondContentVisualBase extends ContentVisualBase {
/** The default text anchor location. */
private static final double DEFAULT_TEXTANCHOR_DIVIDER = 5;
/** Constructor. */ /** Constructor. */
public DiamondContentVisualBase(IContentMVCBundle mvcb) { public DiamondContentVisualBase(IContentMVCBundle mvcb) {
super(mvcb, new Path(), new Path()); super(mvcb, new Path(), new Path());
...@@ -190,7 +193,7 @@ public abstract class DiamondContentVisualBase extends ContentVisualBase { ...@@ -190,7 +193,7 @@ public abstract class DiamondContentVisualBase extends ContentVisualBase {
@Override @Override
protected DiagramCoordinate getTextAnchorLocation() { protected DiagramCoordinate getTextAnchorLocation() {
DiagramCoordinate textAnchorLocation = super.getTextAnchorLocation(); DiagramCoordinate textAnchorLocation = super.getTextAnchorLocation();
// TODO (SB): Magic constant return textAnchorLocation.add(getCurrentBounds().getWidth() / DEFAULT_TEXTANCHOR_DIVIDER,
return textAnchorLocation.add(getCurrentBounds().getWidth() / 5, 0); 0);
} }
} }
...@@ -36,6 +36,8 @@ import javafx.scene.paint.Paint; ...@@ -36,6 +36,8 @@ import javafx.scene.paint.Paint;
/** Base class for {@link LinkVisualBase link visuals} with straight lines. */ /** Base class for {@link LinkVisualBase link visuals} with straight lines. */
public abstract class LineLinkVisualBase extends LinkVisualBase { public abstract class LineLinkVisualBase extends LinkVisualBase {
/** The default arrow length. */
private static final double DEFAULT_ARROW_LENGTH = 10.0;
/** Stores the visual segments. */ /** Stores the visual segments. */
private final List<LineSegment> segments = new LinkedList<>(); private final List<LineSegment> segments = new LinkedList<>();
/** Flag storing if the lines have been added. */ /** Flag storing if the lines have been added. */
...@@ -339,8 +341,7 @@ public abstract class LineLinkVisualBase extends LinkVisualBase { ...@@ -339,8 +341,7 @@ public abstract class LineLinkVisualBase extends LinkVisualBase {
/** Returns the length of the arrow. */ /** Returns the length of the arrow. */
protected double getArrowLength() { protected double getArrowLength() {
// TODO (SB): Magic constant return DEFAULT_ARROW_LENGTH;
return 10;
} }
/** Returns the width of the invisible selection line. */ /** Returns the width of the invisible selection line. */
......
...@@ -28,9 +28,11 @@ import javafx.scene.Node; ...@@ -28,9 +28,11 @@ import javafx.scene.Node;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
// TODO (SB): Check potential code duplication with RectangularContentVisualBase (dragGestureHitTest)
/** Base class for {@link ContentVisualBase content visuals} depicted by rectangles. */ /** Base class for {@link ContentVisualBase content visuals} depicted by rectangles. */
public abstract class RectangularContentVisualBase extends ContentVisualBase { public abstract class RectangularContentVisualBase extends ContentVisualBase {
/** The default corner arc. */
private static final Dimension2D DEFAULT_CORNER_ARC = new Dimension2D(15, 15);
/** Constructor. */ /** Constructor. */
public RectangularContentVisualBase(IContentMVCBundle mvcb) { public RectangularContentVisualBase(IContentMVCBundle mvcb) {
super(mvcb, new Rectangle(), new Rectangle()); super(mvcb, new Rectangle(), new Rectangle());
...@@ -99,39 +101,15 @@ public abstract class RectangularContentVisualBase extends ContentVisualBase { ...@@ -99,39 +101,15 @@ public abstract class RectangularContentVisualBase extends ContentVisualBase {
/** Returns the dimensions of the corner arcs. */ /** Returns the dimensions of the corner arcs. */
protected Dimension2D getCornerArcDimensions() { protected Dimension2D getCornerArcDimensions() {
// TODO (SB): Magic constant return DEFAULT_CORNER_ARC;
return new Dimension2D(15, 15);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected EDragGesture dragGestureHitTest(Node node, DiagramCoordinate diagramLocation) { protected EDragGesture dragGestureHitTest(Node node, DiagramCoordinate diagramLocation) {
if(node == getHitAreaShape()) { if(node == getHitAreaShape()) {
double x = diagramLocation.getLocalX(node); return getRectangularShapeDragGesture(node, diagramLocation, getHitAreaStartLinkSize(),
double y = diagramLocation.getLocalY(node); getHitAreaResizeSize());
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;
} }
if(node == getVisualShape() || node == text) { if(node == getVisualShape() || node == text) {
return EDragGesture.MOVE; return EDragGesture.MOVE;
...@@ -139,6 +117,35 @@ public abstract class RectangularContentVisualBase extends ContentVisualBase { ...@@ -139,6 +117,35 @@ public abstract class RectangularContentVisualBase extends ContentVisualBase {
return EDragGesture.NONE; 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. */ /** Returns the visual rectangle shape. */
protected final Rectangle getVisualRectangleShape() { protected final Rectangle getVisualRectangleShape() {
// wild cast works: see constructor // wild cast works: see constructor
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
package org.fortiss.tooling.common.ui.javafx.lwfxef.visual.rectangular; 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.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.DiagramCoordinate;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramLayers; import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramLayers;
...@@ -21,7 +22,6 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IContentAnchorageVisua ...@@ -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 org.fortiss.tooling.common.ui.javafx.lwfxef.visual.base.ContentVisualBase;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.geometry.Bounds;
import javafx.geometry.Dimension2D; import javafx.geometry.Dimension2D;
import javafx.geometry.Rectangle2D; import javafx.geometry.Rectangle2D;
import javafx.geometry.Side; import javafx.geometry.Side;
...@@ -35,6 +35,11 @@ import javafx.scene.shape.PathElement; ...@@ -35,6 +35,11 @@ import javafx.scene.shape.PathElement;
/** Base class for {@link ContentVisualBase content visuals} depicted by a rhomboid. */ /** Base class for {@link ContentVisualBase content visuals} depicted by a rhomboid. */
public abstract class RhomboidContentVisualBase extends ContentVisualBase { 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. */ /** Constructor. */
public RhomboidContentVisualBase(IContentMVCBundle mvcb) { public RhomboidContentVisualBase(IContentMVCBundle mvcb) {
super(mvcb, new Path(), new Path()); super(mvcb, new Path(), new Path());
...@@ -86,8 +91,7 @@ public abstract class RhomboidContentVisualBase extends ContentVisualBase { ...@@ -86,8 +91,7 @@ public abstract class RhomboidContentVisualBase extends ContentVisualBase {
/** Returns the offset of the upper and lower rhomboid line (0 = rectangle). */ /** Returns the offset of the upper and lower rhomboid line (0 = rectangle). */
public double getOffset() { public double getOffset() {
// TODO (SB): Magic constant return DEFAULT_OFFSET_MULTIPLIER * getViewer().getFeatures().getHorizontalSpacing();
return 3.0 * getViewer().getFeatures().getHorizontalSpacing();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
...@@ -124,39 +128,15 @@ public abstract class RhomboidContentVisualBase extends ContentVisualBase { ...@@ -124,39 +128,15 @@ public abstract class RhomboidContentVisualBase extends ContentVisualBase {
/** Returns the dimensions of the corner arcs. */ /** Returns the dimensions of the corner arcs. */
protected Dimension2D getCornerArcDimensions() { protected Dimension2D getCornerArcDimensions() {
// TODO (SB): Magic constant return DEFAULT_CORNER_ARC;
return new Dimension2D(15, 15);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected EDragGesture dragGestureHitTest(Node node, DiagramCoordinate diagramLocation) { protected EDragGesture dragGestureHitTest(Node node, DiagramCoordinate diagramLocation) {
if(node == getHitAreaShape()) { if(node == getHitAreaShape()) {
double x = diagramLocation.getLocalX(node); return getRectangularShapeDragGesture(node, diagramLocation, getHitAreaStartLinkSize(),
double y = diagramLocation.getLocalY(node); getHitAreaResizeSize());
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;
} }
if(node == getVisualShape() || node == text) { if(node == getVisualShape() || node == text) {
return EDragGesture.MOVE; return EDragGesture.MOVE;
......
...@@ -4,6 +4,6 @@ IContextMenuService.java cfb6b8237b6cd2b0e461991a9ceb95969f330265 GREEN ...@@ -4,6 +4,6 @@ IContextMenuService.java cfb6b8237b6cd2b0e461991a9ceb95969f330265 GREEN
IEditPartFactoryService.java c448bff63fb81f57037c9f1dc5319859c12d0c4d GREEN IEditPartFactoryService.java c448bff63fb81f57037c9f1dc5319859c12d0c4d GREEN
IMarkerService.java d433e838e387dd2fe61b8dea7395ebb7203ae39b GREEN IMarkerService.java d433e838e387dd2fe61b8dea7395ebb7203ae39b GREEN
IModelEditorBindingService.java ce2ae1957e2232bb0fac1d1d262103f9adfc5266 GREEN IModelEditorBindingService.java ce2ae1957e2232bb0fac1d1d262103f9adfc5266 GREEN
IModelElementHandlerService.java 580f526ed495ae474b3cf8e6851acd64322417da RED IModelElementHandlerService.java 748ffd22d6836a5599f8785f023469eb58c80ece YELLOW
INavigatorService.java 8d2ffeb6f075d3abea904b84d8a40090d97837fd GREEN INavigatorService.java 8d2ffeb6f075d3abea904b84d8a40090d97837fd GREEN
ITutorialUIService.java 72707c60c3d23d8ffc5c579cb9b022bb614eb094 GREEN ITutorialUIService.java 72707c60c3d23d8ffc5c579cb9b022bb614eb094 GREEN
...@@ -8,6 +8,6 @@ ILibraryService.java e1e2ec72b1db892478ed20c7fbb7dcf94472a1cd GREEN ...@@ -8,6 +8,6 @@ ILibraryService.java e1e2ec72b1db892478ed20c7fbb7dcf94472a1cd GREEN
ILoggingService.java 1ee9723af5a79299249e8db345e8419f814ff6d1 GREEN ILoggingService.java 1ee9723af5a79299249e8db345e8419f814ff6d1 GREEN
IMigrationService.java 7cfa6268b97f0c38c838905791e065655c6d6a04 GREEN IMigrationService.java 7cfa6268b97f0c38c838905791e065655c6d6a04 GREEN
IPersistencyService.java 2b2eeb329e3040e75f4352d9c374855583e27538 GREEN IPersistencyService.java 2b2eeb329e3040e75f4352d9c374855583e27538 GREEN
IPrototypeService.java 3f11fc887f729ab739736081af9e663d67d3131f YELLOW IPrototypeService.java d2b66742bea8bd6d394157985def6f8ea39c8d20 YELLOW
ITransformationService.java 71f175e94d7257713cb14c8148de5a309b03788a GREEN ITransformationService.java 71f175e94d7257713cb14c8148de5a309b03788a GREEN
ITutorialService.java 22a490516e38536203b1edd32711b615b77a4728 GREEN ITutorialService.java 22a490516e38536203b1edd32711b615b77a4728 GREEN
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