Commit 378ac241 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Components: JavaFX editor. Code update after review. Link feedback.

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 e84d3136
ComponentStructureFXEditor.java d097c17a4ebc5bc2a87659544d3dd15f2afde254 GREEN
ComponentStructureFXEditorBinding.java 230337d9526109ee2a9df599c370b0b3f2ec0b40 GREEN
ControllerFactory.java c123c5382e7b2e2e38c89655455443df08ec4de9 RED
ControllerFactory.java 0adaa2e7ab2e3bc73bae21aec736842a5abeb9a1 YELLOW
FXComponentEditorUtils.java acf8c3009a97543a5ed8d9dd24e80ba44d2f2e31 RED
ModelFactory.java d97242e6b8c69ccaad9fbb6adf80ffdb40520f80 GREEN
VisualFactory.java c3f9acf01cb627f07dca673631a4c8f632d2c4a9 GREEN
......@@ -33,8 +33,6 @@ import org.fortiss.af3.component.ui.editor.fx.controller.SubComponentPortControl
*
* @author hoelzl
*/
// TODO(AD): Just as a general suggestion: Isn't the name IController a bit too broad? Would
// IDiagramController be a better match?
final class ControllerFactory implements IControllerFactory {
/** {@inheritDoc} */
@Override
......
/*-------------------------------------------------------------------------+
| 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;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.base.model.layout.EOrientation;
import javafx.geometry.Rectangle2D;
import javafx.geometry.Side;
/**
* Utility methods for the visuals package.
*
* @author hoelzl
*/
// TODO(AD): Please move to the utils package.
// TODO(AD): Are the following methods only applicable to components? I guess it more specific to
// rectangles and should go to the kernel.
public final class FXComponentEditorUtils {
/** Computes the location of the link w.r.t. the given anchor bounds and target position. */
public static DiagramCoordinate computeLinkToAnchorLocation(Rectangle2D anchorBounds,
DiagramCoordinate target) {
double x = 0;
if(target.getX() < anchorBounds.getMinX()) {
x = -1.0;
} else if(target.getX() > anchorBounds.getMaxX()) {
x = 1.0;
}
double y = 0;
if(target.getY() < anchorBounds.getMinY()) {
y = -1.0;
} else if(target.getY() > anchorBounds.getMaxY()) {
y = 1.0;
}
double w2 = anchorBounds.getWidth() / 2;
double h2 = anchorBounds.getHeight() / 2;
x = anchorBounds.getMinX() + w2 + x * w2;
y = anchorBounds.getMinY() + h2 + y * h2;
return new DiagramCoordinate(x, y);
}
/** Returns the {@link EOrientation} for the given {@link Side}. */
public static EOrientation convertSideToEOrientation(Side s) {
switch(s) {
case TOP:
return EOrientation.NORTH;
case BOTTOM:
return EOrientation.SOUTH;
case LEFT:
return EOrientation.WEST;
case RIGHT:
return EOrientation.EAST;
}
return null;
}
/** Returns the {@link Side} for the given {@link EOrientation}. */
public static Side convertEOrientationToSide(EOrientation eo) {
switch(eo) {
case NORTH:
return Side.TOP;
case SOUTH:
return Side.BOTTOM;
case WEST:
return Side.LEFT;
case EAST:
return Side.RIGHT;
}
return null;
}
/** Constructor. */
private FXComponentEditorUtils() {
// prevent instantiation
}
}
ChannelController.java fe3fd8b71f320e93fa8581298581af6a9d5f8aee YELLOW
DiagramComponentPortController.java c99d075a9bc6b9c4214dee19aa5fd634ca5be379 YELLOW
DiagramController.java 74e96ce04d715a8084eb5d20b74567bc0168910d YELLOW
SubComponentController.java 562b0913d8ed8a2ea8fbd5e3e77ca367d1d8d9d8 YELLOW
SubComponentController.java 3fe6f80d4fec036983523b78a8a1892c7716cbda YELLOW
SubComponentPortController.java ce6b20088baeb1ddd5c98111316f707f71cd133e YELLOW
......@@ -15,9 +15,9 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor.fx.controller;
import static org.fortiss.af3.component.ui.editor.fx.FXComponentEditorUtils.convertSideToEOrientation;
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.LWFXEditorUtils.convertSideToEOrientation;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodeSize;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.moveNode;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodeSize;
......
ChannelVisual.java 8f2b33ad5709d3586c0302a26f2a43f742c85097 RED
ChannelVisual.java 302cff971a2d2efd4f20f3f77225ff0660580a13 YELLOW
CoordinateCorrections.java c676ffd7f26e4f29f6e3bbcbde7c26d4e4c21c4d GREEN
DiagramComponentPortVisual.java c93f811243549c17e902e01647783aa2d3dfd228 RED
SubComponentPortVisual.java b28957d5d657a6d07b8c47ca1a62ae5071d594e9 RED
SubComponentVisual.java 44ce6c1279689c5d0f4b12def0d18d39502c4171 RED
DiagramComponentPortVisual.java 842e298a4d01a9428083d5e86a614547cd065b23 YELLOW
SubComponentPortVisual.java db1ad8ec2246380b25b3e2d1edefe7f047f48b6f YELLOW
SubComponentVisual.java 026ef7e0dfd2a686728eaa71da5414805bda8995 YELLOW
......@@ -16,7 +16,7 @@
package org.fortiss.af3.component.ui.editor.fx.visual;
import static java.util.Collections.emptyList;
import static org.fortiss.af3.component.ui.editor.fx.FXComponentEditorUtils.computeLinkToAnchorLocation;
import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.computeLinkToAnchorLocation;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectionPoints;
import java.util.List;
......@@ -48,8 +48,6 @@ public final class ChannelVisual extends LineLinkVisualBase {
}
/** Returns the model element. */
// TODO(AD): (See comment in kernel): This wrapper could be eliminated by a parameterized
// IContentMVCBundle
public Channel getChannel() {
// wild cast works: see constructor
return (Channel)super.getModel();
......
......@@ -17,6 +17,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 javafx.scene.paint.Color.rgb;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_ALLOWED_TAG;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG;
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;
......@@ -30,6 +33,7 @@ import org.fortiss.tooling.base.model.layout.Point;
import javafx.geometry.Dimension2D;
import javafx.geometry.Rectangle2D;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
/**
......@@ -50,8 +54,6 @@ public final class DiagramComponentPortVisual extends CircularDiagramAnchorageVi
}
/** Returns the port model element. */
// TODO(AD): (See comment in kernel): This wrapper could be eliminated by a parameterized
// IContentMVCBundle
private Port getPort() {
// wild cast works: see constructor.
return (Port)super.getModel();
......@@ -97,4 +99,17 @@ public final class DiagramComponentPortVisual extends CircularDiagramAnchorageVi
protected double getBorderWidth() {
return 1.0;
}
/** {@inheritDoc} */
@Override
protected Color getInteractionColor() {
IDiagramAnchorageMVCBundle mvcBundle = getMVCBundle();
if(mvcBundle.hasTag(LINK_TARGET_DENIED_TAG)) {
return rgb(255, 0, 0, .25);
}
if(mvcBundle.hasTag(LINK_TARGET_ALLOWED_TAG)) {
return rgb(0, 255, 0, 0.25);
}
return super.getInteractionColor();
}
}
......@@ -17,9 +17,12 @@ 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 javafx.scene.paint.Color.rgb;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_ALLOWED_TAG;
import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG;
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.LWFXEditorUtils.convertEOrientationToSide;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorOffsetOrientation;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.layout.ILayout;
......@@ -37,6 +40,7 @@ import javafx.geometry.Dimension2D;
import javafx.geometry.Point2D;
import javafx.geometry.Rectangle2D;
import javafx.geometry.Side;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
/**
......@@ -58,8 +62,6 @@ public final class SubComponentPortVisual extends CircularContentAnchorageVisual
}
/** Returns the port model element. */
// TODO(AD): (See comment in kernel): This wrapper could be eliminated by a parameterized
// IContentMVCBundle
private Port getPort() {
// wild cast works: see constructor.
return (Port)super.getModel();
......@@ -146,4 +148,17 @@ public final class SubComponentPortVisual extends CircularContentAnchorageVisual
protected String getHoverText() {
return getPort().getName();
}
/** {@inheritDoc} */
@Override
protected Color getInteractionColor() {
IContentAnchorageMVCBundle mvcBundle = getMVCBundle();
if(mvcBundle.hasTag(LINK_TARGET_DENIED_TAG)) {
return rgb(255, 0, 0, .25);
}
if(mvcBundle.hasTag(LINK_TARGET_ALLOWED_TAG)) {
return rgb(0, 255, 0, 0.25);
}
return super.getInteractionColor();
}
}
......@@ -75,8 +75,6 @@ public final class SubComponentVisual extends RectangularContentVisualBase {
}
/** Returns the component model element. */
// TODO(AD): (See comment in kernel): This wrapper could be eliminated by a parameterized
// IContentMVCBundle
private Component getComponent() {
// wild cast works: see constructor
return (Component)getModel();
......@@ -96,8 +94,6 @@ public final class SubComponentVisual extends RectangularContentVisualBase {
/** {@inheritDoc} */
@Override
// TODO(AD): Candidate for generalization: Replace getComponent() with generified getModel() and
// put to the base class.
public Rectangle2D getModelBounds() {
Rectangle r = getNodeBounds(getComponent());
double ix = COMPONENT_INSETS.getWidth();
......@@ -109,7 +105,6 @@ public final class SubComponentVisual extends RectangularContentVisualBase {
/** {@inheritDoc} */
@Override
// TODO(AD): Same as above.
public DiagramCoordinate getAnchorageLocation(IContentAnchorageVisual visual) {
Rectangle2D pb = getCurrentBounds();
Side side = visual.getLayout(ISideLayout.class).getSide();
......
Markdown is supported
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