You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/05/27 21:00:18 UTC
(camel) 06/08: CAMEL-23631: Highlight last node box in red for FAIL mode
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch CAMEL-23631-route-diagram-highlight-error-path
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 11c035a91ebc6f33a162774c7b5aaa204ee0c599
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed May 27 22:34:01 2026 +0200
CAMEL-23631: Highlight last node box in red for FAIL mode
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
.../camel/diagram/RouteDiagramAsciiRenderer.java | 23 ++++++++++++++++++++++
.../apache/camel/diagram/RouteDiagramRenderer.java | 23 ++++++++++++++++++----
2 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramAsciiRenderer.java b/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramAsciiRenderer.java
index a09e23bb7e4c..654c166a7114 100644
--- a/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramAsciiRenderer.java
+++ b/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramAsciiRenderer.java
@@ -180,6 +180,16 @@ public class RouteDiagramAsciiRenderer {
}
drawText(grid, labelRow, toCol(PADDING), label);
+ // find the last highlighted node (for FAIL mode box highlighting)
+ LayoutNode lastHighlightedNode = null;
+ if (highlightedNodeIds != null && highlightStyle == RouteDiagramHelper.HighlightStyle.FAIL) {
+ for (LayoutNode ln : lr.nodes) {
+ if (isHighlighted(ln, highlightedNodeIds)) {
+ lastHighlightedNode = ln;
+ }
+ }
+ }
+
for (LayoutNode ln : lr.nodes) {
if (ln.treeNode != null && RouteDiagramLayoutEngine.hasScope(ln.treeNode)) {
drawScopeBox(grid, ln);
@@ -201,6 +211,19 @@ public class RouteDiagramAsciiRenderer {
for (LayoutNode ln : lr.nodes) {
drawNode(grid, ln);
+ if (ln == lastHighlightedNode) {
+ recordNodeHighlight(grid, ln);
+ }
+ }
+ }
+
+ private void recordNodeHighlight(char[][] grid, LayoutNode node) {
+ int col = toCol(node.x);
+ int row = toRow(node.y);
+ int height = 2 + rewrapText(node, boxWidth - 4).size();
+ // highlight the entire box (top border, sides, bottom border)
+ for (int r = row; r < row + height && r < grid.length; r++) {
+ counterPositions.add(new CounterPos(r, col, boxWidth, CounterType.HIGHLIGHT_FAIL));
}
}
diff --git a/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramRenderer.java b/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramRenderer.java
index 789d04a5b314..d874e8f92bc7 100644
--- a/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramRenderer.java
+++ b/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramRenderer.java
@@ -323,8 +323,18 @@ public class RouteDiagramRenderer {
}
}
+ // find the last highlighted node (for FAIL mode box highlighting)
+ LayoutNode lastHighlightedNode = null;
+ if (highlightedNodeIds != null && highlightStyle == RouteDiagramHelper.HighlightStyle.FAIL) {
+ for (LayoutNode ln : lr.nodes) {
+ if (isHighlighted(ln, highlightedNodeIds)) {
+ lastHighlightedNode = ln;
+ }
+ }
+ }
+
for (LayoutNode ln : lr.nodes) {
- drawNode(g, ln, colors);
+ drawNode(g, ln, colors, ln == lastHighlightedNode);
}
}
@@ -417,14 +427,19 @@ public class RouteDiagramRenderer {
drawArrowFromMerge(g, to, colors, false, null);
}
- private void drawNode(Graphics2D g, LayoutNode node, DiagramColors colors) {
+ private void drawNode(Graphics2D g, LayoutNode node, DiagramColors colors, boolean highlightFail) {
Color color = getNodeColor(node.type, colors);
g.setColor(color);
g.fillRoundRect(node.x, node.y, nodeWidth, node.height, ARC, ARC);
- g.setColor(color.brighter());
- g.setStroke(new BasicStroke(BORDER_STROKE_WIDTH));
+ if (highlightFail) {
+ g.setColor(HIGHLIGHT_FAIL_COLOR);
+ g.setStroke(new BasicStroke(HIGHLIGHT_STROKE_WIDTH));
+ } else {
+ g.setColor(color.brighter());
+ g.setStroke(new BasicStroke(BORDER_STROKE_WIDTH));
+ }
g.drawRoundRect(node.x, node.y, nodeWidth, node.height, ARC, ARC);
g.setColor(colors.getText());