Skip to content
Snippets Groups Projects
Commit da5186d4 authored by Simon Barner's avatar Simon Barner
Browse files

Merge branch '3924' into 'master'

[3924] Fix small bugs in fx diagram editor

See merge request !89
parents c25294b3 121b97a9
No related branches found
No related tags found
1 merge request!89[3924] Fix small bugs in fx diagram editor
Showing
with 38 additions and 18 deletions
......@@ -3,7 +3,7 @@ CurvedLinkLayoutedContentAnchorangeController.java 6d2b64c3d6c813ac001b1500ed052
EObjectDiagramController.java 2b253941592ee25ead95223470f983f23ef9776f GREEN
EObjectEllipticResizableContentControllerBase.java 7c862a03b97d2f2cfdcc2fcee7434de2e1e257d2 GREEN
EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN
EObjectRectangularResizableContentControllerBase.java 28a17bf87f6a7222d927bc1c6b80967cb14b5f03 GREEN
EObjectRectangularResizableContentControllerBase.java e73cda8f54318f8b785a208215d9e31eaa46eff7 GREEN
KernelServiceBasedModelChangeProviderBase.java 8d1f8ef79ecd383ff74e5a2bbcf24345aabe70af GREEN
LayoutModelChangeProvider.java b5449d02eaf39086909720c43e21bd061005fc9e GREEN
LayoutedContentAnchorageController.java 9fc513a7404277514c730f7702d45588f2d81878 GREEN
......
......@@ -19,6 +19,7 @@ import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHA
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createElementCompositionContext;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createPrototypeMenu;
import static org.fortiss.tooling.base.ui.editor.fx.visual.CoordinateCorrections.RECTANGLE_INSETS;
import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.canCompose;
import static org.fortiss.tooling.base.ui.utils.FXDNDUtils.compose;
......@@ -146,7 +147,8 @@ public abstract class EObjectRectangularResizableContentControllerBase<T extends
/** {@inheritDoc} */
@Override
protected Dimension2D getMinimumSize() {
return new Dimension2D(DEFAULT_SHAPE_MINIMUM_WIDTH, DEFAULT_SHAPE_MINIMUM_HEIGHT);
return new Dimension2D(DEFAULT_SHAPE_MINIMUM_WIDTH - 2 * RECTANGLE_INSETS.getWidth(),
DEFAULT_SHAPE_MINIMUM_HEIGHT - 2 * RECTANGLE_INSETS.getHeight());
}
/** {@inheritDoc} */
......
......@@ -9,4 +9,4 @@ FeedbackChange.java b088fa89af648f1674f2f9c1f7f99d585ce801ca GREEN
GridCanvasVisual.java 734027d56af342cd01ff445ba9347b8dbb6c83c2 GREEN
MVCBundleManager.java 2b4ab114c55b30a3d98d7135458f8f3ddd244d58 GREEN
MouseState.java 3d9993f799d5d74bc74ac03b46e4a1857c4d267e GREEN
SVGExporter.java 2211f06d81c7b0523ae52dc832410a76875a9e07 GREEN
SVGExporter.java cbbd1eceb2910fd5c1693e05c5303a193127b9db GREEN
......@@ -197,9 +197,13 @@ final class SVGExporter {
return;
}
sb.append("<text ");
double yBaselineOffsetFromTop =
text.getBoundsInParent().getHeight() - text.getBaselineOffset();
setProp("x", text.getX(), sb);
setProp("y", text.getY(), sb);
setProp("font-family", "Arial, Helvetica, sans-serif", sb);
// SVG uses the y-coordinate of the baseline
setProp("y", text.getY() + yBaselineOffsetFromTop, sb);
setProp("font-size", text.getFont().getSize(), sb);
setProp("font-family", text.getFont().getName() + ", Arial, Helvetica, sans-serif", sb);
st.applySVGStyle(sb);
sb.append(">\n");
sb.append(text.getText());
......
AnchorageContentControllerBase.java da56b10cbf2711b5da69f0b59f43eacbe54f4eea GREEN
ClickControllerBase.java 8e5861ed5f9318008ad0fdd5497ed320cd5bd647 GREEN
ContentAnchorageMoveControllerBase.java c18e7915ce23e124757f5b736086ecc46694800a GREEN
ControllerBase.java c74e905a2b47dbf9b6443d94a877f1a9e56ba031 GREEN
ControllerBase.java 0ab6cf1b36cf3618a70c1666fd8747c59e90dbc6 GREEN
DefaultDiagramController.java 0e083b89a08f63967102a384d66ebc1d64d203af GREEN
DelegatingContentAnchorageController.java 2e3b1b4e14402a3503233f816b21ef3e4aa09edc GREEN
DragControllerBase.java b15ff874304f679fe494d85f57cc8cbe4d0d1d15 GREEN
......
......@@ -160,7 +160,13 @@ public abstract class ControllerBase extends MVCBundlePartBase implements IContr
IMVCBundle startBundle = getMVCBundle();
getViewer().terminateNewLinkLineFeedback();
if(canLink(startBundle, startDiagramLocation, endBundle, endDiagramLocation)) {
return () -> link(startBundle, startDiagramLocation, endBundle, endDiagramLocation);
// Need to copy the location to a local variable to make sure that it is passed
// by value to the returned closure. Otherwise the closure will capture 'this' and
// link will see a future value of startDiagramLocation, likely null because
// startDiagramLocation is being set to null right after this return.
final DiagramCoordinate startDiagramLocation_ = startDiagramLocation;
return () -> link(startBundle, startDiagramLocation_, endBundle,
endDiagramLocation);
}
return null;
}
......
DiamondResizableContentControllerBase.java 31f227e88205bd2e131326bdddd8421991b47d79 GREEN
RectangularContentAnchorageMoveController.java c119b011f5a38933cee07b8082fcd44c6c3b0037 GREEN
RectangularContentAnchorageMoveController.java 78b55be1a974ee1bca89a7934afb504f56bd495a GREEN
RectangularResizableContentControllerBase.java 262b083e4e0ce842b0bb8fbb594585e9f0d2f678 GREEN
RhomboidContentAnchorageMoveController.java fbd40ce483f99c18cfa94076374f572bb72c2646 GREEN
RhomboidResizableContentControllerBase.java 863b9eae49bad18f71b20c8cde4b0f350348aa27 GREEN
......@@ -44,8 +44,9 @@ public class RectangularContentAnchorageMoveController extends ContentAnchorageM
Dimension2D anchorageSize =
new Dimension2D(anchorageBounds.getWidth(), anchorageBounds.getHeight());
Dimension2D borderSnap = overrideBorderSnap(anchorageSize);
DiagramCoordinate p = new DiagramCoordinate(anchorageBounds.getMinX() + delta.getX(),
anchorageBounds.getMinY() + delta.getY());
DiagramCoordinate p = new DiagramCoordinate(
anchorageBounds.getMinX() + anchorageSize.getWidth() / 2 + delta.getX(),
anchorageBounds.getMinY() + anchorageSize.getHeight() / 2 + delta.getY());
return getClosestLocationOnBounds(p, contentBounds, anchorageSize, borderSnap);
}
......
......@@ -3,5 +3,5 @@ CircularContentVisualBase.java cc3caea328e36e90069b915e413c8e7e9522a939 GREEN
CircularDiagramAnchorageVisualBase.java 7a3b92fb1b135c218b9a5e16506acfc74a6b5468 GREEN
CurveLinkVisualBase.java 5ce3086769004a9eb6800d7eb58379d831ff74b1 GREEN
CurveSegment.java 0e7f70e9526a74aaec2bec4f4fc16295521cf5f2 GREEN
EllipticBorderLocation.java 1e9b3d42c7fcd5495004fb30b0c499096a839967 GREEN
EllipticBorderLocation.java af451b11d388ba7ebd3831cf44322909892388e6 GREEN
EllipticContentVisualBase.java dc2fddc9cfe5605bc8a5d09dd862845e360b23f5 GREEN
......@@ -10,8 +10,6 @@
package org.fortiss.tooling.common.ui.javafx.lwfxef.visual.elliptic;
import static java.lang.Math.atan2;
import static java.lang.Math.cos;
import static java.lang.Math.sin;
import static java.util.Objects.requireNonNull;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
......@@ -53,14 +51,23 @@ public final class EllipticBorderLocation {
/**
* Returns the location computed from this {@link EllipticBorderLocation} relative to the
* ellipse center.
* TODO(JE): leads to java.lang.ArithmeticException: / by zero if cos is 0. What is the
* difference to the existing code? Why is an adaption needed?
*/
public DiagramCoordinate getLocation() {
double rw = radiuses.getWidth();
double rh = radiuses.getHeight();
double angle = Math.PI * angleInDegree / 180;
double x = rw - correction.getWidth() / 2 + rw * cos(angle);
double y = rh - correction.getHeight() / 2 - rh * sin(angle);
return new DiagramCoordinate(x, y);
double rh = radiuses.getWidth();
double rv = radiuses.getHeight();
DiagramCoordinate middle = new DiagramCoordinate(rh, rv);
double cos = Math.cos(angle);
double sin = Math.sin(angle);
double tan = (sin / cos);
// Division by zero will result in tan being Infinity,
// which gives the right results for x and y.
double x = rh * rv / Math.sqrt(rv * rv + rh * rh * tan * tan);
double y = rh * rv * Math.signum(tan) / Math.sqrt(rv * rv / (tan * tan) + rh * rh);
return middle.add(x * Math.signum(cos), -y * Math.signum(cos))
.subtract(correction.getWidth() / 2.0, correction.getHeight() / 2.0);
}
/**
......
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