This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new be02c61c66 Add an option to draw hops as curves , fixes #9274 (#9272)
be02c61c66 is described below
commit be02c61c6659b30958b1e5b3a89140b988fbc52c
Author: mhamedbenjmaa <[email protected]>
AuthorDate: Thu Nov 5 08:58:05 2026 -0500
Add an option to draw hops as curves , fixes #9274 (#9272)
* Add an option to draw hops as curves
A new "Hop line shape" option in the GUI options (Straight / Curved) lets
hops be drawn as smooth Bézier curves instead of straight center-to-center
lines. A curved hop leaves its source icon and enters its target icon on
the side that faces the other icon (left, right, top or bottom), so it no
longer runs across the icons.
- HopPath holds the hop geometry, used by both painters to draw the hop
and place the arrow, hop icons and badges, and by the graphs to find
the hop under the mouse.
- IGc gets drawCubicCurve(), drawn natively by SwtGc (SWT Path) and
SvgGc (CubicCurve2D), with a polyline fallback for other implementations.
- Hop Web draws the same curve in its drag preview.
- Straight stays the default; nothing changes unless the option is set.
* Test that a click on a curved hop finds the hop
With the Curved hop line shape, a ctrl-click on a point of the curve that is
off the straight center-to-center line must still find the hop. With
Straight
the same point misses it.
* Test that a click on a curved workflow hop finds the hop
Same check as HopGuiPipelineGraphCurvedHopTest, on the workflow canvas.
---
.../pages/hop-gui/perspective-configuration.adoc | 2 +
.../java/org/apache/hop/core/gui/BasePainter.java | 42 ++++
.../java/org/apache/hop/core/gui/HopLineShape.java | 73 ++++++
.../main/java/org/apache/hop/core/gui/HopPath.java | 219 ++++++++++++++++++
.../src/main/java/org/apache/hop/core/gui/IGc.java | 24 ++
.../main/java/org/apache/hop/core/gui/SvgGc.java | 16 ++
.../org/apache/hop/pipeline/PipelinePainter.java | 54 ++---
.../org/apache/hop/workflow/WorkflowPainter.java | 39 ++--
.../core/gui/messages/messages_en_US.properties | 2 +
.../core/gui/messages/messages_fr_FR.properties | 2 +
.../java/org/apache/hop/core/gui/HopPathTest.java | 94 ++++++++
.../org/apache/hop/ui/hopgui/CanvasFacadeImpl.java | 1 +
.../apache/hop/ui/hopgui/CanvasSvgFacadeImpl.java | 1 +
.../resources/org/apache/hop/ui/hopgui/canvas.js | 35 ++-
.../pipeline/HopGuiPipelineGraphCurvedHopTest.java | 230 +++++++++++++++++++
.../workflow/HopGuiWorkflowGraphCurvedHopTest.java | 245 +++++++++++++++++++++
.../main/java/org/apache/hop/ui/core/PropsUi.java | 10 +
.../hopgui/file/pipeline/HopGuiPipelineGraph.java | 6 +
.../hopgui/file/workflow/HopGuiWorkflowGraph.java | 6 +
.../configuration/tabs/ConfigGuiOptionsTab.java | 17 ++
.../org/apache/hop/ui/hopgui/shared/SwtGc.java | 14 ++
.../core/dialog/messages/messages_en_US.properties | 2 +
.../core/dialog/messages/messages_fr_FR.properties | 2 +
23 files changed, 1080 insertions(+), 56 deletions(-)
diff --git
a/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-configuration.adoc
b/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-configuration.adoc
index aae3bcc4be..306cacbeb5 100644
---
a/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-configuration.adoc
+++
b/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-configuration.adoc
@@ -153,6 +153,8 @@ Some of these settings only take effect after Hop GUI is
restarted; the dialog s
|Line width on workspace|The width hops are drawn with on the canvas, in
pixels.|1
+|Hop line shape|How hops are drawn on the canvas. *Straight* draws a line from
icon center to icon center. *Curved* draws a smooth curve that leaves and
enters each icon on the side facing the other icon.|Straight
+
|Dialog middle percentage|Where the divider between labels and input fields
sits in dialogs, as a percentage of the dialog width. Raise it where a
translation makes labels too wide for their column.|35
|===
diff --git a/engine/src/main/java/org/apache/hop/core/gui/BasePainter.java
b/engine/src/main/java/org/apache/hop/core/gui/BasePainter.java
index ed4590cdf0..2c474b5893 100644
--- a/engine/src/main/java/org/apache/hop/core/gui/BasePainter.java
+++ b/engine/src/main/java/org/apache/hop/core/gui/BasePainter.java
@@ -69,6 +69,9 @@ public abstract class BasePainter<H extends BaseHopMeta<?>, P
extends IBaseMeta>
protected int lineWidth;
protected float magnification;
+ /** How hops are drawn: straight or curved. Read from the Hop GUI options. */
+ protected HopLineShape hopLineShape;
+
protected Object subject;
protected IVariables variables;
@@ -133,6 +136,7 @@ public abstract class BasePainter<H extends BaseHopMeta<?>,
P extends IBaseMeta>
this.miniIconSize = iconSize / 2;
this.lineWidth = lineWidth;
this.gridSize = gridSize;
+ this.hopLineShape = HopLineShape.getConfigured();
this.magnification = 1.0f;
this.zoomFactor = zoomFactor;
@@ -642,6 +646,44 @@ public abstract class BasePainter<H extends
BaseHopMeta<?>, P extends IBaseMeta>
return new int[] {x1, y1, x2, y2};
}
+ /**
+ * Build the path of a hop between two points in screen coordinates.
+ *
+ * @param startObject the source transform or action, or a {@link Point}
while a hop is dragged
+ * @param endObject the target transform or action, or a {@link Point} while
a hop is dragged
+ */
+ protected HopPath createHopPath(
+ int x1, int y1, int x2, int y2, Object startObject, Object endObject) {
+ return HopPath.create(
+ hopLineShape, x1, y1, x2, y2, iconSize, isIcon(startObject),
isIcon(endObject));
+ }
+
+ private static boolean isIcon(Object object) {
+ return object != null && !(object instanceof Point);
+ }
+
+ /**
+ * Where the arrow sits on a hop, as a fraction of its length. A straight
hop keeps the arrow past
+ * the middle; a curved hop puts it just in front of the target icon.
+ *
+ * @param factor the straight-line position factor (0 to 2, 1 is the middle)
+ */
+ protected double getArrowFraction(HopPath path, double factor) {
+ if (!path.isCurved()) {
+ return factor / 2;
+ }
+ double length = path.getLength();
+ if (length <= 0) {
+ return 1;
+ }
+ return Math.max(0.5, 1 - (miniIconSize * 0.6) / length);
+ }
+
+ /** Where the hop icons (copy, error, info, ...) start, as a fraction of the
hop length. */
+ protected double getHopIconFraction(HopPath path) {
+ return path.isCurved() ? 0.5 : 0.4;
+ }
+
@SuppressWarnings("javabugs:S2259") // callers pass a line from getLine()
with non-null endpoints
protected void drawArrow(EImage arrow, int[] line, H hop, Object
startObject, Object endObject)
throws HopException {
diff --git a/engine/src/main/java/org/apache/hop/core/gui/HopLineShape.java
b/engine/src/main/java/org/apache/hop/core/gui/HopLineShape.java
new file mode 100644
index 0000000000..aebee04f9e
--- /dev/null
+++ b/engine/src/main/java/org/apache/hop/core/gui/HopLineShape.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.hop.core.gui;
+
+import org.apache.hop.core.config.HopConfig;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.metadata.api.IEnumHasCode;
+import org.apache.hop.metadata.api.IEnumHasCodeAndDescription;
+
+/** How hops are drawn between transforms or actions on the canvas. */
+public enum HopLineShape implements IEnumHasCodeAndDescription {
+ /** A straight line from icon center to icon center. */
+ STRAIGHT("HopLineShape.Straight"),
+ /** A smooth curve that leaves and enters an icon on the side that faces the
other icon. */
+ CURVED("HopLineShape.Curved");
+
+ /** The Hop GUI property that stores the selected shape. */
+ public static final String GUI_PROPERTY_KEY = "HopLineShape";
+
+ private final String descriptionKey;
+
+ HopLineShape(String descriptionKey) {
+ this.descriptionKey = descriptionKey;
+ }
+
+ @Override
+ public String getCode() {
+ return name();
+ }
+
+ @Override
+ public String getDescription() {
+ return BaseMessages.getString(HopLineShape.class, descriptionKey);
+ }
+
+ public static String[] getDescriptions() {
+ return IEnumHasCodeAndDescription.getDescriptions(HopLineShape.class);
+ }
+
+ public static HopLineShape lookupDescription(String description) {
+ return IEnumHasCodeAndDescription.lookupDescription(HopLineShape.class,
description, STRAIGHT);
+ }
+
+ public static HopLineShape lookupCode(String code) {
+ return IEnumHasCode.lookupCode(HopLineShape.class, code, STRAIGHT);
+ }
+
+ /**
+ * @return the shape selected in the Hop GUI options, or {@link #STRAIGHT}
when none is set.
+ */
+ public static HopLineShape getConfigured() {
+ try {
+ return lookupCode(HopConfig.getGuiProperty(GUI_PROPERTY_KEY));
+ } catch (Exception e) {
+ return STRAIGHT;
+ }
+ }
+}
diff --git a/engine/src/main/java/org/apache/hop/core/gui/HopPath.java
b/engine/src/main/java/org/apache/hop/core/gui/HopPath.java
new file mode 100644
index 0000000000..f18b27249e
--- /dev/null
+++ b/engine/src/main/java/org/apache/hop/core/gui/HopPath.java
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.hop.core.gui;
+
+import lombok.Getter;
+
+/**
+ * The geometry of a hop on the canvas: a straight line or a curve, stored as
a polyline. The
+ * painters use it to draw the hop and place the arrow and hop icons; the
graphs use it to find the
+ * hop under the mouse.
+ *
+ * <p>A curved hop leaves its source icon on the side that faces the target
and enters the target on
+ * the opposite side: left or right when the icons are further apart
horizontally than vertically,
+ * top or bottom otherwise.
+ */
+public final class HopPath {
+
+ /** Number of straight segments used to approximate a curve. */
+ private static final int CURVE_SEGMENTS = 32;
+
+ /** Smallest distance between an end point and its Bézier control point. */
+ private static final double MIN_CONTROL_DISTANCE = 20.0;
+
+ /** Largest distance between an end point and its Bézier control point. */
+ private static final double MAX_CONTROL_DISTANCE = 150.0;
+
+ private final double[] xs;
+ private final double[] ys;
+
+ /** Cumulative length of the polyline at each point. */
+ private final double[] lengths;
+
+ @Getter private final boolean curved;
+
+ /** For a curve: start, first control point, second control point, end. Null
for a line. */
+ private final double[] bezier;
+
+ private HopPath(double[] xs, double[] ys, double[] bezier) {
+ this.xs = xs;
+ this.ys = ys;
+ this.bezier = bezier;
+ this.curved = bezier != null;
+ this.lengths = new double[xs.length];
+ for (int i = 1; i < xs.length; i++) {
+ lengths[i] = lengths[i - 1] + Math.hypot(xs[i] - xs[i - 1], ys[i] - ys[i
- 1]);
+ }
+ }
+
+ /** A straight line from (x1,y1) to (x2,y2). */
+ public static HopPath straight(int x1, int y1, int x2, int y2) {
+ return new HopPath(new double[] {x1, x2}, new double[] {y1, y2}, null);
+ }
+
+ /**
+ * Build the path of a hop between two points.
+ *
+ * @param shape the configured line shape
+ * @param x1 x of the source: the icon center when {@code startIsIcon},
otherwise a free point
+ * @param y1 y of the source
+ * @param x2 x of the target: the icon center when {@code endIsIcon},
otherwise a free point
+ * @param y2 y of the target
+ * @param iconSize the icon size, used to start and end a curve on the icon
border
+ * @param startIsIcon true when (x1,y1) is the center of an icon
+ * @param endIsIcon true when (x2,y2) is the center of an icon
+ */
+ public static HopPath create(
+ HopLineShape shape,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ int iconSize,
+ boolean startIsIcon,
+ boolean endIsIcon) {
+ if (shape != HopLineShape.CURVED) {
+ return straight(x1, y1, x2, y2);
+ }
+ return curved(x1, y1, x2, y2, iconSize, startIsIcon, endIsIcon);
+ }
+
+ /** A curve between two icon centers (or free points), see {@link #create}.
*/
+ public static HopPath curved(
+ int x1, int y1, int x2, int y2, int iconSize, boolean startIsIcon,
boolean endIsIcon) {
+ double half = iconSize / 2.0;
+ int dx = x2 - x1;
+ int dy = y2 - y1;
+
+ // Direction in which the hop leaves the source and enters the target.
+ //
+ double dirX;
+ double dirY;
+ if (Math.abs(dx) >= Math.abs(dy)) {
+ dirX = dx >= 0 ? 1 : -1;
+ dirY = 0;
+ } else {
+ dirX = 0;
+ dirY = dy >= 0 ? 1 : -1;
+ }
+
+ double sx = startIsIcon ? x1 + dirX * half : x1;
+ double sy = startIsIcon ? y1 + dirY * half : y1;
+ double ex = endIsIcon ? x2 - dirX * half : x2;
+ double ey = endIsIcon ? y2 - dirY * half : y2;
+
+ double control =
+ Math.clamp(Math.hypot(ex - sx, ey - sy) / 2.0, MIN_CONTROL_DISTANCE,
MAX_CONTROL_DISTANCE);
+ double c1x = sx + dirX * control;
+ double c1y = sy + dirY * control;
+ double c2x = ex - dirX * control;
+ double c2y = ey - dirY * control;
+
+ double[] xs = new double[CURVE_SEGMENTS + 1];
+ double[] ys = new double[CURVE_SEGMENTS + 1];
+ for (int i = 0; i <= CURVE_SEGMENTS; i++) {
+ double t = (double) i / CURVE_SEGMENTS;
+ double u = 1 - t;
+ double a = u * u * u;
+ double b = 3 * u * u * t;
+ double c = 3 * u * t * t;
+ double d = t * t * t;
+ xs[i] = a * sx + b * c1x + c * c2x + d * ex;
+ ys[i] = a * sy + b * c1y + c * c2y + d * ey;
+ }
+ return new HopPath(xs, ys, new double[] {sx, sy, c1x, c1y, c2x, c2y, ex,
ey});
+ }
+
+ /** Total length of the path. */
+ public double getLength() {
+ return lengths[lengths.length - 1];
+ }
+
+ /** Draw the path with the current foreground color, line width and line
style. */
+ public void draw(IGc gc) {
+ if (curved) {
+ gc.drawCubicCurve(
+ bezier[0], bezier[1], bezier[2], bezier[3], bezier[4], bezier[5],
bezier[6], bezier[7]);
+ } else {
+ gc.drawLine(
+ (int) Math.round(xs[0]),
+ (int) Math.round(ys[0]),
+ (int) Math.round(xs[1]),
+ (int) Math.round(ys[1]));
+ }
+ }
+
+ /**
+ * The point at a fraction of the path length. For a straight line this is
plain interpolation
+ * between the two end points.
+ *
+ * @param fraction 0 is the start, 1 is the end
+ * @return {x, y}
+ */
+ public double[] pointAt(double fraction) {
+ if (!curved) {
+ return new double[] {xs[0] + fraction * (xs[1] - xs[0]), ys[0] +
fraction * (ys[1] - ys[0])};
+ }
+ double target = Math.clamp(fraction, 0.0, 1.0) * getLength();
+ int i = segmentAt(target);
+ double segmentLength = lengths[i + 1] - lengths[i];
+ double f = segmentLength <= 0 ? 0 : (target - lengths[i]) / segmentLength;
+ return new double[] {xs[i] + f * (xs[i + 1] - xs[i]), ys[i] + f * (ys[i +
1] - ys[i])};
+ }
+
+ /**
+ * The direction of the path at a fraction of its length.
+ *
+ * @return the angle in radians, as returned by {@link Math#atan2}
+ */
+ public double angleAt(double fraction) {
+ if (!curved) {
+ return Math.atan2(ys[1] - ys[0], xs[1] - xs[0]);
+ }
+ int i = segmentAt(Math.clamp(fraction, 0.0, 1.0) * getLength());
+ return Math.atan2(ys[i + 1] - ys[i], xs[i + 1] - xs[i]);
+ }
+
+ /** The shortest distance from (x,y) to the path. */
+ public double distanceTo(double x, double y) {
+ double best = Double.MAX_VALUE;
+ for (int i = 0; i < xs.length - 1; i++) {
+ best = Math.min(best, distanceToSegment(x, y, xs[i], ys[i], xs[i + 1],
ys[i + 1]));
+ }
+ return best;
+ }
+
+ private int segmentAt(double length) {
+ for (int i = 0; i < xs.length - 2; i++) {
+ if (length <= lengths[i + 1]) {
+ return i;
+ }
+ }
+ return xs.length - 2;
+ }
+
+ private static double distanceToSegment(
+ double px, double py, double ax, double ay, double bx, double by) {
+ double vx = bx - ax;
+ double vy = by - ay;
+ double lengthSquared = vx * vx + vy * vy;
+ double t = lengthSquared <= 0 ? 0 : ((px - ax) * vx + (py - ay) * vy) /
lengthSquared;
+ t = Math.clamp(t, 0.0, 1.0);
+ return Math.hypot(px - (ax + t * vx), py - (ay + t * vy));
+ }
+}
diff --git a/engine/src/main/java/org/apache/hop/core/gui/IGc.java
b/engine/src/main/java/org/apache/hop/core/gui/IGc.java
index ff8ef77530..25b7224887 100644
--- a/engine/src/main/java/org/apache/hop/core/gui/IGc.java
+++ b/engine/src/main/java/org/apache/hop/core/gui/IGc.java
@@ -169,6 +169,30 @@ public interface IGc {
void drawPolyline(int[] polyline);
+ /**
+ * Draw a cubic Bézier curve from (x1,y1) to (x2,y2) with control points
(cx1,cy1) and (cx2,cy2),
+ * using the current foreground color, line width and line style. The
default draws the curve as a
+ * polyline; implementations should draw a smooth curve.
+ */
+ default void drawCubicCurve(
+ double x1, double y1, double cx1, double cy1, double cx2, double cy2,
double x2, double y2) {
+ int segments = 32;
+ int[] polyline = new int[(segments + 1) * 2];
+ for (int i = 0; i <= segments; i++) {
+ double t = (double) i / segments;
+ double u = 1 - t;
+ polyline[i * 2] =
+ (int)
+ Math.round(
+ u * u * u * x1 + 3 * u * u * t * cx1 + 3 * u * t * t * cx2 +
t * t * t * x2);
+ polyline[i * 2 + 1] =
+ (int)
+ Math.round(
+ u * u * u * y1 + 3 * u * u * t * cy1 + 3 * u * t * t * cy2 +
t * t * t * y2);
+ }
+ drawPolyline(polyline);
+ }
+
void setAntialias(boolean antiAlias);
void setTransform(float translationX, float translationY, float
magnification);
diff --git a/engine/src/main/java/org/apache/hop/core/gui/SvgGc.java
b/engine/src/main/java/org/apache/hop/core/gui/SvgGc.java
index 97993c151d..80eeb10f8d 100644
--- a/engine/src/main/java/org/apache/hop/core/gui/SvgGc.java
+++ b/engine/src/main/java/org/apache/hop/core/gui/SvgGc.java
@@ -28,6 +28,7 @@ import java.awt.Polygon;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.awt.geom.AffineTransform;
+import java.awt.geom.CubicCurve2D;
import java.awt.geom.Rectangle2D;
import java.util.Arrays;
import java.util.HashMap;
@@ -350,6 +351,21 @@ public class SvgGc implements IGc {
gc.drawLine(x + xOffset, y + yOffset, x2 + xOffset, y2 + yOffset);
}
+ @Override
+ public void drawCubicCurve(
+ double x1, double y1, double cx1, double cy1, double cx2, double cy2,
double x2, double y2) {
+ gc.draw(
+ new CubicCurve2D.Double(
+ x1 + xOffset,
+ y1 + yOffset,
+ cx1 + xOffset,
+ cy1 + yOffset,
+ cx2 + xOffset,
+ cy2 + yOffset,
+ x2 + xOffset,
+ y2 + yOffset));
+ }
+
@Override
public void drawPoint(int x, int y) {
gc.drawLine(x + xOffset, y + yOffset, x + xOffset, y + yOffset);
diff --git a/engine/src/main/java/org/apache/hop/pipeline/PipelinePainter.java
b/engine/src/main/java/org/apache/hop/pipeline/PipelinePainter.java
index 60b4e19fcf..abd6523d45 100644
--- a/engine/src/main/java/org/apache/hop/pipeline/PipelinePainter.java
+++ b/engine/src/main/java/org/apache/hop/pipeline/PipelinePainter.java
@@ -35,6 +35,7 @@ import org.apache.hop.core.gui.AreaOwner;
import org.apache.hop.core.gui.AreaOwner.AreaType;
import org.apache.hop.core.gui.BasePainter;
import org.apache.hop.core.gui.DPoint;
+import org.apache.hop.core.gui.HopPath;
import org.apache.hop.core.gui.IGc;
import org.apache.hop.core.gui.IGc.EColor;
import org.apache.hop.core.gui.IGc.EFont;
@@ -882,10 +883,7 @@ public class PipelinePainter extends
BasePainter<PipelineHopMeta, TransformMeta>
PipelineHopMeta pipelineHop,
TransformMeta fromTransform,
TransformMeta toTransform,
- int x1,
- int y1,
- int x2,
- int y2) {
+ HopPath path) {
if (!(pipeline instanceof Pipeline localPipeline)
|| localPipeline.getDebugController() == null) {
return;
@@ -935,8 +933,9 @@ public class PipelinePainter extends
BasePainter<PipelineHopMeta, TransformMeta>
int height = extent.y + padY * 2;
// The sample-data badge uses 0.30. Keep the pill further along the hop.
double pillPosition = 0.62;
- int x = (int) (x1 + pillPosition * (x2 - x1)) - width / 2;
- int y = (int) (y1 + pillPosition * (y2 - y1)) - height / 2;
+ double[] pillPoint = path.pointAt(pillPosition);
+ int x = (int) pillPoint[0] - width / 2;
+ int y = (int) pillPoint[1] - height / 2;
boolean empty = unread == 0;
int backpressure = Math.max(1, (int) (localPipeline.getRowSetSize() *
0.99));
@@ -993,10 +992,7 @@ public class PipelinePainter extends
BasePainter<PipelineHopMeta, TransformMeta>
PipelineHopMeta pipelineHop,
TransformMeta fromTransform,
TransformMeta toTransform,
- int x1,
- int y1,
- int x2,
- int y2)
+ HopPath path)
throws HopException {
if (Utils.isEmpty(outputHopRowsMap) || pipelineHop == null ||
fromTransform == null) {
return;
@@ -1009,8 +1005,9 @@ public class PipelinePainter extends
BasePainter<PipelineHopMeta, TransformMeta>
// Place at ~30% of the hop length from the source transform
double hopDataPosition = 0.30;
- int iconX = (int) (x1 + hopDataPosition * (x2 - x1)) - miniIconSize / 2;
- int iconY = (int) (y1 + hopDataPosition * (y2 - y1)) - miniIconSize / 2;
+ double[] iconPoint = path.pointAt(hopDataPosition);
+ int iconX = (int) iconPoint[0] - miniIconSize / 2;
+ int iconY = (int) iconPoint[1] - miniIconSize / 2;
gc.drawImage(EImage.DATA, iconX, iconY, magnification);
areaOwners.add(
@@ -1420,34 +1417,28 @@ public class PipelinePainter extends
BasePainter<PipelineHopMeta, TransformMeta>
throws HopException {
int mx;
int my;
- int a;
- int b;
- int dist;
double angle;
- gc.drawLine(x1, y1, x2, y2);
-
- // What's the distance between the 2 points?
- a = Math.abs(x2 - x1);
- b = Math.abs(y2 - y1);
- dist = (int) Math.sqrt(a * a + b * b);
+ HopPath path = createHopPath(x1, y1, x2, y2, startObject, endObject);
+ path.draw(gc);
// determine factor (position of arrow to left side or right side
// 0-->100%)
if (factor < 0) {
- if (dist >= 2 * iconSize) {
+ if (path.getLength() >= 2 * iconSize) {
factor = 1.3;
} else {
factor = 1.2;
}
}
- // in between 2 points
- mx = (int) (x1 + factor * (x2 - x1) / 2);
- my = (int) (y1 + factor * (y2 - y1) / 2);
+ double arrowFraction = getArrowFraction(path, factor);
+ double[] arrowPoint = path.pointAt(arrowFraction);
+ mx = (int) arrowPoint[0];
+ my = (int) arrowPoint[1];
// calculate points for arrowhead
- angle = Math.atan2(y2 - y1, x2 - x1) + (Math.PI / 2);
+ angle = path.angleAt(arrowFraction) + (Math.PI / 2);
boolean q1 = Math.toDegrees(angle) >= 0 && Math.toDegrees(angle) < 90;
boolean q2 = Math.toDegrees(angle) >= 90 && Math.toDegrees(angle) < 180;
@@ -1461,11 +1452,10 @@ public class PipelinePainter extends
BasePainter<PipelineHopMeta, TransformMeta>
}
if (startObject instanceof TransformMeta fs && endObject instanceof
TransformMeta ts) {
- factor = 0.8;
-
// in between 2 points
- mx = (int) (x1 + factor * (x2 - x1) / 2) - miniIconSize / 2;
- my = (int) (y1 + factor * (y2 - y1) / 2) - miniIconSize / 2;
+ double[] iconPoint = path.pointAt(getHopIconFraction(path));
+ mx = (int) iconPoint[0] - miniIconSize / 2;
+ my = (int) iconPoint[1] - miniIconSize / 2;
boolean errorHop =
fs.isSendingErrorRowsToTransform(ts)
@@ -1588,8 +1578,8 @@ public class PipelinePainter extends
BasePainter<PipelineHopMeta, TransformMeta>
// Data preview icon near the source transform for hop-level samples
(target hops, etc.)
//
- drawHopOutputDataIndicator(pipelineHop, fs, ts, x1, y1, x2, y2);
- drawDebugHopPill(pipelineHop, fs, ts, x1, y1, x2, y2);
+ drawHopOutputDataIndicator(pipelineHop, fs, ts, path);
+ drawDebugHopPill(pipelineHop, fs, ts, path);
}
PipelinePainterExtension extension =
diff --git a/engine/src/main/java/org/apache/hop/workflow/WorkflowPainter.java
b/engine/src/main/java/org/apache/hop/workflow/WorkflowPainter.java
index 7789ee4d10..d56cb721cb 100644
--- a/engine/src/main/java/org/apache/hop/workflow/WorkflowPainter.java
+++ b/engine/src/main/java/org/apache/hop/workflow/WorkflowPainter.java
@@ -29,6 +29,7 @@ import org.apache.hop.core.gui.AreaOwner;
import org.apache.hop.core.gui.AreaOwner.AreaType;
import org.apache.hop.core.gui.BasePainter;
import org.apache.hop.core.gui.DPoint;
+import org.apache.hop.core.gui.HopPath;
import org.apache.hop.core.gui.IGc;
import org.apache.hop.core.gui.IGc.EColor;
import org.apache.hop.core.gui.IGc.EFont;
@@ -566,34 +567,28 @@ public class WorkflowPainter extends
BasePainter<WorkflowHopMeta, ActionMeta> {
throws HopException {
int mx;
int my;
- int a;
- int b;
- int dist;
double angle;
- gc.drawLine(x1, y1, x2, y2);
-
- // What's the distance between the 2 points?
- a = Math.abs(x2 - x1);
- b = Math.abs(y2 - y1);
- dist = (int) Math.sqrt(a * a + b * b);
+ HopPath path = createHopPath(x1, y1, x2, y2, startObject, endObject);
+ path.draw(gc);
// determine factor (position of arrow to left side or right side
// 0-->100%)
if (factor < 0) {
- if (dist >= 2 * iconSize) {
+ if (path.getLength() >= 2 * iconSize) {
factor = 1.3;
} else {
factor = 1.2;
}
}
- // in between 2 points
- mx = (int) (x1 + factor * (x2 - x1) / 2);
- my = (int) (y1 + factor * (y2 - y1) / 2);
+ double arrowFraction = getArrowFraction(path, factor);
+ double[] arrowPoint = path.pointAt(arrowFraction);
+ mx = (int) arrowPoint[0];
+ my = (int) arrowPoint[1];
// calculate points for arrowhead
- angle = Math.atan2(y2 - y1, x2 - x1) + (Math.PI / 2);
+ angle = path.angleAt(arrowFraction) + (Math.PI / 2);
boolean q1 = Math.toDegrees(angle) >= 0 && Math.toDegrees(angle) < 90;
boolean q2 = Math.toDegrees(angle) >= 90 && Math.toDegrees(angle) < 180;
@@ -608,21 +603,21 @@ public class WorkflowPainter extends
BasePainter<WorkflowHopMeta, ActionMeta> {
// Display an icon above the hop...
//
- factor = 0.8;
-
- // in between 2 points
- mx = (int) (x1 + factor * (x2 - x1) / 2) - miniIconSize / 2;
- my = (int) (y1 + factor * (y2 - y1) / 2) - miniIconSize / 2;
+ double iconFraction = getHopIconFraction(path);
+ double[] iconPoint = path.pointAt(iconFraction);
+ mx = (int) iconPoint[0] - miniIconSize / 2;
+ my = (int) iconPoint[1] - miniIconSize / 2;
if (workflowHop != null) {
if (workflowHop.getFromAction().isLaunchingInParallel()) {
// in between 2 points
- mx = (int) (x1 + factor * (x2 - x1) / 2);
- my = (int) (y1 + factor * (y2 - y1) / 2);
+ mx = (int) iconPoint[0];
+ my = (int) iconPoint[1];
+ double iconAngle = path.angleAt(iconFraction) + (Math.PI / 2);
EImage image = (workflowHop.isEnabled()) ? EImage.PARALLEL :
EImage.PARALLEL_DISABLED;
- gc.drawImage(image, mx, my, magnification, angle);
+ gc.drawImage(image, mx, my, magnification, iconAngle);
areaOwners.add(
new AreaOwner(
AreaType.WORKFLOW_HOP_PARALLEL_ICON,
diff --git
a/engine/src/main/resources/org/apache/hop/core/gui/messages/messages_en_US.properties
b/engine/src/main/resources/org/apache/hop/core/gui/messages/messages_en_US.properties
index 591601afe9..b04062f90b 100644
---
a/engine/src/main/resources/org/apache/hop/core/gui/messages/messages_en_US.properties
+++
b/engine/src/main/resources/org/apache/hop/core/gui/messages/messages_en_US.properties
@@ -16,3 +16,5 @@
#
BasePainter.OutsideWorkableArea=Outside workable area
+HopLineShape.Straight=Straight
+HopLineShape.Curved=Curved
diff --git
a/engine/src/main/resources/org/apache/hop/core/gui/messages/messages_fr_FR.properties
b/engine/src/main/resources/org/apache/hop/core/gui/messages/messages_fr_FR.properties
index 1692cdb472..cf617ccb50 100644
---
a/engine/src/main/resources/org/apache/hop/core/gui/messages/messages_fr_FR.properties
+++
b/engine/src/main/resources/org/apache/hop/core/gui/messages/messages_fr_FR.properties
@@ -17,3 +17,5 @@
#
#
+HopLineShape.Straight=Droit
+HopLineShape.Curved=Arrondi
diff --git a/engine/src/test/java/org/apache/hop/core/gui/HopPathTest.java
b/engine/src/test/java/org/apache/hop/core/gui/HopPathTest.java
new file mode 100644
index 0000000000..2343b812bb
--- /dev/null
+++ b/engine/src/test/java/org/apache/hop/core/gui/HopPathTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.hop.core.gui;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
+class HopPathTest {
+
+ private static final int ICON_SIZE = 32;
+ private static final double DELTA = 0.5;
+
+ @Test
+ void straightPathKeepsCenterToCenterLine() {
+ HopPath path = HopPath.create(HopLineShape.STRAIGHT, 0, 0, 100, 0,
ICON_SIZE, true, true);
+
+ assertFalse(path.isCurved());
+ assertEquals(100, path.getLength(), DELTA);
+ assertArrayEquals(new double[] {65, 0}, path.pointAt(0.65), DELTA);
+ assertEquals(0, path.angleAt(0.5), 1e-9);
+ }
+
+ @Test
+ void curvedPathLeavesRightAndEntersLeftWhenTargetIsToTheRight() {
+ HopPath path = HopPath.create(HopLineShape.CURVED, 0, 0, 200, 60,
ICON_SIZE, true, true);
+
+ assertTrue(path.isCurved());
+ assertArrayEquals(new double[] {16, 0}, path.pointAt(0), DELTA);
+ assertArrayEquals(new double[] {184, 60}, path.pointAt(1), DELTA);
+ // Horizontal at both ends.
+ assertEquals(0, path.angleAt(0), 0.1);
+ assertEquals(0, path.angleAt(1), 0.1);
+ }
+
+ @Test
+ void curvedPathEntersFromTheTopWhenTargetIsBelow() {
+ HopPath path = HopPath.create(HopLineShape.CURVED, 0, 0, 40, 200,
ICON_SIZE, true, true);
+
+ assertArrayEquals(new double[] {0, 16}, path.pointAt(0), DELTA);
+ assertArrayEquals(new double[] {40, 184}, path.pointAt(1), DELTA);
+ assertEquals(Math.PI / 2, path.angleAt(1), 0.1);
+ }
+
+ @Test
+ void curvedPathEntersFromTheRightWhenTargetIsToTheLeft() {
+ HopPath path = HopPath.create(HopLineShape.CURVED, 200, 0, 0, 0,
ICON_SIZE, true, true);
+
+ assertArrayEquals(new double[] {184, 0}, path.pointAt(0), DELTA);
+ assertArrayEquals(new double[] {16, 0}, path.pointAt(1), DELTA);
+ }
+
+ @Test
+ void freeEndPointIsNotMovedToAnIconBorder() {
+ HopPath path = HopPath.create(HopLineShape.CURVED, 0, 0, 200, 0,
ICON_SIZE, true, false);
+
+ assertArrayEquals(new double[] {200, 0}, path.pointAt(1), DELTA);
+ }
+
+ @Test
+ void distanceToFindsPointsOnTheCurve() {
+ HopPath path = HopPath.create(HopLineShape.CURVED, 0, 0, 300, 120,
ICON_SIZE, true, true);
+ double[] middle = path.pointAt(0.5);
+
+ assertTrue(path.distanceTo(middle[0], middle[1]) < 1);
+ assertTrue(path.distanceTo(middle[0], middle[1] - 30) > 10);
+ }
+
+ @Test
+ void unknownCodeFallsBackToStraight() {
+ assertSame(HopLineShape.STRAIGHT, HopLineShape.lookupCode(null));
+ assertSame(HopLineShape.STRAIGHT, HopLineShape.lookupCode("nonsense"));
+ assertSame(HopLineShape.CURVED, HopLineShape.lookupCode("CURVED"));
+ }
+}
diff --git a/rap/src/main/java/org/apache/hop/ui/hopgui/CanvasFacadeImpl.java
b/rap/src/main/java/org/apache/hop/ui/hopgui/CanvasFacadeImpl.java
index 48a549e3d9..5df5d37dcf 100644
--- a/rap/src/main/java/org/apache/hop/ui/hopgui/CanvasFacadeImpl.java
+++ b/rap/src/main/java/org/apache/hop/ui/hopgui/CanvasFacadeImpl.java
@@ -50,6 +50,7 @@ public class CanvasFacadeImpl extends CanvasFacade {
JsonObject jsonProps = new JsonObject();
jsonProps.add("themeId", PropsUi.getInstance().isDarkMode() ? "dark" :
"light");
jsonProps.add("gridSize", PropsUi.getInstance().getCanvasGridSize());
+ jsonProps.add("hopLineShape",
PropsUi.getInstance().getHopLineShape().getCode());
jsonProps.add("showGrid", PropsUi.getInstance().isShowCanvasGridEnabled());
jsonProps.add("iconSize", PropsUi.getInstance().getIconSize());
jsonProps.add("magnification", (float) (magnification *
PropsUi.getNativeZoomFactor()));
diff --git
a/rap/src/main/java/org/apache/hop/ui/hopgui/CanvasSvgFacadeImpl.java
b/rap/src/main/java/org/apache/hop/ui/hopgui/CanvasSvgFacadeImpl.java
index 8368cea113..dccdb2d809 100644
--- a/rap/src/main/java/org/apache/hop/ui/hopgui/CanvasSvgFacadeImpl.java
+++ b/rap/src/main/java/org/apache/hop/ui/hopgui/CanvasSvgFacadeImpl.java
@@ -202,6 +202,7 @@ public class CanvasSvgFacadeImpl extends CanvasSvgFacade {
props.add("offsetY", offset.y);
props.add("iconSize", PropsUi.getInstance().getIconSize());
props.add("gridSize", PropsUi.getInstance().getCanvasGridSize());
+ props.add("hopLineShape",
PropsUi.getInstance().getHopLineShape().getCode());
props.add("showGrid", PropsUi.getInstance().isShowCanvasGridEnabled());
props.add("useDoubleClick", PropsUi.getInstance().useDoubleClick());
if (canvasSize != null) {
diff --git a/rap/src/main/resources/org/apache/hop/ui/hopgui/canvas.js
b/rap/src/main/resources/org/apache/hop/ui/hopgui/canvas.js
index bebf67a9d8..5e87df1ad6 100644
--- a/rap/src/main/resources/org/apache/hop/ui/hopgui/canvas.js
+++ b/rap/src/main/resources/org/apache/hop/ui/hopgui/canvas.js
@@ -24,6 +24,7 @@ let clicked = null;
let hopStartNode = null; // Track the start node for hop creation separately
let iconOffsetX = 0, iconOffsetY = 0; // Track where in the icon the user
clicked (like desktop client)
let offsetX, offsetY, magnification, gridSize, showGrid;
+let hopLineShape = "STRAIGHT"; // STRAIGHT or CURVED, see HopLineShape.java
let fgColor, bgColor, selectedNodeColor, nodeColor;
let canvasWidth = 0, canvasHeight = 0; // Store canvas dimensions for mouse
wheel zoom calculations
let panStartMouseX = 0, panStartMouseY = 0; // Mouse position when pan started
@@ -81,6 +82,7 @@ const handleEvent = function (event) {
magnification = props.magnification;
gridSize = props.gridSize; // Always set for snapping
showGrid = props.showGrid; // Control visibility only
+ hopLineShape = props.hopLineShape || "STRAIGHT";
const iconSize = Math.round(props.iconSize * magnification);
@@ -648,12 +650,41 @@ function drawHops(hops, gc, mode, nodes, dx, iconSize,
dy) {
toY = c.y;
}
- gc.moveTo(fromX, fromY);
- gc.lineTo(toX, toY);
+ if (hopLineShape === "CURVED") {
+ drawCurvedHop(gc, fromX, fromY, toX, toY, defaultLogicalIcon *
magnification / 2);
+ } else {
+ gc.moveTo(fromX, fromY);
+ gc.lineTo(toX, toY);
+ }
gc.stroke();
});
}
+/**
+ * Same curve as HopPath.curved() in Java: leave the source icon on the side
that faces the
+ * target, enter the target on the opposite side. Coordinates are icon centers
in screen pixels.
+ */
+function drawCurvedHop(gc, x1, y1, x2, y2, half) {
+ const dx = x2 - x1;
+ const dy = y2 - y1;
+ let dirX = 0, dirY = 0;
+ if (Math.abs(dx) >= Math.abs(dy)) {
+ dirX = dx >= 0 ? 1 : -1;
+ } else {
+ dirY = dy >= 0 ? 1 : -1;
+ }
+ const sx = x1 + dirX * half, sy = y1 + dirY * half;
+ const ex = x2 - dirX * half, ey = y2 - dirY * half;
+ const minControl = 20 * magnification;
+ const maxControl = 150 * magnification;
+ const control = Math.min(maxControl, Math.max(minControl, Math.hypot(ex -
sx, ey - sy) / 2));
+ gc.moveTo(sx, sy);
+ gc.bezierCurveTo(
+ sx + dirX * control, sy + dirY * control,
+ ex - dirX * control, ey - dirY * control,
+ ex, ey);
+}
+
function drawNodes(nodes, mode, dx, dy, gc, iconSize) {
if (!nodes) {
return;
diff --git
a/rcp/src/test/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraphCurvedHopTest.java
b/rcp/src/test/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraphCurvedHopTest.java
new file mode 100644
index 0000000000..02ba1adb6c
--- /dev/null
+++
b/rcp/src/test/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraphCurvedHopTest.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.hop.ui.hopgui.file.pipeline;
+
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.hop.core.exception.HopException;
+import org.apache.hop.core.gui.AreaOwner;
+import org.apache.hop.core.gui.HopLineShape;
+import org.apache.hop.core.gui.HopPath;
+import org.apache.hop.core.gui.Point;
+import org.apache.hop.pipeline.PipelineHopMeta;
+import org.apache.hop.pipeline.PipelineMeta;
+import org.apache.hop.pipeline.transform.BaseTransformMeta;
+import org.apache.hop.pipeline.transform.ITransform;
+import org.apache.hop.pipeline.transform.ITransformData;
+import org.apache.hop.pipeline.transform.TransformMeta;
+import org.apache.hop.ui.core.PropsUi;
+import org.apache.hop.ui.hopgui.HopGuiEnvironment;
+import org.apache.hop.ui.hopgui.file.GraphCanvasTestBase;
+import org.apache.hop.ui.hopgui.perspective.explorer.ExplorerPerspective;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Finding a hop under the mouse when hops are drawn as curves. A curved hop
does not follow the
+ * straight line between the two icon centres, so a click on the curve away
from that line must
+ * still find the hop. The click is a ctrl-click, which flips the enabled
state of the hop it finds.
+ */
+@Tag("uitest")
+class HopGuiPipelineGraphCurvedHopTest extends GraphCanvasTestBase {
+
+ private static final String SOURCE_TRANSFORM = "Source";
+ private static final String TARGET_TRANSFORM = "Target";
+ private static final Point SOURCE_LOCATION = new Point(60, 60);
+ private static final Point TARGET_LOCATION = new Point(460, 300);
+
+ /** Where on the curve the test clicks, as a fraction of its length. */
+ private static final double CLICK_FRACTION = 0.25;
+
+ /** How far the click must be from the straight line, so that only the curve
can find it. */
+ private static final double MIN_DISTANCE_FROM_STRAIGHT_LINE = 15;
+
+ @BeforeAll
+ static void registerGuiPlugins() throws HopException {
+ HopGuiEnvironment.init();
+ }
+
+ @AfterEach
+ void restoreStraightHops() {
+ onUi(() -> PropsUi.getInstance().setHopLineShape(HopLineShape.STRAIGHT));
+ }
+
+ @Test
+ void ctrlClickingACurvedHopAwayFromTheStraightLineFindsTheHop() {
+ onCanvas(
+ HopLineShape.CURVED,
+ (bot, pipelineMeta, spots) -> {
+ PipelineHopMeta hop = theHop(pipelineMeta);
+
+ String popup = ctrlClick(bot, spots);
+ assertAll(
+ "a ctrl-click on the curve should find the hop and disable it",
+ () -> assertFalse(hop.isEnabled(), "the click should have
disabled the hop"),
+ () -> assertTrue(popup == null, "no dialog may open, but got " +
popup),
+ () -> assertTrue(swallowed.isEmpty(), "the canvas threw " +
swallowed));
+ });
+ }
+
+ @Test
+ void withStraightHopsTheSamePointIsNotOnTheHop() {
+ onCanvas(
+ HopLineShape.STRAIGHT,
+ (bot, pipelineMeta, spots) -> {
+ PipelineHopMeta hop = theHop(pipelineMeta);
+
+ ctrlClick(bot, spots);
+ assertAll(
+ "a straight hop does not pass through the point on the curve",
+ () -> assertTrue(hop.isEnabled(), "the click should have missed
the hop"),
+ () -> assertTrue(swallowed.isEmpty(), "the canvas threw " +
swallowed));
+ });
+ }
+
+ private static PipelineHopMeta theHop(PipelineMeta pipelineMeta) {
+ PipelineHopMeta hop =
+ pipelineMeta.findPipelineHop(
+ pipelineMeta.findTransform(SOURCE_TRANSFORM),
+ pipelineMeta.findTransform(TARGET_TRANSFORM));
+ assertNotNull(hop, "the scene should hold the hop under test");
+ assertTrue(hop.isEnabled(), "the hop starts enabled");
+ return hop;
+ }
+
+ /** Ctrl-clicks the point on the curve and reports the title of any dialog
that opened. */
+ private String ctrlClick(SWTBot bot, Spots spots) {
+ Set<Shell> before = openShells();
+ fire(spots.canvas, SWT.MouseDown, spots.scale, spots.onCurve, 1, SWT.MOD1);
+ fireAsync(spots.canvas, SWT.MouseUp, spots.scale, spots.onCurve, 1,
SWT.MOD1 | buttonMask(1));
+ Shell popup = awaitNewShell(bot, before);
+ String title = titleOf(popup);
+ closeShell(bot, popup);
+ return title;
+ }
+
+ // ------------------------------------------------------------------ scene
+
+ /** The canvas, its scale and a point on the curved hop that is off the
straight line. */
+ private record Spots(Canvas canvas, double scale, Point onCurve) {}
+
+ @FunctionalInterface
+ private interface CanvasTest {
+ void run(SWTBot bot, PipelineMeta pipelineMeta, Spots spots);
+ }
+
+ private void onCanvas(HopLineShape shape, CanvasTest test) {
+ AtomicReference<HopGuiPipelineGraph> graphRef = new AtomicReference<>();
+ AtomicReference<PipelineMeta> metaRef = new AtomicReference<>();
+
+ withScene(
+ shell -> {
+ shell.setSize(1000, 700);
+ shell.setLayout(new FormLayout());
+ // Keep the single click on the canvas synchronous and deterministic.
+ PropsUi.getInstance().setUseDoubleClickOnCanvas(false);
+ PropsUi.getInstance().setHopLineShape(shape);
+
+ PipelineMeta pipelineMeta = buildPipeline();
+ metaRef.set(pipelineMeta);
+ graphRef.set(
+ new HopGuiPipelineGraph(
+ shell,
+ hopGui(),
+ new ExplorerPerspective(),
+ pipelineMeta,
+ new HopPipelineFileType<>()));
+ },
+ bot -> {
+ HopGuiPipelineGraph graph = graphRef.get();
+ PipelineMeta pipelineMeta = metaRef.get();
+ test.run(bot, pipelineMeta, aim(bot, graph, pipelineMeta));
+ });
+ }
+
+ /** Locates the icons and returns a point on the curved hop that is off the
straight line. */
+ private Spots aim(SWTBot bot, HopGuiPipelineGraph graph, PipelineMeta
pipelineMeta) {
+ Canvas canvas = onUi(graph::getCanvas);
+ double scale = canvasToGraphScale(graph);
+ AreaLookup lookup = graph::getVisibleAreaOwner;
+ int iconSize = onUi(() -> PropsUi.getInstance().getIconSize());
+
+ Point source =
+ awaitIcon(
+ bot,
+ lookup,
+ AreaOwner.AreaType.TRANSFORM_ICON,
+ pipelineMeta.findTransform(SOURCE_TRANSFORM),
+ SOURCE_LOCATION);
+ Point target =
+ awaitIcon(
+ bot,
+ lookup,
+ AreaOwner.AreaType.TRANSFORM_ICON,
+ pipelineMeta.findTransform(TARGET_TRANSFORM),
+ TARGET_LOCATION);
+
+ // The same curve the painter draws and the graph looks the hop up with.
+ double[] point =
+ HopPath.curved(source.x, source.y, target.x, target.y, iconSize, true,
true)
+ .pointAt(CLICK_FRACTION);
+ Point onCurve = new Point((int) Math.round(point[0]), (int)
Math.round(point[1]));
+
+ double fromStraightLine =
+ HopPath.straight(source.x, source.y, target.x,
target.y).distanceTo(onCurve.x, onCurve.y);
+ assertTrue(
+ fromStraightLine >= MIN_DISTANCE_FROM_STRAIGHT_LINE,
+ "the click must be off the straight line, but is only " +
fromStraightLine + " away");
+ // Nothing else may sit there, or the click would hit that instead of the
hop.
+ assertEmptyCanvas(lookup, onCurve);
+
+ return new Spots(canvas, scale, onCurve);
+ }
+
+ /** A single hop from the top left to the bottom right, so the curve bends
away from the line. */
+ private static PipelineMeta buildPipeline() {
+ PipelineMeta pipelineMeta = new PipelineMeta();
+ pipelineMeta.setName("curved-hop");
+
+ TransformMeta source = transform(SOURCE_TRANSFORM, SOURCE_LOCATION);
+ TransformMeta target = transform(TARGET_TRANSFORM, TARGET_LOCATION);
+ pipelineMeta.addTransform(source);
+ pipelineMeta.addTransform(target);
+ pipelineMeta.addPipelineHop(new PipelineHopMeta(source, target));
+ return pipelineMeta;
+ }
+
+ private static TransformMeta transform(String name, Point location) {
+ TransformMeta transformMeta =
+ new TransformMeta("Dummy", name, new BaseTransformMeta<ITransform,
ITransformData>());
+ transformMeta.setLocation(location.x, location.y);
+ return transformMeta;
+ }
+}
diff --git
a/rcp/src/test/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraphCurvedHopTest.java
b/rcp/src/test/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraphCurvedHopTest.java
new file mode 100644
index 0000000000..3b53fd270e
--- /dev/null
+++
b/rcp/src/test/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraphCurvedHopTest.java
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.hop.ui.hopgui.file.workflow;
+
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.hop.core.Result;
+import org.apache.hop.core.exception.HopException;
+import org.apache.hop.core.gui.AreaOwner;
+import org.apache.hop.core.gui.HopLineShape;
+import org.apache.hop.core.gui.HopPath;
+import org.apache.hop.core.gui.Point;
+import org.apache.hop.ui.core.PropsUi;
+import org.apache.hop.ui.hopgui.HopGuiEnvironment;
+import org.apache.hop.ui.hopgui.file.GraphCanvasTestBase;
+import org.apache.hop.ui.hopgui.perspective.explorer.ExplorerPerspective;
+import org.apache.hop.workflow.WorkflowHopMeta;
+import org.apache.hop.workflow.WorkflowMeta;
+import org.apache.hop.workflow.action.ActionBase;
+import org.apache.hop.workflow.action.ActionMeta;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Finding a hop under the mouse when hops are drawn as curves. A curved hop
does not follow the
+ * straight line between the two icon centres, so a click on the curve away
from that line must
+ * still find the hop. The click is a ctrl-click, which flips the enabled
state of the hop it finds.
+ */
+@Tag("uitest")
+class HopGuiWorkflowGraphCurvedHopTest extends GraphCanvasTestBase {
+
+ private static final String SOURCE_ACTION = "Source";
+ private static final String TARGET_ACTION = "Target";
+ private static final Point SOURCE_LOCATION = new Point(60, 60);
+ private static final Point TARGET_LOCATION = new Point(460, 300);
+
+ /** Where on the curve the test clicks, as a fraction of its length. */
+ private static final double CLICK_FRACTION = 0.25;
+
+ /** How far the click must be from the straight line, so that only the curve
can find it. */
+ private static final double MIN_DISTANCE_FROM_STRAIGHT_LINE = 15;
+
+ @BeforeAll
+ static void registerGuiPlugins() throws HopException {
+ HopGuiEnvironment.init();
+ }
+
+ @AfterEach
+ void restoreStraightHops() {
+ onUi(() -> PropsUi.getInstance().setHopLineShape(HopLineShape.STRAIGHT));
+ }
+
+ @Test
+ void ctrlClickingACurvedHopAwayFromTheStraightLineFindsTheHop() {
+ onCanvas(
+ HopLineShape.CURVED,
+ (bot, workflowMeta, spots) -> {
+ WorkflowHopMeta hop = theHop(workflowMeta);
+
+ String popup = ctrlClick(bot, spots);
+ assertAll(
+ "a ctrl-click on the curve should find the hop and disable it",
+ () -> assertFalse(hop.isEnabled(), "the click should have
disabled the hop"),
+ () -> assertTrue(popup == null, "no dialog may open, but got " +
popup),
+ () -> assertTrue(swallowed.isEmpty(), "the canvas threw " +
swallowed));
+ });
+ }
+
+ @Test
+ void withStraightHopsTheSamePointIsNotOnTheHop() {
+ onCanvas(
+ HopLineShape.STRAIGHT,
+ (bot, workflowMeta, spots) -> {
+ WorkflowHopMeta hop = theHop(workflowMeta);
+
+ ctrlClick(bot, spots);
+ assertAll(
+ "a straight hop does not pass through the point on the curve",
+ () -> assertTrue(hop.isEnabled(), "the click should have missed
the hop"),
+ () -> assertTrue(swallowed.isEmpty(), "the canvas threw " +
swallowed));
+ });
+ }
+
+ private static WorkflowHopMeta theHop(WorkflowMeta workflowMeta) {
+ WorkflowHopMeta hop =
+ workflowMeta.findWorkflowHop(
+ workflowMeta.findAction(SOURCE_ACTION),
workflowMeta.findAction(TARGET_ACTION));
+ assertNotNull(hop, "the scene should hold the hop under test");
+ assertTrue(hop.isEnabled(), "the hop starts enabled");
+ return hop;
+ }
+
+ /** Ctrl-clicks the point on the curve and reports the title of any dialog
that opened. */
+ private String ctrlClick(SWTBot bot, Spots spots) {
+ Set<Shell> before = openShells();
+ fire(spots.canvas, SWT.MouseDown, spots.scale, spots.onCurve, 1, SWT.MOD1);
+ fireAsync(spots.canvas, SWT.MouseUp, spots.scale, spots.onCurve, 1,
SWT.MOD1 | buttonMask(1));
+ Shell popup = awaitNewShell(bot, before);
+ String title = titleOf(popup);
+ closeShell(bot, popup);
+ return title;
+ }
+
+ // ------------------------------------------------------------------ scene
+
+ /** The canvas, its scale and a point on the curved hop that is off the
straight line. */
+ private record Spots(Canvas canvas, double scale, Point onCurve) {}
+
+ @FunctionalInterface
+ private interface CanvasTest {
+ void run(SWTBot bot, WorkflowMeta workflowMeta, Spots spots);
+ }
+
+ private void onCanvas(HopLineShape shape, CanvasTest test) {
+ AtomicReference<HopGuiWorkflowGraph> graphRef = new AtomicReference<>();
+ AtomicReference<WorkflowMeta> metaRef = new AtomicReference<>();
+
+ withScene(
+ shell -> {
+ shell.setSize(1000, 700);
+ // The workflow graph gives itself GridData, so its parent lays out
with a GridLayout.
+ shell.setLayout(new GridLayout(1, false));
+ // Keep the single click on the canvas synchronous and deterministic.
+ PropsUi.getInstance().setUseDoubleClickOnCanvas(false);
+ PropsUi.getInstance().setHopLineShape(shape);
+
+ WorkflowMeta workflowMeta = buildWorkflow();
+ metaRef.set(workflowMeta);
+ graphRef.set(
+ new HopGuiWorkflowGraph(
+ shell,
+ hopGui(),
+ new ExplorerPerspective(),
+ workflowMeta,
+ new HopWorkflowFileType<>()));
+ },
+ bot -> {
+ HopGuiWorkflowGraph graph = graphRef.get();
+ WorkflowMeta workflowMeta = metaRef.get();
+ test.run(bot, workflowMeta, aim(bot, graph, workflowMeta));
+ });
+ }
+
+ /** Locates the icons and returns a point on the curved hop that is off the
straight line. */
+ private Spots aim(SWTBot bot, HopGuiWorkflowGraph graph, WorkflowMeta
workflowMeta) {
+ Canvas canvas = onUi(graph::getCanvas);
+ double scale = canvasToGraphScale(graph);
+ AreaLookup lookup = graph::getVisibleAreaOwner;
+ int iconSize = onUi(() -> PropsUi.getInstance().getIconSize());
+
+ Point source =
+ awaitIcon(
+ bot,
+ lookup,
+ AreaOwner.AreaType.ACTION_ICON,
+ workflowMeta.findAction(SOURCE_ACTION),
+ SOURCE_LOCATION);
+ Point target =
+ awaitIcon(
+ bot,
+ lookup,
+ AreaOwner.AreaType.ACTION_ICON,
+ workflowMeta.findAction(TARGET_ACTION),
+ TARGET_LOCATION);
+
+ // The same curve the painter draws and the graph looks the hop up with.
+ double[] point =
+ HopPath.curved(source.x, source.y, target.x, target.y, iconSize, true,
true)
+ .pointAt(CLICK_FRACTION);
+ Point onCurve = new Point((int) Math.round(point[0]), (int)
Math.round(point[1]));
+
+ double fromStraightLine =
+ HopPath.straight(source.x, source.y, target.x,
target.y).distanceTo(onCurve.x, onCurve.y);
+ assertTrue(
+ fromStraightLine >= MIN_DISTANCE_FROM_STRAIGHT_LINE,
+ "the click must be off the straight line, but is only " +
fromStraightLine + " away");
+ // Nothing else may sit there, or the click would hit that instead of the
hop.
+ assertEmptyCanvas(lookup, onCurve);
+
+ return new Spots(canvas, scale, onCurve);
+ }
+
+ /** A single hop from the top left to the bottom right, so the curve bends
away from the line. */
+ private static WorkflowMeta buildWorkflow() {
+ WorkflowMeta workflowMeta = new WorkflowMeta();
+ workflowMeta.setName("curved-hop");
+
+ ActionMeta source = action(SOURCE_ACTION, SOURCE_LOCATION);
+ ActionMeta target = action(TARGET_ACTION, TARGET_LOCATION);
+ workflowMeta.addAction(source);
+ workflowMeta.addAction(target);
+ workflowMeta.addWorkflowHop(new WorkflowHopMeta(source, target));
+ return workflowMeta;
+ }
+
+ private static ActionMeta action(String name, Point location) {
+ ActionMeta actionMeta = new ActionMeta(new TestAction(name));
+ actionMeta.setLocation(location.x, location.y);
+ return actionMeta;
+ }
+
+ /** The smallest possible action: the canvas only needs a name, a location
and an icon slot. */
+ private static class TestAction extends ActionBase {
+ TestAction(String name) {
+ super(name, "");
+ }
+
+ @Override
+ public Result execute(Result prevResult, int nr) {
+ return prevResult;
+ }
+
+ @Override
+ public Object clone() {
+ return new TestAction(getName());
+ }
+ }
+}
diff --git a/ui/src/main/java/org/apache/hop/ui/core/PropsUi.java
b/ui/src/main/java/org/apache/hop/ui/core/PropsUi.java
index 18b19c69b9..f019101edb 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/PropsUi.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/PropsUi.java
@@ -22,6 +22,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.hop.core.Const;
import org.apache.hop.core.Props;
+import org.apache.hop.core.gui.HopLineShape;
import org.apache.hop.core.gui.IGuiPosition;
import org.apache.hop.core.gui.IGuiSize;
import org.apache.hop.core.gui.Point;
@@ -1337,6 +1338,15 @@ public class PropsUi extends Props {
setProperty(AUTO_LAYOUT_DIRECTION, direction);
}
+ /** How hops are drawn on the pipeline and workflow canvas. Defaults to
straight lines. */
+ public HopLineShape getHopLineShape() {
+ return HopLineShape.lookupCode(getProperty(HopLineShape.GUI_PROPERTY_KEY));
+ }
+
+ public void setHopLineShape(HopLineShape shape) {
+ setProperty(HopLineShape.GUI_PROPERTY_KEY, shape.getCode());
+ }
+
/** Auto-layout distance between consecutive layers, along the flow
direction. */
public int getAutoLayoutLayerSpacing() {
return Const.toInt(
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
index a2b58456c2..adeab15e1f 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
@@ -61,6 +61,8 @@ import org.apache.hop.core.gui.AreaOwner.AreaType;
import org.apache.hop.core.gui.BasePainter;
import org.apache.hop.core.gui.CanvasSvgRenderResult;
import org.apache.hop.core.gui.DPoint;
+import org.apache.hop.core.gui.HopLineShape;
+import org.apache.hop.core.gui.HopPath;
import org.apache.hop.core.gui.IGc;
import org.apache.hop.core.gui.IRedrawable;
import org.apache.hop.core.gui.IUndo;
@@ -5585,6 +5587,10 @@ public class HopGuiPipelineGraph extends
HopGuiAbstractGraph
}
private boolean pointOnLine(int x, int y, int[] line) {
+ if (HopLineShape.getConfigured() == HopLineShape.CURVED) {
+ HopPath path = HopPath.curved(line[0], line[1], line[2], line[3],
iconSize, true, true);
+ return path.distanceTo(x, y) <= HOP_SEL_MARGIN / 2.0 + 1;
+ }
int dx;
int dy;
int pm = HOP_SEL_MARGIN / 2;
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
index d71c15d73e..ea9d78ed52 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
@@ -54,6 +54,8 @@ import org.apache.hop.core.file.IHasFilename;
import org.apache.hop.core.gui.AreaOwner;
import org.apache.hop.core.gui.CanvasSvgRenderResult;
import org.apache.hop.core.gui.DPoint;
+import org.apache.hop.core.gui.HopLineShape;
+import org.apache.hop.core.gui.HopPath;
import org.apache.hop.core.gui.IGc;
import org.apache.hop.core.gui.IRedrawable;
import org.apache.hop.core.gui.IUndo;
@@ -4528,6 +4530,10 @@ public class HopGuiWorkflowGraph extends
HopGuiAbstractGraph
}
protected boolean pointOnLine(int x, int y, int[] line) {
+ if (HopLineShape.getConfigured() == HopLineShape.CURVED) {
+ HopPath path = HopPath.curved(line[0], line[1], line[2], line[3],
iconSize, true, true);
+ return path.distanceTo(x, y) <= HOP_SEL_MARGIN / 2.0 + 1;
+ }
int dx;
int dy;
int pm = HOP_SEL_MARGIN / 2;
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/configuration/tabs/ConfigGuiOptionsTab.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/configuration/tabs/ConfigGuiOptionsTab.java
index ea106ad54e..60073a0ada 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/configuration/tabs/ConfigGuiOptionsTab.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/configuration/tabs/ConfigGuiOptionsTab.java
@@ -24,6 +24,7 @@ import java.util.function.Consumer;
import org.apache.hop.core.Const;
import org.apache.hop.core.Props;
import org.apache.hop.core.config.HopConfig;
+import org.apache.hop.core.gui.HopLineShape;
import org.apache.hop.core.gui.plugin.GuiPlugin;
import org.apache.hop.core.gui.plugin.tab.GuiTab;
import org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement;
@@ -97,6 +98,7 @@ public class ConfigGuiOptionsTab {
private Text wIconSize;
private Text wLineWidth;
+ private Combo wHopLineShape;
private Text wMiddlePct;
private Combo wGlobalZoom;
private Text wGridSize;
@@ -191,6 +193,7 @@ public class ConfigGuiOptionsTab {
// Reload text fields and checkboxes
wIconSize.setText(Integer.toString(props.getIconSize()));
wLineWidth.setText(Integer.toString(props.getLineWidth()));
+ wHopLineShape.setText(props.getHopLineShape().getDescription());
wMiddlePct.setText(Integer.toString(props.getMiddlePct()));
wGridSize.setText(Integer.toString(props.getCanvasGridSize()));
wShowCanvasGrid.setSelection(props.isShowCanvasGridEnabled());
@@ -471,6 +474,19 @@ public class ConfigGuiOptionsTab {
});
lastAppearanceControl = wLineWidth;
+ // Hop line shape: straight or curved
+ Control[] hopLineShapeControls =
+ createComboField(
+ appearanceContent,
+ "EnterOptionsDialog.HopLineShape.Label",
+ "EnterOptionsDialog.HopLineShape.ToolTip",
+ HopLineShape.getDescriptions(),
+ lastAppearanceControl,
+ margin);
+ wHopLineShape = (Combo) hopLineShapeControls[1];
+ wHopLineShape.setText(props.getHopLineShape().getDescription());
+ lastAppearanceControl = wHopLineShape;
+
// Dialog middle percentage
Control[] middlePctControls =
createTextField(
@@ -1341,6 +1357,7 @@ public class ConfigGuiOptionsTab {
props.setGraphFont(graphFontData);
props.setIconSize(Const.toInt(wIconSize.getText(), props.getIconSize()));
props.setLineWidth(Const.toInt(wLineWidth.getText(),
props.getLineWidth()));
+
props.setHopLineShape(HopLineShape.lookupDescription(wHopLineShape.getText()));
props.setMiddlePct(Const.toInt(wMiddlePct.getText(),
props.getMiddlePct()));
props.setCanvasGridSize(Const.toInt(wGridSize.getText(), 1));
int directionIndex = wAutoLayoutDirection.getSelectionIndex();
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/shared/SwtGc.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/shared/SwtGc.java
index a4a6822ad9..d142b35c5c 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/shared/SwtGc.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/shared/SwtGc.java
@@ -42,6 +42,7 @@ import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.LineAttributes;
+import org.eclipse.swt.graphics.Path;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Transform;
@@ -261,6 +262,19 @@ public class SwtGc implements IGc {
gc.drawPolyline(polyline);
}
+ @Override
+ public void drawCubicCurve(
+ double x1, double y1, double cx1, double cy1, double cx2, double cy2,
double x2, double y2) {
+ Path path = new Path(gc.getDevice());
+ try {
+ path.moveTo((float) x1, (float) y1);
+ path.cubicTo((float) cx1, (float) cy1, (float) cx2, (float) cy2, (float)
x2, (float) y2);
+ gc.drawPath(path);
+ } finally {
+ path.dispose();
+ }
+ }
+
@Override
public void drawRectangle(int x, int y, int width, int height) {
gc.drawRectangle(x, y, width, height);
diff --git
a/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
b/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
index 8a7ea0039e..f0f47b1a73 100644
---
a/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
+++
b/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_en_US.properties
@@ -186,6 +186,8 @@ EnterOptionsDialog.HideMenuBar.Label=Hide the menu bar
EnterOptionsDialog.HideMenuBar.ToolTip=Enabling this option hides the menu bar
from the user interface.
EnterOptionsDialog.IconSize.Label=Icon size in workspace:
EnterOptionsDialog.LineWidth.Label=Line width on workspace:
+EnterOptionsDialog.HopLineShape.Label=Hop line shape:
+EnterOptionsDialog.HopLineShape.ToolTip=Straight draws hops from icon center
to icon center. Curved draws a smooth curve that leaves and enters each icon on
the side facing the other icon.
EnterOptionsDialog.LookAndFeel.Label=Look & Feel
EnterOptionsDialog.KeyboardShortuts=Keyboard Shortcuts
EnterOptionsDialog.MaxExecutionLoggingTextSizeSize.Label=Maximum execution
logging text size:
diff --git
a/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_fr_FR.properties
b/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_fr_FR.properties
index 205f8d7f5e..50959984bd 100644
---
a/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_fr_FR.properties
+++
b/ui/src/main/resources/org/apache/hop/ui/core/dialog/messages/messages_fr_FR.properties
@@ -93,6 +93,8 @@ EnterOptionsDialog.HideMenuBar.Label=Masquer la barre de menu
EnterOptionsDialog.HideMenuBar.ToolTip=L''activation de cette option permet de
masquer la barre de menu de l''interface utilisateur.
EnterOptionsDialog.IconSize.Label=Taille des ic\u00F4nes:
EnterOptionsDialog.LineWidth.Label=Epaisseur des liens
+EnterOptionsDialog.HopLineShape.Label=Forme des liens
+EnterOptionsDialog.HopLineShape.ToolTip=Droit trace les liens d\u2019un centre
d\u2019ic\u00F4ne \u00E0 l\u2019autre. Arrondi trace une courbe qui sort et
entre dans chaque ic\u00F4ne par le c\u00F4t\u00E9 qui fait face \u00E0
l\u2019autre ic\u00F4ne.
EnterOptionsDialog.LookAndFeel.Label=Apparence
EnterOptionsDialog.ExpandAll.Tooltip=D\u00E9velopper toutes les sections
EnterOptionsDialog.CollapseAll.Tooltip=R\u00E9duire toutes les sections