From 3f0e880c4090ac35f3f37bacaea6752ac320a74d Mon Sep 17 00:00:00 2001 From: BOUTIER Charly Date: Mon, 16 Sep 2024 11:43:18 +0200 Subject: [PATCH] Adds a new parameter to unify SLD and NAD colors Signed-off-by: BOUTIER Charly --- .../com/powsybl/sld/server/SingleLineDiagramService.java | 5 +++-- .../java/com/powsybl/sld/server/SingleLineDiagramTest.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/powsybl/sld/server/SingleLineDiagramService.java b/src/main/java/com/powsybl/sld/server/SingleLineDiagramService.java index 088f15c..c794ff6 100644 --- a/src/main/java/com/powsybl/sld/server/SingleLineDiagramService.java +++ b/src/main/java/com/powsybl/sld/server/SingleLineDiagramService.java @@ -98,6 +98,7 @@ SvgAndMetadata generateSvgAndMetadata(UUID networkUuid, String variantId, String svgParameters.setLabelDiagonal(diagParams.isDiagonalLabel()); svgParameters.setUseName(diagParams.isUseName()); svgParameters.setLanguageTag(diagParams.getLanguage()); + svgParameters.setUnifyVoltageLevelColors(true); LayoutParameters layoutParameters = new LayoutParameters(LAYOUT_PARAMETERS); SldParameters sldParameters = new SldParameters(); @@ -120,8 +121,8 @@ SvgAndMetadata generateSvgAndMetadata(UUID networkUuid, String variantId, String sldParameters.setSubstationLayoutFactory(substationLayoutFactory); sldParameters.setVoltageLevelLayoutFactoryCreator(voltageLevelLayoutFactory); sldParameters.setLayoutParameters(layoutParameters); - sldParameters.setStyleProviderFactory(n -> diagParams.isTopologicalColoring() ? - new StyleProvidersList(new TopologicalStyleProvider(network), new HighlightLineStateStyleProvider(network)) : + sldParameters.setStyleProviderFactory((n, s) -> diagParams.isTopologicalColoring() ? + new StyleProvidersList(new TopologicalStyleProvider(network, svgParameters), new HighlightLineStateStyleProvider(network)) : new StyleProvidersList(new NominalVoltageStyleProvider(), new HighlightLineStateStyleProvider(network))); sldParameters.setComponentLibrary(compLibrary); diff --git a/src/test/java/com/powsybl/sld/server/SingleLineDiagramTest.java b/src/test/java/com/powsybl/sld/server/SingleLineDiagramTest.java index cc300dc..848f794 100644 --- a/src/test/java/com/powsybl/sld/server/SingleLineDiagramTest.java +++ b/src/test/java/com/powsybl/sld/server/SingleLineDiagramTest.java @@ -554,7 +554,7 @@ public void testPositionDiagramLabelProvider() throws IOException { assertFalse(feederInfos1.get(0).getLeftLabel().isPresent()); assertFalse(feederInfos1.get(1).getLeftLabel().isPresent()); sldParameters.setLabelProviderFactory((a, b, c, d) -> new PositionDiagramLabelProvider(testNetwork, componentLibrary, layoutParameters, svgParameters, "vl1")); - sldParameters.setStyleProviderFactory(n -> new NominalVoltageStyleProvider()); + sldParameters.setStyleProviderFactory((n, s) -> new NominalVoltageStyleProvider()); sldParameters.setComponentLibrary(componentLibrary); sldParameters.setLayoutParameters(layoutParameters);