Skip to content

Commit

Permalink
Fix layout algorithms in AbstractElbowLineConnectionWithMarkersFigure…
Browse files Browse the repository at this point in the history
… and AbstractPathConnectionWithMarkersFigure.
  • Loading branch information
wrandelshofer committed Sep 29, 2024
1 parent 7219487 commit ee40e95
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,35 +236,33 @@ public PathIterator getPathIterator(RenderContext ctx, @Nullable AffineTransform

@Override
public void layout(RenderContext ctx) {
// Get start and end points
Point2D start = getNonNull(START).getConvertedValue();
Point2D end = getNonNull(END).getConvertedValue();

// If the figure is connected at its start and/or end, move the start and/or end points
Connector startConnector = get(START_CONNECTOR);
Connector endConnector = get(END_CONNECTOR);
Figure startTarget = get(START_TARGET);
Figure endTarget = get(END_TARGET);


ObservableList<Double> points = path.getPoints();
points.clear();

// Find initial start and end points
Point2D startDerivative = null;
Point2D endDerivative = null;
Point2D initialStart = start;
Point2D initalEnd = end;
if (startConnector != null && startTarget != null) {
start = startConnector.getPointAndDerivativeInWorld(this, startTarget).getPoint(Point2D::new);
initialStart = startConnector.getPointAndDerivativeInWorld(this, startTarget).getPoint(Point2D::new);
}
if (endConnector != null && endTarget != null) {
end = endConnector.getPointAndDerivativeInWorld(this, endTarget).getPoint(Point2D::new);
initalEnd = endConnector.getPointAndDerivativeInWorld(this, endTarget).getPoint(Point2D::new);
}
// Chop start and end points
Point2D startDerivative = null;
if (startConnector != null && startTarget != null) {
IntersectionPointEx intersectionPointEx = startConnector.chopStart(ctx, this, startTarget, start, end);
IntersectionPointEx intersectionPointEx = startConnector.chopStart(ctx, this, startTarget, initialStart, initalEnd);
startDerivative = new Point2D(intersectionPointEx.getDerivativeB().getX(), intersectionPointEx.getDerivativeB().getY());
start = worldToParent(intersectionPointEx.getX(), intersectionPointEx.getY());
set(START, new CssPoint2D(start));
}
Point2D endDerivative = null;
if (endConnector != null && endTarget != null) {
IntersectionPointEx intersectionPointEx = endConnector.chopStart(ctx, this, endTarget, end, start);
IntersectionPointEx intersectionPointEx = endConnector.chopStart(ctx, this, endTarget, initalEnd, initialStart);
endDerivative = new Point2D(intersectionPointEx.getDerivativeB().getX(), intersectionPointEx.getDerivativeB().getY());
end = worldToParent(intersectionPointEx.getX(), intersectionPointEx.getY());
set(END, new CssPoint2D(end));
Expand All @@ -277,7 +275,9 @@ public void layout(RenderContext ctx) {
endDerivative = lineDerivative.multiply(-1);
}


// Layout the elbow line
ObservableList<Double> points = path.getPoints();
points.clear();
points.add(start.getX());
points.add(start.getY());
if (start.getX() == end.getX() || start.getY() == end.getY()) {
Expand Down

0 comments on commit ee40e95

Please sign in to comment.