fix: left-align DO_TRY sections and shrink container to fit content
- Left-align all sections (try_body, doFinally, doCatch) within DO_TRY - Shrink DO_TRY height to match actual content, removing bottom padding Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -326,6 +326,7 @@ public class ElkDiagramRenderer implements DiagramRenderer {
|
||||
*/
|
||||
private void postProcessDoTrySections(LayoutContext ctx) {
|
||||
for (Map.Entry<String, List<String>> entry : ctx.doTrySectionOrder.entrySet()) {
|
||||
String doTryId = entry.getKey();
|
||||
List<String> orderedIds = entry.getValue();
|
||||
List<ElkNode> sections = new ArrayList<>();
|
||||
for (String id : orderedIds) {
|
||||
@@ -334,18 +335,29 @@ public class ElkDiagramRenderer implements DiagramRenderer {
|
||||
}
|
||||
if (sections.size() < 2) continue;
|
||||
|
||||
// Left-align all sections and stack vertically
|
||||
double startY = sections.stream().mapToDouble(ElkNode::getY).min().orElse(0);
|
||||
double spacing = 20;
|
||||
double currentY = startY;
|
||||
for (ElkNode section : sections) {
|
||||
section.setX(COMPOUND_SIDE_PADDING);
|
||||
section.setY(currentY);
|
||||
currentY += section.getHeight() + spacing;
|
||||
}
|
||||
|
||||
// Uniform width
|
||||
double maxWidth = sections.stream().mapToDouble(ElkNode::getWidth).max().orElse(0);
|
||||
for (ElkNode section : sections) {
|
||||
section.setWidth(maxWidth);
|
||||
}
|
||||
|
||||
// Shrink DO_TRY parent height to fit its content
|
||||
ElkNode doTryNode = ctx.elkNodeMap.get(doTryId);
|
||||
if (doTryNode != null) {
|
||||
double contentBottom = currentY - spacing + COMPOUND_SIDE_PADDING;
|
||||
doTryNode.setHeight(contentBottom);
|
||||
doTryNode.setWidth(maxWidth + 2 * COMPOUND_SIDE_PADDING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user