Commit 1a5890b8 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Components: JavaFX editor. Fixed border dragging of component ports.

Issue-Ref: 3815
Issue-Url: https://af3-developer.fortiss.org/issues/3815

Signed-off-by: Florian Hölzl's avatarFlorian Hoelzl <hoelzl@fortiss.org>
parent a6f99954
ComponentStructureFXEditor.java 0d5e3c00d0021fbd469841706093cccde85d7d42 YELLOW
ComponentStructureFXEditorBinding.java 3f78a7b48cb7b9a0b0b35fab58a4ad7f3233c18a YELLOW
ControllerFactory.java c319c22e2a3df19bf972bf7ad78c5b9c5aa64be3 YELLOW
ControllerFactory.java 0adaa2e7ab2e3bc73bae21aec736842a5abeb9a1 YELLOW
FXComponentEditorUtils.java 6aa86b3c28b6a8a68844d251c961378d83df7710 YELLOW
ModelFactory.java 4ae8e202869cffac25fa8eea484c4ab9411f8948 YELLOW
VisualFactory.java c3f9acf01cb627f07dca673631a4c8f632d2c4a9 YELLOW
ChannelController.java 99c2b3b99b4fe37642605a33a3f6fd7c12a2f6bf RED
DiagramComponentPortController.java 98f2b9c069c48d98fbf3a51fd086a3f5cffce911 RED
DiagramController.java 4d184103feefcaf9a74ed63538d227b975f9c4f8 RED
SubComponentController.java 42d3c964f33bef24172a44819672988ba07e6edd RED
SubComponentPortController.java ce6b20088baeb1ddd5c98111316f707f71cd133e RED
DiagramComponentPortController.java 98f2b9c069c48d98fbf3a51fd086a3f5cffce911 YELLOW
DiagramController.java 74e96ce04d715a8084eb5d20b74567bc0168910d YELLOW
SubComponentController.java 562b0913d8ed8a2ea8fbd5e3e77ca367d1d8d9d8 YELLOW
SubComponentPortController.java ce6b20088baeb1ddd5c98111316f707f71cd133e YELLOW
......@@ -15,9 +15,6 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor.fx.controller;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.base.ui.editor.fx.EObjectBasedDiagramControllerBase;
......@@ -32,24 +29,4 @@ public final class DiagramController extends EObjectBasedDiagramControllerBase {
public DiagramController(IMVCBundle mvcb) {
super(mvcb);
}
/** Notification adapter for model change events. */
private final Adapter notificationListener = new AdapterImpl() {
@Override
public void notifyChanged(Notification event) {
fireUpdateComplete();
}
};
/** {@inheritDoc} */
@Override
protected void connectToModel() {
getEObject().eAdapters().add(notificationListener);
}
/** {@inheritDoc} */
@Override
protected void disconnectFromModel() {
getEObject().eAdapters().remove(notificationListener);
}
}
......@@ -25,6 +25,8 @@ import static org.fortiss.tooling.base.utils.LayoutDataUtils.setStickyConnectorL
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.FeedbackChange;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IDragController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.rectangular.RectangularContentAnchorageMoveController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.af3.component.model.Component;
......@@ -58,6 +60,22 @@ public final class SubComponentController
return (Component)getModel();
}
/** {@inheritDoc} */
@Override
protected IDragController createAnchorageMoveController(IContentAnchorageMVCBundle anchorage) {
// we need an overridden port move controller due to the frameworks default snapping
// behavior, which snaps to anchorage size while AF3 ports snap to half their size
return new RectangularContentAnchorageMoveController(this, anchorage) {
/** {@inheritDoc} */
@Override
protected Dimension2D overrideBorderSnap(Dimension2D anchorageSize) {
// this override is required because ports can be moved by half their size
// while the default implementation would only allow for full size of the port
return new Dimension2D(anchorageSize.getWidth() / 2, anchorageSize.getHeight() / 2);
}
};
}
/** {@inheritDoc} */
@Override
protected void moveAnchorageToSideOffset(IContentAnchorageMVCBundle anchorage, Side side,
......@@ -65,7 +83,16 @@ public final class SubComponentController
Object portObj = anchorage.getModel();
if(portObj instanceof Port) {
Port port = (Port)portObj;
setStickyConnectorLayoutData(port, convertSideToEOrientation(side), (int)offset);
// the following correction compensates for SubComponentPortVisual.getOffset()
Dimension2D portDim = anchorage.getVisual().getDimensions();
int correction;
if(side == Side.TOP || side == Side.BOTTOM) {
correction = (int)portDim.getWidth() / 2;
} else {
correction = (int)portDim.getHeight() / 2;
}
int corrected = (int)offset + correction;
setStickyConnectorLayoutData(port, convertSideToEOrientation(side), corrected);
}
}
......
ChannelVisual.java 1f2e539d25326fa1bbcedf32362f5d643582dff1 RED
DiagramComponentPortVisual.java 4a2e4f089bf55d8642d0f334a6978cc2bf8bf954 YELLOW
SubComponentPortVisual.java 90fb107e57fe107b56b38fcf66a273f286b50760 RED
SubComponentVisual.java 84f6549016ae4a0e8b430918bc00c682645c7724 YELLOW
ChannelVisual.java 1f2e539d25326fa1bbcedf32362f5d643582dff1 YELLOW
CoordinateCorrections.java c676ffd7f26e4f29f6e3bbcbde7c26d4e4c21c4d YELLOW
DiagramComponentPortVisual.java 027a24874dbcf67559986a87620aefc21e8efc12 YELLOW
SubComponentPortVisual.java b67585448c283c29de8dabc674f0c5e49596d70e RED
SubComponentVisual.java 026ef7e0dfd2a686728eaa71da5414805bda8995 YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2019 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.af3.component.ui.editor.fx.visual;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
import org.fortiss.tooling.base.layout.DefaultLayoutConstants;
import javafx.geometry.Dimension2D;
/**
* This class contains corrections of {@link DefaultLayoutConstants}.
*
* @author hoelzl
*/
class CoordinateCorrections {
/** The insets of components. */
/* package */ static final Dimension2D COMPONENT_INSETS =
new Dimension2D(DEFAULT_CONNECTOR_SIZE / 2, DEFAULT_CONNECTOR_SIZE / 2);
/** The default size of ports. */
/* package */ static final Dimension2D PORT_DIMENSION =
new Dimension2D(DEFAULT_CONNECTOR_SIZE, DEFAULT_CONNECTOR_SIZE);
/** The insets of the port visuals. */
/* package */ static final double PORT_INSET = DEFAULT_CONNECTOR_SIZE / 4.5;
}
......@@ -17,7 +17,8 @@ package org.fortiss.af3.component.ui.editor.fx.visual;
import static javafx.scene.paint.Color.BLACK;
import static javafx.scene.paint.Color.WHITE;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
import static org.fortiss.af3.component.ui.editor.fx.visual.CoordinateCorrections.PORT_DIMENSION;
import static org.fortiss.af3.component.ui.editor.fx.visual.CoordinateCorrections.PORT_INSET;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodePosition;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
......@@ -38,12 +39,6 @@ import javafx.scene.paint.Paint;
* @author hoelzl
*/
public final class DiagramComponentPortVisual extends CircularDiagramAnchorageVisualBase {
/** The default size of diagram anchorages. */
/* package */ static final Dimension2D PORT_DIMENSION =
new Dimension2D(DEFAULT_CONNECTOR_SIZE, DEFAULT_CONNECTOR_SIZE);
/** The insets of the anchorages. */
/* package */ static final double PORT_INSET = DEFAULT_CONNECTOR_SIZE / 4.5;
/** Constructor. */
public DiagramComponentPortVisual(IDiagramAnchorageMVCBundle mvcb) {
super(mvcb);
......
......@@ -18,9 +18,9 @@ package org.fortiss.af3.component.ui.editor.fx.visual;
import static javafx.scene.paint.Color.BLACK;
import static javafx.scene.paint.Color.WHITE;
import static org.fortiss.af3.component.ui.editor.fx.FXComponentEditorUtils.convertEOrientationToSide;
import static org.fortiss.af3.component.ui.editor.fx.visual.DiagramComponentPortVisual.PORT_DIMENSION;
import static org.fortiss.af3.component.ui.editor.fx.visual.DiagramComponentPortVisual.PORT_INSET;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorOffset;
import static org.fortiss.af3.component.ui.editor.fx.visual.CoordinateCorrections.PORT_DIMENSION;
import static org.fortiss.af3.component.ui.editor.fx.visual.CoordinateCorrections.PORT_INSET;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorOffsetOrientation;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.ILayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.IOffsetLayout;
......@@ -32,7 +32,6 @@ import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.component.model.Port;
import org.fortiss.tooling.base.model.layout.EOrientation;
import org.fortiss.tooling.base.model.layout.OffsetOrientation;
import org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils;
import javafx.geometry.Dimension2D;
import javafx.geometry.Point2D;
......@@ -95,24 +94,16 @@ public final class SubComponentPortVisual extends CircularContentAnchorageVisual
/** {@inheritDoc} */
@Override
public double getOffset() {
// FIXME: after bugfix #3868
OffsetOrientation oo = LayoutDataUIUtils.getConnectorOffsetOrientation(getPort());
EOrientation eo = EOrientation.NORTH;
if(oo != null) {
eo = oo.getOrientation();
}
double dy = 0;
if(eo == EOrientation.WEST || eo == EOrientation.EAST) {
dy = PORT_DIMENSION.getHeight() / 2;
}
return getConnectorOffset(getPort()).getOffset() - dy;
OffsetOrientation oo = getConnectorOffsetOrientation(getPort());
double inset = getDimensions().getWidth() / 2;
return oo.getOffset() - inset;
}
/** {@inheritDoc} */
@Override
public Side getSide() {
// FIXME: after bugfix #3868
OffsetOrientation oo = LayoutDataUIUtils.getConnectorOffsetOrientation(getPort());
OffsetOrientation oo = getConnectorOffsetOrientation(getPort());
EOrientation eo = EOrientation.NORTH;
if(oo != null) {
eo = oo.getOrientation();
......@@ -147,4 +138,10 @@ public final class SubComponentPortVisual extends CircularContentAnchorageVisual
protected double getBorderWidth() {
return 1.0;
}
/** {@inheritDoc} */
@Override
protected String getHoverText() {
return getPort().getName();
}
}
......@@ -21,17 +21,24 @@ import static org.fortiss.af3.component.ui.AF3ComponentUIActivator.getFXImage;
import static org.fortiss.af3.component.ui.DefaultStyle.STRONGLY_CAUSAL_COMPONENT_BACKGROUND;
import static org.fortiss.af3.component.ui.DefaultStyle.SUBSTRUCTURE_COMPONENT_BACKGROUND;
import static org.fortiss.af3.component.ui.DefaultStyle.WEAKLY_CAUSAL_COMPONENT_BACKGROUND;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
import static org.fortiss.af3.component.ui.editor.fx.visual.CoordinateCorrections.COMPONENT_INSETS;
import static org.fortiss.af3.component.ui.editor.fx.visual.CoordinateCorrections.PORT_DIMENSION;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodeBounds;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.IOffsetLayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.ISideLayout;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IContentAnchorageVisual;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IContentVisual;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.rectangular.RectangularBorderLocation;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.rectangular.RectangularContentVisualBase;
import org.fortiss.af3.component.model.Component;
import org.fortiss.tooling.base.model.layout.Rectangle;
import javafx.geometry.Dimension2D;
import javafx.geometry.Rectangle2D;
import javafx.geometry.Side;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
......@@ -89,10 +96,20 @@ public final class SubComponentVisual extends RectangularContentVisualBase {
@Override
public Rectangle2D getModelBounds() {
Rectangle r = getNodeBounds(getComponent());
double inset = DEFAULT_CONNECTOR_SIZE / 2;
double inset2 = 2 * inset;
return new Rectangle2D(r.getX() + inset, r.getY() + inset, r.getWidth() - inset2,
r.getHeight() - inset2);
double ix = COMPONENT_INSETS.getWidth();
double dw = ix * 2;
double iy = COMPONENT_INSETS.getHeight();
double dh = ix * 2;
return new Rectangle2D(r.getX() + ix, r.getY() + iy, r.getWidth() - dw, r.getHeight() - dh);
}
/** {@inheritDoc} */
@Override
public DiagramCoordinate getAnchorageLocation(IContentAnchorageVisual visual) {
Rectangle2D pb = getCurrentBounds();
Side side = visual.getLayout(ISideLayout.class).getSide();
double offset = visual.getLayout(IOffsetLayout.class).getOffset();
return new RectangularBorderLocation(side, offset, pb, PORT_DIMENSION).getLocation();
}
/** {@inheritDoc} */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment