feat(02-02): add ELK/JFreeSVG dependencies and core diagram rendering interfaces

- Add Eclipse ELK core + layered algorithm and JFreeSVG dependencies to app module
- Create DiagramRenderer interface in core with renderSvg and layoutJson methods
- Create DiagramLayout, PositionedNode, PositionedEdge records for layout data

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-03-11 16:04:32 +01:00
parent b56eff0b94
commit 6df74505be
5 changed files with 113 additions and 0 deletions

View File

@@ -46,6 +46,21 @@
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.8.6</version> <version>2.8.6</version>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.elk</groupId>
<artifactId>org.eclipse.elk.core</artifactId>
<version>0.11.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.elk</groupId>
<artifactId>org.eclipse.elk.alg.layered</artifactId>
<version>0.11.0</version>
</dependency>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>org.jfree.svg</artifactId>
<version>5.0.7</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>

View File

@@ -0,0 +1,21 @@
package com.cameleer3.server.core.diagram;
import java.util.List;
/**
* Complete diagram layout with positioned nodes and edges.
* <p>
* This is the JSON response format for the layout endpoint.
*
* @param width total diagram width
* @param height total diagram height
* @param nodes positioned nodes with coordinates
* @param edges positioned edges with waypoints
*/
public record DiagramLayout(
double width,
double height,
List<PositionedNode> nodes,
List<PositionedEdge> edges
) {
}

View File

@@ -0,0 +1,28 @@
package com.cameleer3.server.core.diagram;
import com.cameleer3.common.graph.RouteGraph;
/**
* Renders route diagrams from {@link RouteGraph} definitions.
* <p>
* Implementations produce either SVG documents for direct display or
* JSON-serializable layout data for client-side rendering.
*/
public interface DiagramRenderer {
/**
* Render the route graph as an SVG XML document.
*
* @param graph the route graph definition
* @return SVG XML string
*/
String renderSvg(RouteGraph graph);
/**
* Compute the diagram layout with positioned nodes and edges.
*
* @param graph the route graph definition
* @return layout data suitable for JSON serialization
*/
DiagramLayout layoutJson(RouteGraph graph);
}

View File

@@ -0,0 +1,19 @@
package com.cameleer3.server.core.diagram;
import java.util.List;
/**
* An edge with computed waypoints for rendering.
*
* @param sourceId source node identifier
* @param targetId target node identifier
* @param label optional edge label
* @param points list of [x, y] waypoints from source to target
*/
public record PositionedEdge(
String sourceId,
String targetId,
String label,
List<double[]> points
) {
}

View File

@@ -0,0 +1,30 @@
package com.cameleer3.server.core.diagram;
import java.util.List;
/**
* A node with computed layout position and dimensions.
* <p>
* For compound nodes (CHOICE, SPLIT, TRY_CATCH, etc.), {@code children}
* contains the nested child nodes rendered inside the parent bounds.
*
* @param id node identifier (matches RouteNode.id)
* @param label display label
* @param type NodeType name (e.g., "ENDPOINT", "PROCESSOR")
* @param x horizontal position
* @param y vertical position
* @param width node width
* @param height node height
* @param children nested child nodes for compound/swimlane groups
*/
public record PositionedNode(
String id,
String label,
String type,
double x,
double y,
double width,
double height,
List<PositionedNode> children
) {
}