fix: order DO_TRY sections as try-body, finally, catch and reduce spacing
ELK TB layout places children in insertion order. Now explicitly adds DO_FINALLY before DO_CATCH so the visual order inside DO_TRY is: try body (top) → finally → catch blocks (bottom). Also reduces internal spacing to keep the compound more compact. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -549,8 +549,8 @@ public class ElkDiagramRenderer implements DiagramRenderer {
|
|||||||
elkNode.setHeight(100);
|
elkNode.setHeight(100);
|
||||||
elkNode.setProperty(CoreOptions.ALGORITHM, "org.eclipse.elk.layered");
|
elkNode.setProperty(CoreOptions.ALGORITHM, "org.eclipse.elk.layered");
|
||||||
elkNode.setProperty(CoreOptions.DIRECTION, Direction.DOWN);
|
elkNode.setProperty(CoreOptions.DIRECTION, Direction.DOWN);
|
||||||
elkNode.setProperty(CoreOptions.SPACING_NODE_NODE, NODE_SPACING * 0.6);
|
elkNode.setProperty(CoreOptions.SPACING_NODE_NODE, NODE_SPACING * 0.4);
|
||||||
elkNode.setProperty(CoreOptions.SPACING_EDGE_NODE, EDGE_SPACING * 0.5);
|
elkNode.setProperty(CoreOptions.SPACING_EDGE_NODE, EDGE_SPACING * 0.3);
|
||||||
elkNode.setProperty(CoreOptions.PADDING,
|
elkNode.setProperty(CoreOptions.PADDING,
|
||||||
new org.eclipse.elk.core.math.ElkPadding(COMPOUND_TOP_PADDING,
|
new org.eclipse.elk.core.math.ElkPadding(COMPOUND_TOP_PADDING,
|
||||||
COMPOUND_SIDE_PADDING, COMPOUND_SIDE_PADDING, COMPOUND_SIDE_PADDING));
|
COMPOUND_SIDE_PADDING, COMPOUND_SIDE_PADDING, COMPOUND_SIDE_PADDING));
|
||||||
@@ -590,12 +590,22 @@ public class ElkDiagramRenderer implements DiagramRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler children are direct children of DO_TRY (stacked below)
|
// Handler children stacked below try body: DO_FINALLY first, then DO_CATCH
|
||||||
|
// (ELK TB layout places children in insertion order)
|
||||||
for (RouteNode child : handlerChildren) {
|
for (RouteNode child : handlerChildren) {
|
||||||
|
if (child.getType() == NodeType.DO_FINALLY) {
|
||||||
childNodeIds.add(child.getId());
|
childNodeIds.add(child.getId());
|
||||||
createElkNodeRecursive(child, elkNode, factory, elkNodeMap, nodeColors,
|
createElkNodeRecursive(child, elkNode, factory, elkNodeMap, nodeColors,
|
||||||
compoundNodeIds, childNodeIds, doTryNodeIds);
|
compoundNodeIds, childNodeIds, doTryNodeIds);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
for (RouteNode child : handlerChildren) {
|
||||||
|
if (child.getType() == NodeType.DO_CATCH) {
|
||||||
|
childNodeIds.add(child.getId());
|
||||||
|
createElkNodeRecursive(child, elkNode, factory, elkNodeMap, nodeColors,
|
||||||
|
compoundNodeIds, childNodeIds, doTryNodeIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (isCompound) {
|
} else if (isCompound) {
|
||||||
compoundNodeIds.add(rn.getId());
|
compoundNodeIds.add(rn.getId());
|
||||||
elkNode.setWidth(200);
|
elkNode.setWidth(200);
|
||||||
@@ -661,9 +671,18 @@ public class ElkDiagramRenderer implements DiagramRenderer {
|
|||||||
wrapperChildren));
|
wrapperChildren));
|
||||||
compoundInfos.put(wrapperId, new CompoundInfo(wrapperId, Color.WHITE));
|
compoundInfos.put(wrapperId, new CompoundInfo(wrapperId, Color.WHITE));
|
||||||
}
|
}
|
||||||
// Handler children (DO_CATCH, DO_FINALLY)
|
// Handler children: DO_FINALLY first, then DO_CATCH
|
||||||
for (RouteNode child : rn.getChildren()) {
|
for (RouteNode child : rn.getChildren()) {
|
||||||
if (child.getType() == NodeType.DO_CATCH || child.getType() == NodeType.DO_FINALLY) {
|
if (child.getType() == NodeType.DO_FINALLY) {
|
||||||
|
ElkNode childElk = elkNodeMap.get(child.getId());
|
||||||
|
if (childElk != null) {
|
||||||
|
children.add(extractPositionedNode(child, childElk, elkNodeMap,
|
||||||
|
compoundNodeIds, compoundInfos, rootNode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (RouteNode child : rn.getChildren()) {
|
||||||
|
if (child.getType() == NodeType.DO_CATCH) {
|
||||||
ElkNode childElk = elkNodeMap.get(child.getId());
|
ElkNode childElk = elkNodeMap.get(child.getId());
|
||||||
if (childElk != null) {
|
if (childElk != null) {
|
||||||
children.add(extractPositionedNode(child, childElk, elkNodeMap,
|
children.add(extractPositionedNode(child, childElk, elkNodeMap,
|
||||||
|
|||||||
Reference in New Issue
Block a user