Skip to content

Commit

Permalink
[1194] Fix empty diagram svg export
Browse files Browse the repository at this point in the history
Bug: #1194
Signed-off-by: Guillaume Coutable <[email protected]>
  • Loading branch information
gcoutable committed May 17, 2022
1 parent d7288d9 commit 807b499
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ See ADR-54 for the details.
- https://github.com/eclipse-sirius/sirius-components/issues/1171[#1171] [workbench] Fix the overflow behavior of the side panels when they are resized horizontally
- https://github.com/eclipse-sirius/sirius-components/issues/1115[#1115] [workbench] Stop using the deprecated props `rowsMax`
- https://github.com/eclipse-sirius/sirius-components/issues/1195[#1195] [diagram] Fix edge svg export
- https://github.com/eclipse-sirius/sirius-components/issues/1194[#1194] [diagram] Fix empty diagram svg export

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ private StringBuilder computeViewBox(Diagram diagram) {

this.computeElementsCoordinates(diagram);

double minX = this.xBeginPositions.stream().min(Double::compare).get();
double minY = this.yBeginPositions.stream().min(Double::compare).get();
double maxX = this.xEndPositions.stream().max(Double::compare).get();
double maxY = this.yEndPositions.stream().max(Double::compare).get();
double minX = this.xBeginPositions.stream().min(Double::compare).orElse(0d);
double minY = this.yBeginPositions.stream().min(Double::compare).orElse(0d);
double maxX = this.xEndPositions.stream().max(Double::compare).orElse(0d);
double maxY = this.yEndPositions.stream().max(Double::compare).orElse(0d);

int padding = 20;
double width = Math.abs(minX - maxX) + diagram.getPosition().getX();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,12 @@ public void testExportDiagramWithEdge() throws URISyntaxException {
assertThat(export).contains("<path d=\""); //$NON-NLS-1$
}

@Test
public void testExportEmptyDiagram() throws URISyntaxException {
Diagram emptyDiagram = TestLayoutDiagramBuilder.diagram("Root").nodes().and().build(); //$NON-NLS-1$
DiagramExportService diagramExportService = this.getDiagramExportService();
String export = diagramExportService.export(emptyDiagram);
assertThat(export).isNotBlank();
}

}

0 comments on commit 807b499

Please sign in to comment.