From 9478dcdabbf98cee88cbd6641ea24830062cfed1 Mon Sep 17 00:00:00 2001 From: Thomas ADAM Date: Thu, 9 Feb 2023 11:53:54 +0100 Subject: [PATCH 01/10] HvdcTest : fix svg generation at any time Signed-off-by: Thomas ADAM --- .../src/test/java/com/powsybl/nad/svg/HvdcTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/network-area-diagram/src/test/java/com/powsybl/nad/svg/HvdcTest.java b/network-area-diagram/src/test/java/com/powsybl/nad/svg/HvdcTest.java index 1bdb9c068..482ba4df7 100644 --- a/network-area-diagram/src/test/java/com/powsybl/nad/svg/HvdcTest.java +++ b/network-area-diagram/src/test/java/com/powsybl/nad/svg/HvdcTest.java @@ -45,7 +45,6 @@ protected LabelProvider getLabelProvider(Network network) { @Test public void testHvdcVL1Depth1() { Network network = HvdcTestNetwork.createVsc(); - debugSvg = true; assertEquals( toString("/hvdc-vl-depth-1.svg"), generateSvgString(network, From 87c22ee6c93dc3fb2eca5ee513cbec8f252c2a07 Mon Sep 17 00:00:00 2001 From: Thomas ADAM Date: Fri, 10 Feb 2023 17:30:25 +0100 Subject: [PATCH 02/10] First try to animate feeder infos arrows using test resources components library Signed-off-by: Thomas ADAM --- .../powsybl/sld/svg/BasicStyleProvider.java | 2 +- .../com/powsybl/sld/svg/DefaultSVGWriter.java | 2 +- .../powsybl/sld/svg/DiagramStyleProvider.java | 2 +- .../com/powsybl/sld/svg/DiagramStyles.java | 8 + .../com/powsybl/sld/iidm/TestFeederInfos.java | 66 +++++++- .../resources/AnimatedLibrary/components.css | 24 +++ .../resources/AnimatedLibrary/components.json | 3 + .../resources/TestAnimatedFeederInfos.svg | 151 ++++++++++++++++++ .../src/test/resources/TestFeederInfos.svg | 24 +++ .../resources/TestFormattingFeederInfos.svg | 24 +++ 10 files changed, 295 insertions(+), 11 deletions(-) create mode 100644 single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.css create mode 100644 single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.json create mode 100644 single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/BasicStyleProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/BasicStyleProvider.java index 090b72ef6..e2e630351 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/BasicStyleProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/BasicStyleProvider.java @@ -150,7 +150,7 @@ public Optional getBusInfoStyle(BusInfo info) { } @Override - public List getFeederInfoStyles(FeederInfo info) { + public List getFeederInfoStyles(FeederInfo info, boolean animated) { List styles = new ArrayList<>(); styles.add(FEEDER_INFO); if (info instanceof DirectionalFeederInfo) { diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultSVGWriter.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultSVGWriter.java index 522f8ea67..787aa1aea 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultSVGWriter.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultSVGWriter.java @@ -878,7 +878,7 @@ private void drawFeederInfo(String prefixId, FeederNode feederNode, List // we draw the feeder info double rotationAngle = points.get(0).getY() > points.get(1).getY() ? 180 : 0; insertFeederInfoSVGIntoDocumentSVG(feederInfo, prefixId, g, rotationAngle); - styles.addAll(styleProvider.getFeederInfoStyles(feederInfo)); + styles.addAll(styleProvider.getFeederInfoStyles(feederInfo, layoutParameters.isEnableFeederInfosAnimation())); // we draw the right label only if present feederInfo.getRightLabel().ifPresent(s -> { diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyleProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyleProvider.java index e16d51c9d..10403bef9 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyleProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyleProvider.java @@ -44,7 +44,7 @@ public interface DiagramStyleProvider { Optional getBusInfoStyle(BusInfo info); - List getFeederInfoStyles(FeederInfo info); + List getFeederInfoStyles(FeederInfo info, boolean animated); List getCellStyles(Cell cell); } diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyles.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyles.java index f365572db..ffb63016b 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyles.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyles.java @@ -46,6 +46,14 @@ public final class DiagramStyles { public static final String ANGLE = STYLE_PREFIX + "angle"; public static final String FEEDER_INFO = STYLE_PREFIX + "feeder-info"; + public static final String ARROW_ANIMATION = STYLE_PREFIX + "arrow-animation"; + + public static final String ARROW_ANIMATION_SPEED_1 = STYLE_PREFIX + "arrow-animation-speed-1"; + + public static final String ARROW_ANIMATION_SPEED_2 = STYLE_PREFIX + "arrow-animation-speed-2"; + + public static final String ARROW_ANIMATION_SPEED_3 = STYLE_PREFIX + "arrow-animation-speed-3"; + private static final String ID_PREFIX = "id"; private DiagramStyles() { diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java index c2f683b88..1771c90e4 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java @@ -6,27 +6,24 @@ */ package com.powsybl.sld.iidm; -import com.powsybl.iidm.network.Country; -import com.powsybl.iidm.network.Network; -import com.powsybl.iidm.network.SwitchKind; -import com.powsybl.iidm.network.TopologyKind; +import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.ConnectablePosition; import com.powsybl.sld.builders.NetworkGraphBuilder; +import com.powsybl.sld.library.ResourcesComponentLibrary; import com.powsybl.sld.model.coordinate.Direction; import com.powsybl.sld.model.graphs.VoltageLevelGraph; import com.powsybl.sld.model.nodes.FeederNode; import com.powsybl.sld.model.nodes.Node; import com.powsybl.sld.svg.*; +import com.powsybl.sld.util.NominalVoltageDiagramStyleProvider; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.*; import static com.powsybl.sld.library.ComponentTypeName.ARROW_ACTIVE; import static com.powsybl.sld.library.ComponentTypeName.ARROW_REACTIVE; +import static com.powsybl.sld.svg.DiagramStyles.*; import static org.junit.Assert.assertEquals; /** @@ -44,6 +41,11 @@ */ public class TestFeederInfos extends AbstractTestCaseIidm { + @Override + protected ResourcesComponentLibrary getResourcesComponentLibrary() { + return new ResourcesComponentLibrary("animated", "/ConvergenceLibrary", "/AnimatedLibrary"); + } + @Before public void setUp() { network = Network.create("testCase14", "test"); @@ -112,4 +114,52 @@ public void testFrenchFormatting() { // write SVG and compare to reference assertEquals(toString("/TestFormattingFeederInfos.svg"), toSVG(g, "/TestFormattingFeederInfos.svg")); } + + @Test + public void testAnimation() { + // Add power values to the load + network.getLoad("l").getTerminal().setP(1200.29); + network.getLoad("l").getTerminal().setQ(-1); + + // Enable animation + layoutParameters.setEnableFeederInfosAnimation(true); + + DiagramLabelProvider labelProvider = new DefaultDiagramLabelProvider(network, componentLibrary, layoutParameters) { + @Override + public List getFeederInfos(FeederNode node) { + Load l = network.getLoad("l"); + return Arrays.asList( + new DirectionalFeederInfo(ARROW_ACTIVE, l.getTerminal().getP(), valueFormatter::formatPower, l.getNameOrId()), + new DirectionalFeederInfo(ARROW_REACTIVE, l.getTerminal().getQ(), valueFormatter::formatPower, l.getNameOrId())); + } + }; + + DiagramStyleProvider styleProvider = new NominalVoltageDiagramStyleProvider(network) { + @Override + public List getFeederInfoStyles(FeederInfo info, boolean animated) { + List styles = new ArrayList<>(super.getFeederInfoStyles(info, animated)); + if (animated && info instanceof DirectionalFeederInfo) { + DirectionalFeederInfo feederInfo = (DirectionalFeederInfo) info; + styles.add(ARROW_ANIMATION); + Load equipment = this.network.getLoad(feederInfo.getUserDefinedId()); + double power = Math.abs(feederInfo.getDirection() == DiagramLabelProvider.LabelDirection.OUT ? equipment.getTerminal().getP() : equipment.getTerminal().getQ()); + if (Math.abs(power) > 1000) { + styles.add(ARROW_ANIMATION_SPEED_3); + } else { + styles.add(ARROW_ANIMATION_SPEED_1); + } + } + return styles; + } + }; + + // build graph + VoltageLevelGraph g = graphBuilder.buildVoltageLevelGraph(vl.getId()); + + // Run layout + voltageLevelGraphLayout(g); + + // write SVG and compare to reference + assertEquals(toString("/TestAnimatedFeederInfos.svg"), toSVG(g, "/TestAnimatedFeederInfos.svg", labelProvider, styleProvider)); + } } diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.css b/single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.css new file mode 100644 index 000000000..2d8e68639 --- /dev/null +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.css @@ -0,0 +1,24 @@ +/* ----------------------------------------------------------------------- */ +/* File : components.css ------------------------------------------------- */ +/* feeder infos animation */ +.sld-arrow-in { + offset-rotate: 0deg; + offset-path: var(--sld-arrow-in-offset-path, path('')); + animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; +} +.sld-arrow-out { + offset-rotate: 0deg; + offset-path: var(--sld-arrow-out-offset-path, path('')); + animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; +} +@keyframes move { + to { + offset-distance: 100%; + } +} +/* Enable arrows animation */ +.sld-arrow-animation { --sld-arrow-in-offset-path: path('M 0,-10 0,10'); --sld-arrow-out-offset-path: path('M 0,10 0,-10') } +/* Set arrows animation speed (1: the slowest -> 3: the fastest) */ +.sld-arrow-animation-speed-1 { --sld-arrow-animation-duration: 3s } +.sld-arrow-animation-speed-2 { --sld-arrow-animation-duration: 2s } +.sld-arrow-animation-speed-3 { --sld-arrow-animation-duration: 1s } diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.json b/single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.json new file mode 100644 index 000000000..06ddee619 --- /dev/null +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.json @@ -0,0 +1,3 @@ +{ + "components" : [] +} \ No newline at end of file diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg new file mode 100644 index 000000000..f4d990900 --- /dev/null +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg @@ -0,0 +1,151 @@ + + + + + + + + bbs + + + + + + + + + + + + + + + + + + 1,200 + + + + + -1 + + + + + + + + + + + + + + + + + + + + l + + + + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederInfos.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederInfos.svg index f95556293..96213278f 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederInfos.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederInfos.svg @@ -57,6 +57,30 @@ .sld-disconnector.sld-fictitious {stroke: maroon} .sld-load-break-switch.sld-fictitious {stroke: maroon} .sld-busbar-section.sld-fictitious {stroke: var(--sld-vl-color, #c80000); stroke-width: 1} +/* ----------------------------------------------------------------------- */ +/* File : components.css ------------------------------------------------- */ +/* feeder infos animation */ +.sld-arrow-in { + offset-rotate: 0deg; + offset-path: var(--sld-arrow-in-offset-path, path('')); + animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; +} +.sld-arrow-out { + offset-rotate: 0deg; + offset-path: var(--sld-arrow-out-offset-path, path('')); + animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; +} +@keyframes move { + to { + offset-distance: 100%; + } +} +/* Enable arrows animation */ +.sld-arrow-animation { --sld-arrow-in-offset-path: path('M 0,-10 0,10'); --sld-arrow-out-offset-path: path('M 0,10 0,-10') } +/* Set arrows animation speed (1: the slowest -> 3: the fastest) */ +.sld-arrow-animation-speed-1 { --sld-arrow-animation-duration: 3s } +.sld-arrow-animation-speed-2 { --sld-arrow-animation-duration: 2s } +.sld-arrow-animation-speed-3 { --sld-arrow-animation-duration: 1s } ]]> diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFormattingFeederInfos.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFormattingFeederInfos.svg index d7780bfb2..5f204a537 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFormattingFeederInfos.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFormattingFeederInfos.svg @@ -135,6 +135,30 @@ .sld-disconnector.sld-fictitious {stroke: maroon} .sld-load-break-switch.sld-fictitious {stroke: maroon} .sld-busbar-section.sld-fictitious {stroke: var(--sld-vl-color, #c80000); stroke-width: 1} +/* ----------------------------------------------------------------------- */ +/* File : components.css ------------------------------------------------- */ +/* feeder infos animation */ +.sld-arrow-in { + offset-rotate: 0deg; + offset-path: var(--sld-arrow-in-offset-path, path('')); + animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; +} +.sld-arrow-out { + offset-rotate: 0deg; + offset-path: var(--sld-arrow-out-offset-path, path('')); + animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; +} +@keyframes move { + to { + offset-distance: 100%; + } +} +/* Enable arrows animation */ +.sld-arrow-animation { --sld-arrow-in-offset-path: path('M 0,-10 0,10'); --sld-arrow-out-offset-path: path('M 0,10 0,-10') } +/* Set arrows animation speed (1: the slowest -> 3: the fastest) */ +.sld-arrow-animation-speed-1 { --sld-arrow-animation-duration: 3s } +.sld-arrow-animation-speed-2 { --sld-arrow-animation-duration: 2s } +.sld-arrow-animation-speed-3 { --sld-arrow-animation-duration: 1s } ]]> From a8fc76d83699d5b2972b41d86adcd1c9a6e33fee Mon Sep 17 00:00:00 2001 From: Thomas ADAM Date: Wed, 15 Feb 2023 10:24:51 +0100 Subject: [PATCH 03/10] Add & use rotation info Signed-off-by: Thomas ADAM --- .../powsybl/sld/svg/BasicStyleProvider.java | 2 +- .../com/powsybl/sld/svg/DefaultSVGWriter.java | 2 +- .../powsybl/sld/svg/DiagramStyleProvider.java | 2 +- .../com/powsybl/sld/svg/DiagramStyles.java | 8 --- .../com/powsybl/sld/iidm/TestFeederInfos.java | 59 +++++++++++++++---- .../resources/AnimatedLibrary/components.css | 7 ++- .../resources/TestAnimatedFeederInfos.svg | 52 +++++++++++++--- .../src/test/resources/TestFeederInfos.svg | 7 ++- .../resources/TestFormattingFeederInfos.svg | 7 ++- 9 files changed, 107 insertions(+), 39 deletions(-) diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/BasicStyleProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/BasicStyleProvider.java index e2e630351..782e5b870 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/BasicStyleProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/BasicStyleProvider.java @@ -150,7 +150,7 @@ public Optional getBusInfoStyle(BusInfo info) { } @Override - public List getFeederInfoStyles(FeederInfo info, boolean animated) { + public List getFeederInfoStyles(FeederInfo info, boolean rotated, boolean animated) { List styles = new ArrayList<>(); styles.add(FEEDER_INFO); if (info instanceof DirectionalFeederInfo) { diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultSVGWriter.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultSVGWriter.java index 787aa1aea..8b68c7907 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultSVGWriter.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultSVGWriter.java @@ -878,7 +878,7 @@ private void drawFeederInfo(String prefixId, FeederNode feederNode, List // we draw the feeder info double rotationAngle = points.get(0).getY() > points.get(1).getY() ? 180 : 0; insertFeederInfoSVGIntoDocumentSVG(feederInfo, prefixId, g, rotationAngle); - styles.addAll(styleProvider.getFeederInfoStyles(feederInfo, layoutParameters.isEnableFeederInfosAnimation())); + styles.addAll(styleProvider.getFeederInfoStyles(feederInfo, rotationAngle != 0, layoutParameters.isEnableFeederInfosAnimation())); // we draw the right label only if present feederInfo.getRightLabel().ifPresent(s -> { diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyleProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyleProvider.java index 10403bef9..92b7acccb 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyleProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyleProvider.java @@ -44,7 +44,7 @@ public interface DiagramStyleProvider { Optional getBusInfoStyle(BusInfo info); - List getFeederInfoStyles(FeederInfo info, boolean animated); + List getFeederInfoStyles(FeederInfo info, boolean rotated, boolean animated); List getCellStyles(Cell cell); } diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyles.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyles.java index ffb63016b..f365572db 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyles.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DiagramStyles.java @@ -46,14 +46,6 @@ public final class DiagramStyles { public static final String ANGLE = STYLE_PREFIX + "angle"; public static final String FEEDER_INFO = STYLE_PREFIX + "feeder-info"; - public static final String ARROW_ANIMATION = STYLE_PREFIX + "arrow-animation"; - - public static final String ARROW_ANIMATION_SPEED_1 = STYLE_PREFIX + "arrow-animation-speed-1"; - - public static final String ARROW_ANIMATION_SPEED_2 = STYLE_PREFIX + "arrow-animation-speed-2"; - - public static final String ARROW_ANIMATION_SPEED_3 = STYLE_PREFIX + "arrow-animation-speed-3"; - private static final String ID_PREFIX = "id"; private DiagramStyles() { diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java index 1771c90e4..858ca936d 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java @@ -41,6 +41,16 @@ */ public class TestFeederInfos extends AbstractTestCaseIidm { + public static final String ARROW_IN_ANIMATION = STYLE_PREFIX + "arrow-in-animation"; + + public static final String ARROW_OUT_ANIMATION = STYLE_PREFIX + "arrow-out-animation"; + + public static final String ARROW_ANIMATION_SPEED_1 = STYLE_PREFIX + "arrow-animation-speed-1"; + + public static final String ARROW_ANIMATION_SPEED_2 = STYLE_PREFIX + "arrow-animation-speed-2"; + + public static final String ARROW_ANIMATION_SPEED_3 = STYLE_PREFIX + "arrow-animation-speed-3"; + @Override protected ResourcesComponentLibrary getResourcesComponentLibrary() { return new ResourcesComponentLibrary("animated", "/ConvergenceLibrary", "/AnimatedLibrary"); @@ -117,36 +127,61 @@ public void testFrenchFormatting() { @Test public void testAnimation() { + // Add load at bottom + createSwitch(vl, "d2", "d2", SwitchKind.DISCONNECTOR, false, false, false, 0, 3); + createLoad(vl, "l2", "l2", "l2", 0, ConnectablePosition.Direction.BOTTOM, 3, 10, 10); + // Add power values to the load network.getLoad("l").getTerminal().setP(1200.29); - network.getLoad("l").getTerminal().setQ(-1); + network.getLoad("l").getTerminal().setQ(-1.0); + + network.getLoad("l2").getTerminal().setP(501.0); + network.getLoad("l2").getTerminal().setQ(0.0); // Enable animation - layoutParameters.setEnableFeederInfosAnimation(true); + layoutParameters.setFeederInfosIntraMargin(20) + .setEnableFeederInfosAnimation(true); DiagramLabelProvider labelProvider = new DefaultDiagramLabelProvider(network, componentLibrary, layoutParameters) { @Override public List getFeederInfos(FeederNode node) { Load l = network.getLoad("l"); - return Arrays.asList( - new DirectionalFeederInfo(ARROW_ACTIVE, l.getTerminal().getP(), valueFormatter::formatPower, l.getNameOrId()), - new DirectionalFeederInfo(ARROW_REACTIVE, l.getTerminal().getQ(), valueFormatter::formatPower, l.getNameOrId())); + Load l2 = network.getLoad("l2"); + + if (Objects.equals(l.getNameOrId(), node.getEquipmentId())) { + return Arrays.asList( + new DirectionalFeederInfo(ARROW_ACTIVE, l.getTerminal().getP(), valueFormatter::formatPower, node.getEquipmentId()), + new DirectionalFeederInfo(ARROW_REACTIVE, l.getTerminal().getQ(), valueFormatter::formatPower, node.getEquipmentId())); + } else { + return Arrays.asList( + new DirectionalFeederInfo(ARROW_ACTIVE, l2.getTerminal().getP(), valueFormatter::formatPower, node.getEquipmentId()), + new DirectionalFeederInfo(ARROW_REACTIVE, l2.getTerminal().getQ(), valueFormatter::formatPower, node.getEquipmentId())); + } } }; DiagramStyleProvider styleProvider = new NominalVoltageDiagramStyleProvider(network) { @Override - public List getFeederInfoStyles(FeederInfo info, boolean animated) { - List styles = new ArrayList<>(super.getFeederInfoStyles(info, animated)); + public List getFeederInfoStyles(FeederInfo info, boolean rotated, boolean animated) { + List styles = new ArrayList<>(super.getFeederInfoStyles(info, rotated, animated)); if (animated && info instanceof DirectionalFeederInfo) { DirectionalFeederInfo feederInfo = (DirectionalFeederInfo) info; - styles.add(ARROW_ANIMATION); + if (feederInfo.getDirection() == DiagramLabelProvider.LabelDirection.IN) { + styles.add(rotated ? ARROW_OUT_ANIMATION : ARROW_IN_ANIMATION); + } else { + styles.add(rotated ? ARROW_IN_ANIMATION : ARROW_OUT_ANIMATION); + } + Load equipment = this.network.getLoad(feederInfo.getUserDefinedId()); double power = Math.abs(feederInfo.getDirection() == DiagramLabelProvider.LabelDirection.OUT ? equipment.getTerminal().getP() : equipment.getTerminal().getQ()); - if (Math.abs(power) > 1000) { - styles.add(ARROW_ANIMATION_SPEED_3); - } else { - styles.add(ARROW_ANIMATION_SPEED_1); + if (Math.abs(power) > 0) { + if (Math.abs(power) > 1000) { + styles.add(ARROW_ANIMATION_SPEED_3); + } else if (Math.abs(power) > 500.0) { + styles.add(ARROW_ANIMATION_SPEED_2); + } else { + styles.add(ARROW_ANIMATION_SPEED_1); + } } } return styles; diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.css b/single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.css index 2d8e68639..ffb31cc54 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.css +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/AnimatedLibrary/components.css @@ -3,12 +3,12 @@ /* feeder infos animation */ .sld-arrow-in { offset-rotate: 0deg; - offset-path: var(--sld-arrow-in-offset-path, path('')); + offset-path: var(--sld-arrow-offset-path, path('')); animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; } .sld-arrow-out { offset-rotate: 0deg; - offset-path: var(--sld-arrow-out-offset-path, path('')); + offset-path: var(--sld-arrow-offset-path, path('')); animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; } @keyframes move { @@ -17,7 +17,8 @@ } } /* Enable arrows animation */ -.sld-arrow-animation { --sld-arrow-in-offset-path: path('M 0,-10 0,10'); --sld-arrow-out-offset-path: path('M 0,10 0,-10') } +.sld-arrow-in-animation { --sld-arrow-offset-path: path('M 0,-10 0,10') } +.sld-arrow-out-animation { --sld-arrow-offset-path: path('M 0,10 0,-10') } /* Set arrows animation speed (1: the slowest -> 3: the fastest) */ .sld-arrow-animation-speed-1 { --sld-arrow-animation-duration: 3s } .sld-arrow-animation-speed-2 { --sld-arrow-animation-duration: 2s } diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg index f4d990900..4d9cfb7f3 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg @@ -1,5 +1,5 @@ - + - + bbs - - + + - + - + - + - + 1,200 - + -1 - + - + - + - + - + l - - + + - + - + - + 501 - + 0 - + - + - + - + From 2dd8d2f2e59d3ca2ffce358ac5576d0fc283eef2 Mon Sep 17 00:00:00 2001 From: Thomas ADAM Date: Thu, 16 Feb 2023 14:48:23 +0100 Subject: [PATCH 05/10] Update svg test reference files Signed-off-by: Thomas ADAM --- .../resources/InternalBranchesBusBreaker.svg | 16 +++--- .../resources/InternalBranchesNodeBreaker.svg | 16 +++--- .../NodeDecoratorsBranchStatusBusBreaker.svg | 16 +++--- .../NodeDecoratorsBranchStatusNodeBreaker.svg | 24 ++++----- .../test/resources/NodeDecoratorsSwitches.svg | 16 +++--- .../src/test/resources/TestCase1.svg | 2 +- .../test/resources/TestCase11FlatDesign.svg | 54 +++++++++---------- .../TestCase11SubstationGraphHFirst.svg | 54 +++++++++---------- .../TestCase11SubstationGraphHLast.svg | 54 +++++++++---------- .../TestCase11SubstationGraphHMiddle.svg | 54 +++++++++---------- .../TestCase11SubstationGraphHNone.svg | 54 +++++++++---------- ...ase12GraphWithNodesInfosNominalVoltage.svg | 24 ++++----- ...stCase12GraphWithNodesInfosTopological.svg | 24 ++++----- .../TestCase15GraphWithVoltageIndicator.svg | 6 +-- ...15GraphWithVoltageIndicatorTopological.svg | 6 +-- ...TestCase15GraphWithoutVoltageIndicator.svg | 6 +-- .../test/resources/TestCaseFictitiousBus.svg | 6 +-- .../TestCaseFictitiousBusTopological.svg | 6 +-- .../resources/TestCaseLoadBreakSwitch.svg | 4 +- .../src/test/resources/TestCheese.svg | 2 +- .../TestComplexParallelLegsInternalPst.svg | 2 +- .../src/test/resources/TestFeederInfos.svg | 27 +--------- .../src/test/resources/TestFeederOnBus.svg | 2 +- .../resources/TestFeederOnBusDisconnector.svg | 2 +- .../resources/TestFormattingFeederInfos.svg | 27 +--------- .../test/resources/TestSldClassSubstation.svg | 8 +-- .../src/test/resources/TestSldClassVl.svg | 4 +- .../src/test/resources/consecutive_shunts.svg | 20 +++---- .../src/test/resources/feederInfoTest.svg | 6 +-- .../src/test/resources/noComponentsOnBus.svg | 6 +-- .../nominal_voltage_style_substation.svg | 12 ++--- .../resources/nominal_voltage_style_vl2.svg | 4 +- .../resources/nominal_voltage_style_vl3.svg | 2 +- .../src/test/resources/switchesOnBus.svg | 6 +-- .../topological_style_substation.svg | 12 ++--- 35 files changed, 267 insertions(+), 317 deletions(-) diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/InternalBranchesBusBreaker.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/InternalBranchesBusBreaker.svg index 4286e9625..672b14f1a 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/InternalBranchesBusBreaker.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/InternalBranchesBusBreaker.svg @@ -144,7 +144,7 @@ - + @@ -180,7 +180,7 @@ LD1 - + @@ -213,7 +213,7 @@ L11 - + @@ -246,7 +246,7 @@ L12 - + @@ -297,7 +297,7 @@ T3_12 - + @@ -333,7 +333,7 @@ G - + @@ -366,7 +366,7 @@ L11 - + @@ -401,7 +401,7 @@ T12 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/InternalBranchesNodeBreaker.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/InternalBranchesNodeBreaker.svg index 919df0918..bafaea90d 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/InternalBranchesNodeBreaker.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/InternalBranchesNodeBreaker.svg @@ -225,7 +225,7 @@ - + @@ -269,7 +269,7 @@ L1 - + @@ -310,7 +310,7 @@ L11 - + @@ -351,7 +351,7 @@ L12 - + @@ -410,7 +410,7 @@ T3_12 - + @@ -454,7 +454,7 @@ G - + @@ -495,7 +495,7 @@ L11 - + @@ -538,7 +538,7 @@ T12 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusBusBreaker.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusBusBreaker.svg index 053f411bc..8e0cc9ee0 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusBusBreaker.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusBusBreaker.svg @@ -211,7 +211,7 @@ - + @@ -247,7 +247,7 @@ LD1 - + @@ -283,7 +283,7 @@ - + @@ -319,7 +319,7 @@ - + @@ -373,7 +373,7 @@ T3_12 - + @@ -409,7 +409,7 @@ G - + @@ -445,7 +445,7 @@ - + @@ -483,7 +483,7 @@ - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg index 150fb7f9c..613bd181f 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg @@ -231,7 +231,7 @@ - + @@ -275,7 +275,7 @@ L1 - + @@ -319,7 +319,7 @@ - + @@ -363,7 +363,7 @@ - + @@ -407,7 +407,7 @@ - + @@ -451,7 +451,7 @@ G - + @@ -495,7 +495,7 @@ - + @@ -539,7 +539,7 @@ - + @@ -593,7 +593,7 @@ BBS2 - + @@ -637,7 +637,7 @@ L2 - + @@ -681,7 +681,7 @@ - + @@ -725,7 +725,7 @@ - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsSwitches.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsSwitches.svg index e5741c30e..53498e112 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsSwitches.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsSwitches.svg @@ -246,7 +246,7 @@ - + @@ -296,7 +296,7 @@ L1 - + @@ -343,7 +343,7 @@ L11 - + @@ -390,7 +390,7 @@ L12 - + @@ -455,7 +455,7 @@ T3_12 - + @@ -505,7 +505,7 @@ G - + @@ -552,7 +552,7 @@ L11 - + @@ -601,7 +601,7 @@ T12 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase1.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase1.svg index a21c4b985..f9fec8cf2 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase1.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase1.svg @@ -65,7 +65,7 @@ bbs - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11FlatDesign.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11FlatDesign.svg index 78c7e4662..91451632b 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11FlatDesign.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11FlatDesign.svg @@ -206,7 +206,7 @@ - + @@ -247,7 +247,7 @@ load1 - + @@ -287,7 +287,7 @@ trf1 - + @@ -327,7 +327,7 @@ trf5 - + @@ -367,7 +367,7 @@ trf61 - + @@ -407,7 +407,7 @@ line1 - + @@ -448,7 +448,7 @@ load2 - + @@ -488,7 +488,7 @@ trf2 - + @@ -528,7 +528,7 @@ trf81 - + @@ -569,7 +569,7 @@ gen1 - + @@ -609,7 +609,7 @@ trf3 - + @@ -649,7 +649,7 @@ trf71 - + @@ -690,7 +690,7 @@ gen2 - + @@ -771,7 +771,7 @@ - + @@ -812,7 +812,7 @@ load3 - + @@ -852,7 +852,7 @@ trf1 - + @@ -892,7 +892,7 @@ trf4 - + @@ -932,7 +932,7 @@ trf72 - + @@ -973,7 +973,7 @@ gen4 - + @@ -1013,7 +1013,7 @@ trf2 - + @@ -1053,7 +1053,7 @@ trf3 - + @@ -1093,7 +1093,7 @@ trf62 - + @@ -1140,7 +1140,7 @@ bbs7 - + @@ -1181,7 +1181,7 @@ load4 - + @@ -1221,7 +1221,7 @@ trf5 - + @@ -1261,7 +1261,7 @@ trf63 - + @@ -1301,7 +1301,7 @@ trf73 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHFirst.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHFirst.svg index ed566561f..1390bc38a 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHFirst.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHFirst.svg @@ -222,7 +222,7 @@ - + @@ -266,7 +266,7 @@ load1 - + @@ -307,7 +307,7 @@ trf1 - + @@ -348,7 +348,7 @@ trf5 - + @@ -389,7 +389,7 @@ trf61 - + @@ -430,7 +430,7 @@ line1 - + @@ -474,7 +474,7 @@ load2 - + @@ -515,7 +515,7 @@ trf2 - + @@ -556,7 +556,7 @@ trf81 - + @@ -600,7 +600,7 @@ gen1 - + @@ -641,7 +641,7 @@ trf3 - + @@ -682,7 +682,7 @@ trf71 - + @@ -726,7 +726,7 @@ gen2 - + @@ -810,7 +810,7 @@ - + @@ -854,7 +854,7 @@ load3 - + @@ -895,7 +895,7 @@ trf1 - + @@ -936,7 +936,7 @@ trf4 - + @@ -977,7 +977,7 @@ trf72 - + @@ -1021,7 +1021,7 @@ gen4 - + @@ -1062,7 +1062,7 @@ trf2 - + @@ -1103,7 +1103,7 @@ trf3 - + @@ -1144,7 +1144,7 @@ trf62 - + @@ -1192,7 +1192,7 @@ bbs7 - + @@ -1236,7 +1236,7 @@ load4 - + @@ -1277,7 +1277,7 @@ trf5 - + @@ -1318,7 +1318,7 @@ trf63 - + @@ -1359,7 +1359,7 @@ trf73 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHLast.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHLast.svg index 314858278..c38912783 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHLast.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHLast.svg @@ -222,7 +222,7 @@ - + @@ -266,7 +266,7 @@ load1 - + @@ -307,7 +307,7 @@ trf1 - + @@ -348,7 +348,7 @@ trf5 - + @@ -389,7 +389,7 @@ trf61 - + @@ -430,7 +430,7 @@ line1 - + @@ -474,7 +474,7 @@ load2 - + @@ -515,7 +515,7 @@ trf2 - + @@ -556,7 +556,7 @@ trf81 - + @@ -600,7 +600,7 @@ gen1 - + @@ -641,7 +641,7 @@ trf3 - + @@ -682,7 +682,7 @@ trf71 - + @@ -726,7 +726,7 @@ gen2 - + @@ -810,7 +810,7 @@ - + @@ -854,7 +854,7 @@ load3 - + @@ -895,7 +895,7 @@ trf1 - + @@ -936,7 +936,7 @@ trf4 - + @@ -977,7 +977,7 @@ trf72 - + @@ -1021,7 +1021,7 @@ gen4 - + @@ -1062,7 +1062,7 @@ trf2 - + @@ -1103,7 +1103,7 @@ trf3 - + @@ -1144,7 +1144,7 @@ trf62 - + @@ -1192,7 +1192,7 @@ bbs7 - + @@ -1236,7 +1236,7 @@ load4 - + @@ -1277,7 +1277,7 @@ trf5 - + @@ -1318,7 +1318,7 @@ trf63 - + @@ -1359,7 +1359,7 @@ trf73 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHMiddle.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHMiddle.svg index 970e6d976..a55b809dd 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHMiddle.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHMiddle.svg @@ -222,7 +222,7 @@ - + @@ -266,7 +266,7 @@ load1 - + @@ -307,7 +307,7 @@ trf1 - + @@ -348,7 +348,7 @@ trf5 - + @@ -389,7 +389,7 @@ trf61 - + @@ -430,7 +430,7 @@ line1 - + @@ -474,7 +474,7 @@ load2 - + @@ -515,7 +515,7 @@ trf2 - + @@ -556,7 +556,7 @@ trf81 - + @@ -600,7 +600,7 @@ gen1 - + @@ -641,7 +641,7 @@ trf3 - + @@ -682,7 +682,7 @@ trf71 - + @@ -726,7 +726,7 @@ gen2 - + @@ -810,7 +810,7 @@ - + @@ -854,7 +854,7 @@ load3 - + @@ -895,7 +895,7 @@ trf1 - + @@ -936,7 +936,7 @@ trf4 - + @@ -977,7 +977,7 @@ trf72 - + @@ -1021,7 +1021,7 @@ gen4 - + @@ -1062,7 +1062,7 @@ trf2 - + @@ -1103,7 +1103,7 @@ trf3 - + @@ -1144,7 +1144,7 @@ trf62 - + @@ -1192,7 +1192,7 @@ bbs7 - + @@ -1236,7 +1236,7 @@ load4 - + @@ -1277,7 +1277,7 @@ trf5 - + @@ -1318,7 +1318,7 @@ trf63 - + @@ -1359,7 +1359,7 @@ trf73 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHNone.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHNone.svg index ed566561f..1390bc38a 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHNone.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase11SubstationGraphHNone.svg @@ -222,7 +222,7 @@ - + @@ -266,7 +266,7 @@ load1 - + @@ -307,7 +307,7 @@ trf1 - + @@ -348,7 +348,7 @@ trf5 - + @@ -389,7 +389,7 @@ trf61 - + @@ -430,7 +430,7 @@ line1 - + @@ -474,7 +474,7 @@ load2 - + @@ -515,7 +515,7 @@ trf2 - + @@ -556,7 +556,7 @@ trf81 - + @@ -600,7 +600,7 @@ gen1 - + @@ -641,7 +641,7 @@ trf3 - + @@ -682,7 +682,7 @@ trf71 - + @@ -726,7 +726,7 @@ gen2 - + @@ -810,7 +810,7 @@ - + @@ -854,7 +854,7 @@ load3 - + @@ -895,7 +895,7 @@ trf1 - + @@ -936,7 +936,7 @@ trf4 - + @@ -977,7 +977,7 @@ trf72 - + @@ -1021,7 +1021,7 @@ gen4 - + @@ -1062,7 +1062,7 @@ trf2 - + @@ -1103,7 +1103,7 @@ trf3 - + @@ -1144,7 +1144,7 @@ trf62 - + @@ -1192,7 +1192,7 @@ bbs7 - + @@ -1236,7 +1236,7 @@ load4 - + @@ -1277,7 +1277,7 @@ trf5 - + @@ -1318,7 +1318,7 @@ trf63 - + @@ -1359,7 +1359,7 @@ trf73 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase12GraphWithNodesInfosNominalVoltage.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase12GraphWithNodesInfosNominalVoltage.svg index ffc43558f..e22d0e198 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase12GraphWithNodesInfosNominalVoltage.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase12GraphWithNodesInfosNominalVoltage.svg @@ -155,7 +155,7 @@ - + @@ -199,7 +199,7 @@ load1 - + @@ -242,7 +242,7 @@ trf1 - + @@ -285,7 +285,7 @@ trf5 - + @@ -344,7 +344,7 @@ trf61 - + @@ -388,7 +388,7 @@ load2 - + @@ -431,7 +431,7 @@ trf2 - + @@ -490,7 +490,7 @@ trf81 - + @@ -534,7 +534,7 @@ gen1 - + @@ -577,7 +577,7 @@ trf3 - + @@ -636,7 +636,7 @@ trf71 - + @@ -680,7 +680,7 @@ gen2 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase12GraphWithNodesInfosTopological.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase12GraphWithNodesInfosTopological.svg index d722be6bf..2056bc7b8 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase12GraphWithNodesInfosTopological.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase12GraphWithNodesInfosTopological.svg @@ -219,7 +219,7 @@ - + @@ -263,7 +263,7 @@ load1 - + @@ -306,7 +306,7 @@ trf1 - + @@ -349,7 +349,7 @@ trf5 - + @@ -408,7 +408,7 @@ trf61 - + @@ -452,7 +452,7 @@ load2 - + @@ -495,7 +495,7 @@ trf2 - + @@ -554,7 +554,7 @@ trf81 - + @@ -598,7 +598,7 @@ gen1 - + @@ -641,7 +641,7 @@ trf3 - + @@ -700,7 +700,7 @@ trf71 - + @@ -744,7 +744,7 @@ gen2 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithVoltageIndicator.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithVoltageIndicator.svg index bbb72bd21..985fd902c 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithVoltageIndicator.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithVoltageIndicator.svg @@ -101,7 +101,7 @@ Bottom - + @@ -152,7 +152,7 @@ - + @@ -233,7 +233,7 @@ - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithVoltageIndicatorTopological.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithVoltageIndicatorTopological.svg index 847f2c6b0..8165bb60b 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithVoltageIndicatorTopological.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithVoltageIndicatorTopological.svg @@ -189,7 +189,7 @@ Bottom - + @@ -240,7 +240,7 @@ - + @@ -321,7 +321,7 @@ - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithoutVoltageIndicator.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithoutVoltageIndicator.svg index e3972d0d2..ac4ddcc9d 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithoutVoltageIndicator.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCase15GraphWithoutVoltageIndicator.svg @@ -87,7 +87,7 @@ bbs23 - + @@ -138,7 +138,7 @@ - + @@ -219,7 +219,7 @@ - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseFictitiousBus.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseFictitiousBus.svg index 0e348a82f..24deba57a 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseFictitiousBus.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseFictitiousBus.svg @@ -142,7 +142,7 @@ - + @@ -175,7 +175,7 @@ L1 - + @@ -208,7 +208,7 @@ L2 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseFictitiousBusTopological.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseFictitiousBusTopological.svg index 0e348a82f..24deba57a 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseFictitiousBusTopological.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseFictitiousBusTopological.svg @@ -142,7 +142,7 @@ - + @@ -175,7 +175,7 @@ L1 - + @@ -208,7 +208,7 @@ L2 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseLoadBreakSwitch.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseLoadBreakSwitch.svg index 0a75778ba..920e5ca9c 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseLoadBreakSwitch.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseLoadBreakSwitch.svg @@ -177,7 +177,7 @@ - + @@ -220,7 +220,7 @@ G - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCheese.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCheese.svg index 54e85c855..eb01f4a6d 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCheese.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCheese.svg @@ -69,7 +69,7 @@ bbs - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestComplexParallelLegsInternalPst.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestComplexParallelLegsInternalPst.svg index c453e60c8..5aee86aa4 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestComplexParallelLegsInternalPst.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestComplexParallelLegsInternalPst.svg @@ -135,7 +135,7 @@ bbs2 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederInfos.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederInfos.svg index c738e0249..050cb4a9e 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederInfos.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederInfos.svg @@ -57,31 +57,6 @@ .sld-disconnector.sld-fictitious {stroke: maroon} .sld-load-break-switch.sld-fictitious {stroke: maroon} .sld-busbar-section.sld-fictitious {stroke: var(--sld-vl-color, #c80000); stroke-width: 1} -/* ----------------------------------------------------------------------- */ -/* File : components.css ------------------------------------------------- */ -/* feeder infos animation */ -.sld-arrow-in { - offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('')); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; -} -.sld-arrow-out { - offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('')); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; -} -@keyframes move { - to { - offset-distance: 100%; - } -} -/* Enable arrows animation */ -.sld-arrow-in-animation { --sld-arrow-offset-path: path('M 0,-10 0,10') } -.sld-arrow-out-animation { --sld-arrow-offset-path: path('M 0,10 0,-10') } -/* Set arrows animation speed (1: the slowest -> 3: the fastest) */ -.sld-arrow-animation-speed-1 { --sld-arrow-animation-duration: 3s } -.sld-arrow-animation-speed-2 { --sld-arrow-animation-duration: 2s } -.sld-arrow-animation-speed-3 { --sld-arrow-animation-duration: 1s } ]]> @@ -90,7 +65,7 @@ bbs - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederOnBus.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederOnBus.svg index e4ec3f693..f62eef90e 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederOnBus.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederOnBus.svg @@ -65,7 +65,7 @@ bbs - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederOnBusDisconnector.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederOnBusDisconnector.svg index fd8a9d592..485e0032a 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederOnBusDisconnector.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFeederOnBusDisconnector.svg @@ -65,7 +65,7 @@ bbs - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFormattingFeederInfos.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFormattingFeederInfos.svg index 024176cb6..700bdfc6b 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestFormattingFeederInfos.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestFormattingFeederInfos.svg @@ -135,31 +135,6 @@ .sld-disconnector.sld-fictitious {stroke: maroon} .sld-load-break-switch.sld-fictitious {stroke: maroon} .sld-busbar-section.sld-fictitious {stroke: var(--sld-vl-color, #c80000); stroke-width: 1} -/* ----------------------------------------------------------------------- */ -/* File : components.css ------------------------------------------------- */ -/* feeder infos animation */ -.sld-arrow-in { - offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('')); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; -} -.sld-arrow-out { - offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('')); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; -} -@keyframes move { - to { - offset-distance: 100%; - } -} -/* Enable arrows animation */ -.sld-arrow-in-animation { --sld-arrow-offset-path: path('M 0,-10 0,10') } -.sld-arrow-out-animation { --sld-arrow-offset-path: path('M 0,10 0,-10') } -/* Set arrows animation speed (1: the slowest -> 3: the fastest) */ -.sld-arrow-animation-speed-1 { --sld-arrow-animation-duration: 3s } -.sld-arrow-animation-speed-2 { --sld-arrow-animation-duration: 2s } -.sld-arrow-animation-speed-3 { --sld-arrow-animation-duration: 1s } ]]> @@ -168,7 +143,7 @@ bbs - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestSldClassSubstation.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestSldClassSubstation.svg index f41f0e908..c6ed56fbe 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestSldClassSubstation.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestSldClassSubstation.svg @@ -146,7 +146,7 @@ bbs1 - + @@ -190,7 +190,7 @@ l - + @@ -238,7 +238,7 @@ bbs2 - + @@ -282,7 +282,7 @@ g - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestSldClassVl.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestSldClassVl.svg index 5c6f1d03b..3cbf2b91e 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestSldClassVl.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestSldClassVl.svg @@ -143,7 +143,7 @@ bbs1 - + @@ -187,7 +187,7 @@ l - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/consecutive_shunts.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/consecutive_shunts.svg index 8a893d517..6a14ba41e 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/consecutive_shunts.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/consecutive_shunts.svg @@ -163,7 +163,7 @@ BF - + @@ -352,7 +352,7 @@ 19 - + @@ -517,7 +517,7 @@ 5 - + @@ -677,7 +677,7 @@ 45 - + @@ -881,7 +881,7 @@ 29 - + @@ -921,7 +921,7 @@ 2 - + @@ -965,7 +965,7 @@ FP - + @@ -1000,7 +1000,7 @@ FX_ONE - + @@ -1043,7 +1043,7 @@ FV_ONE - + @@ -1083,7 +1083,7 @@ 37 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/feederInfoTest.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/feederInfoTest.svg index e23022f8c..5d39cf9df 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/feederInfoTest.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/feederInfoTest.svg @@ -177,7 +177,7 @@ - + @@ -243,7 +243,7 @@ Converter1 - + @@ -287,7 +287,7 @@ Filter 1 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/noComponentsOnBus.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/noComponentsOnBus.svg index 1b4acdeb4..7c3eba75b 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/noComponentsOnBus.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/noComponentsOnBus.svg @@ -177,7 +177,7 @@ - + @@ -255,7 +255,7 @@ Converter1 - + @@ -299,7 +299,7 @@ Filter 1 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_substation.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_substation.svg index 9388c6675..e5c94cb1f 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_substation.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_substation.svg @@ -82,7 +82,7 @@ bbs1 - + @@ -116,7 +116,7 @@ l - + @@ -147,7 +147,7 @@ 2WT_1 - + @@ -185,7 +185,7 @@ bbs2 - + @@ -216,7 +216,7 @@ 2WT_2 - + @@ -254,7 +254,7 @@ bbs3 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_vl2.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_vl2.svg index 75d60c7b8..b980654a3 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_vl2.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_vl2.svg @@ -79,7 +79,7 @@ bbs2 - + @@ -112,7 +112,7 @@ 2WT_2 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_vl3.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_vl3.svg index 29ffaafcc..7daef2f2a 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_vl3.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/nominal_voltage_style_vl3.svg @@ -79,7 +79,7 @@ bbs3 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/switchesOnBus.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/switchesOnBus.svg index 81ebf3714..b91a65a1d 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/switchesOnBus.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/switchesOnBus.svg @@ -177,7 +177,7 @@ - + @@ -243,7 +243,7 @@ Converter1 - + @@ -284,7 +284,7 @@ Filter 1 - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/topological_style_substation.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/topological_style_substation.svg index 35a9affba..b9827dc4b 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/topological_style_substation.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/topological_style_substation.svg @@ -146,7 +146,7 @@ bbs1 - + @@ -190,7 +190,7 @@ l - + @@ -231,7 +231,7 @@ 2WT_1 - + @@ -279,7 +279,7 @@ bbs2 - + @@ -320,7 +320,7 @@ 2WT_2 - + @@ -368,7 +368,7 @@ bbs3 - + From 9a45b390bbb7c91750dc79ca60416d5edb2a462e Mon Sep 17 00:00:00 2001 From: Thomas ADAM Date: Thu, 16 Feb 2023 16:23:00 +0100 Subject: [PATCH 06/10] Add 2 thresholhs in AnimatedFeederInfoStyleProvider constructor Signed-off-by: Thomas ADAM --- .../sld/util/AnimatedFeederInfoStyleProvider.java | 12 +++++++++--- .../java/com/powsybl/sld/iidm/TestFeederInfos.java | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java index 2a9c485cd..418292419 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java @@ -29,8 +29,14 @@ public class AnimatedFeederInfoStyleProvider extends TopologicalStyleProvider { private static final String ARROW_ANIMATION_HIGH_SPEED = ARROW_ANIMATION + "-high-" + ARROW_SPEED; - public AnimatedFeederInfoStyleProvider(Network network) { + private final double threshold1; + + private final double threshold2; + + public AnimatedFeederInfoStyleProvider(Network network, double threshold1, double threshold2) { super(network); + this.threshold1 = threshold1; + this.threshold2 = threshold2; } @Override @@ -41,9 +47,9 @@ public List getFeederInfoStyles(FeederInfo info) { feederInfo.getRightLabel().ifPresent(label -> { double power = feederInfo.getValue(); if (!Double.isNaN(power) && Math.abs(power) > 0) { - if (Math.abs(power) > 1000) { + if (Math.abs(power) > threshold2) { styles.add(ARROW_ANIMATION_HIGH_SPEED); - } else if (Math.abs(power) > 500.0) { + } else if (Math.abs(power) > threshold1) { styles.add(ARROW_ANIMATION_NOMINAL_SPEED); } else { styles.add(ARROW_ANIMATION_LOW_SPEED); diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java index fae685159..5d4941dae 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java @@ -143,7 +143,7 @@ public List getFeederInfos(FeederNode node) { } }; - DiagramStyleProvider styleProvider = new AnimatedFeederInfoStyleProvider(network); + DiagramStyleProvider styleProvider = new AnimatedFeederInfoStyleProvider(network, 500, 1000); // build graph VoltageLevelGraph g = graphBuilder.buildVoltageLevelGraph(vl.getId()); From 7d860816500b23b49831964b380e7c8b9fd58d3b Mon Sep 17 00:00:00 2001 From: Thomas ADAM Date: Mon, 27 Feb 2023 09:52:56 +0100 Subject: [PATCH 07/10] Taking into account MR comments: nominal renamed to average Signed-off-by: Thomas ADAM --- .../com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java | 4 ++-- .../src/main/resources/animations.css | 2 +- .../src/test/resources/TestAnimatedFeederInfos.svg | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java index 418292419..98bcad5ce 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java @@ -25,7 +25,7 @@ public class AnimatedFeederInfoStyleProvider extends TopologicalStyleProvider { private static final String ARROW_ANIMATION_LOW_SPEED = ARROW_ANIMATION + "-low-" + ARROW_SPEED; - private static final String ARROW_ANIMATION_NOMINAL_SPEED = ARROW_ANIMATION + "-nominal-" + ARROW_SPEED; + private static final String ARROW_ANIMATION_AVERAGE_SPEED = ARROW_ANIMATION + "-average-" + ARROW_SPEED; private static final String ARROW_ANIMATION_HIGH_SPEED = ARROW_ANIMATION + "-high-" + ARROW_SPEED; @@ -50,7 +50,7 @@ public List getFeederInfoStyles(FeederInfo info) { if (Math.abs(power) > threshold2) { styles.add(ARROW_ANIMATION_HIGH_SPEED); } else if (Math.abs(power) > threshold1) { - styles.add(ARROW_ANIMATION_NOMINAL_SPEED); + styles.add(ARROW_ANIMATION_AVERAGE_SPEED); } else { styles.add(ARROW_ANIMATION_LOW_SPEED); } diff --git a/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css b/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css index fbdbf71e3..3000d1e01 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css +++ b/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css @@ -28,5 +28,5 @@ } /* Set arrows animation speed (1: the slowest -> 3: the fastest) */ .sld-arrow-animation-low-speed { --sld-arrow-animation-duration: 3s } -.sld-arrow-animation-nominal-speed { --sld-arrow-animation-duration: 2s } +.sld-arrow-animation-average-speed { --sld-arrow-animation-duration: 2s } .sld-arrow-animation-high-speed { --sld-arrow-animation-duration: 1s } diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg index df2a95841..1e5ac5ca2 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg @@ -120,7 +120,7 @@ } /* Set arrows animation speed (1: the slowest -> 3: the fastest) */ .sld-arrow-animation-low-speed { --sld-arrow-animation-duration: 3s } -.sld-arrow-animation-nominal-speed { --sld-arrow-animation-duration: 2s } +.sld-arrow-animation-average-speed { --sld-arrow-animation-duration: 2s } .sld-arrow-animation-high-speed { --sld-arrow-animation-duration: 1s } /* ----------------------------------------------------------------------- */ /* File : components.css ------------------------------------------------- */ @@ -229,7 +229,7 @@ - + 501 From 7a4087b4c479b6cf8618826b7bd37c76f5abe600 Mon Sep 17 00:00:00 2001 From: Thomas ADAM Date: Mon, 27 Feb 2023 11:58:08 +0100 Subject: [PATCH 08/10] Taking into account MR comments: do not apply offet on no speed animation Signed-off-by: Thomas ADAM --- .../util/AnimatedFeederInfoStyleProvider.java | 14 +++++-- .../src/main/resources/animations.css | 26 +++++++------ .../com/powsybl/sld/iidm/TestFeederInfos.java | 24 +++++++++++- .../resources/TestAnimatedFeederInfos.svg | 39 ++++++++++++------- 4 files changed, 73 insertions(+), 30 deletions(-) diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java index 98bcad5ce..c40588013 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java @@ -23,6 +23,8 @@ public class AnimatedFeederInfoStyleProvider extends TopologicalStyleProvider { private static final String ARROW_SPEED = "speed"; + private static final String ARROW_ANIMATION_NO_SPEED = ARROW_ANIMATION + "-no-" + ARROW_SPEED; + private static final String ARROW_ANIMATION_LOW_SPEED = ARROW_ANIMATION + "-low-" + ARROW_SPEED; private static final String ARROW_ANIMATION_AVERAGE_SPEED = ARROW_ANIMATION + "-average-" + ARROW_SPEED; @@ -45,17 +47,21 @@ public List getFeederInfoStyles(FeederInfo info) { if (info instanceof DirectionalFeederInfo) { DirectionalFeederInfo feederInfo = (DirectionalFeederInfo) info; feederInfo.getRightLabel().ifPresent(label -> { - double power = feederInfo.getValue(); - if (!Double.isNaN(power) && Math.abs(power) > 0) { - if (Math.abs(power) > threshold2) { + double value = Math.abs(feederInfo.getValue()); + if (!Double.isNaN(value) && value > 0) { + if (value > threshold2) { styles.add(ARROW_ANIMATION_HIGH_SPEED); - } else if (Math.abs(power) > threshold1) { + } else if (value > threshold1) { styles.add(ARROW_ANIMATION_AVERAGE_SPEED); } else { styles.add(ARROW_ANIMATION_LOW_SPEED); } + } else { + styles.add(ARROW_ANIMATION_NO_SPEED); } }); + } else { + styles.add(ARROW_ANIMATION_NO_SPEED); } return styles; } diff --git a/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css b/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css index 3000d1e01..5ce6ba2fc 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css +++ b/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css @@ -3,30 +3,32 @@ /* feeder info */ .sld-cell-direction-top .sld-arrow-in { offset-rotate: 0deg; - offset-path: path('M 0,-10 0,10'); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; + offset-path: var(--sld-arrow-offset-path, path('M 0,-10 0,10')); + animation: move var(--sld-arrow-animation-parameters, 0s); } .sld-cell-direction-top .sld-arrow-out { offset-rotate: 0deg; - offset-path: path('M 0,10 0,-10'); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; + offset-path: var(--sld-arrow-offset-path, path('M 0,10 0,-10')); + animation: move var(--sld-arrow-animation-parameters, 0s); } .sld-cell-direction-bottom .sld-arrow-in { offset-rotate: 0deg; - offset-path: path('M 0,10 0,-10'); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; + offset-path: var(--sld-arrow-offset-path, path('M 0,10 0,-10')); + animation: move var(--sld-arrow-animation-parameters, 0s); } .sld-cell-direction-bottom .sld-arrow-out { offset-rotate: 0deg; - offset-path: path('M 0,-10 0,10'); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; + offset-path: var(--sld-arrow-offset-path, path('M 0,-10 0,10')); + animation: move var(--sld-arrow-animation-parameters, 0s); } @keyframes move { to { offset-distance: 100%; } } -/* Set arrows animation speed (1: the slowest -> 3: the fastest) */ -.sld-arrow-animation-low-speed { --sld-arrow-animation-duration: 3s } -.sld-arrow-animation-average-speed { --sld-arrow-animation-duration: 2s } -.sld-arrow-animation-high-speed { --sld-arrow-animation-duration: 1s } + +/* Set arrows animation speeds */ +.sld-arrow-animation-low-speed { --sld-arrow-animation-parameters: 3s infinite linear } +.sld-arrow-animation-average-speed { --sld-arrow-animation-parameters: 2s infinite linear } +.sld-arrow-animation-high-speed { --sld-arrow-animation-parameters: 1s infinite linear } +.sld-arrow-animation-no-speed { --sld-arrow-offset-path: path('') } diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java index 5d4941dae..c2d825dab 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java @@ -138,7 +138,29 @@ public List getFeederInfos(FeederNode node) { } else { return Arrays.asList( new DirectionalFeederInfo(ARROW_ACTIVE, l2.getTerminal().getP(), valueFormatter::formatPower, null), - new DirectionalFeederInfo(ARROW_REACTIVE, l2.getTerminal().getQ(), valueFormatter::formatPower, null)); + new DirectionalFeederInfo(ARROW_REACTIVE, l2.getTerminal().getQ(), valueFormatter::formatPower, null), + new DirectionalFeederInfo(ARROW_REACTIVE, Double.NaN, valueFormatter::formatPower, null), + new FeederInfo() { + @Override + public String getUserDefinedId() { + return null; + } + + @Override + public String getComponentType() { + return ARROW_ACTIVE; + } + + @Override + public Optional getLeftLabel() { + return Optional.of("Left"); + } + + @Override + public Optional getRightLabel() { + return Optional.of("Right"); + } + }); } } }; diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg index 1e5ac5ca2..015a8f68f 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg @@ -95,33 +95,35 @@ /* feeder info */ .sld-cell-direction-top .sld-arrow-in { offset-rotate: 0deg; - offset-path: path('M 0,-10 0,10'); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; + offset-path: var(--sld-arrow-offset-path, path('M 0,-10 0,10')); + animation: move var(--sld-arrow-animation-parameters, 0s); } .sld-cell-direction-top .sld-arrow-out { offset-rotate: 0deg; - offset-path: path('M 0,10 0,-10'); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; + offset-path: var(--sld-arrow-offset-path, path('M 0,10 0,-10')); + animation: move var(--sld-arrow-animation-parameters, 0s); } .sld-cell-direction-bottom .sld-arrow-in { offset-rotate: 0deg; - offset-path: path('M 0,10 0,-10'); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; + offset-path: var(--sld-arrow-offset-path, path('M 0,10 0,-10')); + animation: move var(--sld-arrow-animation-parameters, 0s); } .sld-cell-direction-bottom .sld-arrow-out { offset-rotate: 0deg; - offset-path: path('M 0,-10 0,10'); - animation: move var(--sld-arrow-animation-duration, 0s) linear infinite; + offset-path: var(--sld-arrow-offset-path, path('M 0,-10 0,10')); + animation: move var(--sld-arrow-animation-parameters, 0s); } @keyframes move { to { offset-distance: 100%; } } -/* Set arrows animation speed (1: the slowest -> 3: the fastest) */ -.sld-arrow-animation-low-speed { --sld-arrow-animation-duration: 3s } -.sld-arrow-animation-average-speed { --sld-arrow-animation-duration: 2s } -.sld-arrow-animation-high-speed { --sld-arrow-animation-duration: 1s } + +/* Set arrows animation speeds */ +.sld-arrow-animation-low-speed { --sld-arrow-animation-parameters: 3s infinite linear } +.sld-arrow-animation-average-speed { --sld-arrow-animation-parameters: 2s infinite linear } +.sld-arrow-animation-high-speed { --sld-arrow-animation-parameters: 1s infinite linear } +.sld-arrow-animation-no-speed { --sld-arrow-offset-path: path('') } /* ----------------------------------------------------------------------- */ /* File : components.css ------------------------------------------------- */ /* Stroke black */ @@ -234,11 +236,22 @@ 501 - + 0 + + + + + + + + + Right + Left + From 2f3b9ca4cb6762952a91c0e31cdd1b15f6a8696a Mon Sep 17 00:00:00 2001 From: Thomas ADAM Date: Thu, 23 Mar 2023 16:44:09 +0100 Subject: [PATCH 09/10] Use :not(.sld-arrow-animation-no-speed) instead of new CSS variable Signed-off-by: Thomas ADAM --- .../src/main/resources/animations.css | 17 ++++++++--------- .../com/powsybl/sld/iidm/TestFeederInfos.java | 3 +-- .../test/resources/TestAnimatedFeederInfos.svg | 17 ++++++++--------- .../TestCaseKeepFictitiousSwitchNode.svg | 2 +- .../TestCaseRemoveFictitiousSwitchNode.svg | 2 +- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css b/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css index 5ce6ba2fc..43f9adf39 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css +++ b/single-line-diagram/single-line-diagram-core/src/main/resources/animations.css @@ -1,24 +1,24 @@ /* ----------------------------------------------------------------------- */ /* File : animations.css ------------------------------------------------- */ /* feeder info */ -.sld-cell-direction-top .sld-arrow-in { +.sld-cell-direction-top :not(.sld-arrow-animation-no-speed) .sld-arrow-in { offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('M 0,-10 0,10')); + offset-path: path('M 0,-10 0,10'); animation: move var(--sld-arrow-animation-parameters, 0s); } -.sld-cell-direction-top .sld-arrow-out { +.sld-cell-direction-top :not(.sld-arrow-animation-no-speed) .sld-arrow-out { offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('M 0,10 0,-10')); + offset-path: path('M 0,10 0,-10'); animation: move var(--sld-arrow-animation-parameters, 0s); } -.sld-cell-direction-bottom .sld-arrow-in { +.sld-cell-direction-bottom :not(.sld-arrow-animation-no-speed) .sld-arrow-in { offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('M 0,10 0,-10')); + offset-path: path('M 0,10 0,-10'); animation: move var(--sld-arrow-animation-parameters, 0s); } -.sld-cell-direction-bottom .sld-arrow-out { +.sld-cell-direction-bottom :not(.sld-arrow-animation-no-speed) .sld-arrow-out { offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('M 0,-10 0,10')); + offset-path: path('M 0,-10 0,10'); animation: move var(--sld-arrow-animation-parameters, 0s); } @keyframes move { @@ -31,4 +31,3 @@ .sld-arrow-animation-low-speed { --sld-arrow-animation-parameters: 3s infinite linear } .sld-arrow-animation-average-speed { --sld-arrow-animation-parameters: 2s infinite linear } .sld-arrow-animation-high-speed { --sld-arrow-animation-parameters: 1s infinite linear } -.sld-arrow-animation-no-speed { --sld-arrow-offset-path: path('') } diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java index c2d825dab..4d043680f 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java @@ -122,8 +122,7 @@ public void testAnimation() { network.getLoad("l2").getTerminal().setQ(0.0); // Enable animation - layoutParameters.setFeederInfosIntraMargin(20) - .setEnableFeederInfosAnimation(true); + layoutParameters.setFeederInfosIntraMargin(20); DiagramLabelProvider labelProvider = new DefaultDiagramLabelProvider(network, componentLibrary, layoutParameters) { @Override diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg index 015a8f68f..bca09d7cf 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestAnimatedFeederInfos.svg @@ -93,24 +93,24 @@ /* ----------------------------------------------------------------------- */ /* File : animations.css ------------------------------------------------- */ /* feeder info */ -.sld-cell-direction-top .sld-arrow-in { +.sld-cell-direction-top :not(.sld-arrow-animation-no-speed) .sld-arrow-in { offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('M 0,-10 0,10')); + offset-path: path('M 0,-10 0,10'); animation: move var(--sld-arrow-animation-parameters, 0s); } -.sld-cell-direction-top .sld-arrow-out { +.sld-cell-direction-top :not(.sld-arrow-animation-no-speed) .sld-arrow-out { offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('M 0,10 0,-10')); + offset-path: path('M 0,10 0,-10'); animation: move var(--sld-arrow-animation-parameters, 0s); } -.sld-cell-direction-bottom .sld-arrow-in { +.sld-cell-direction-bottom :not(.sld-arrow-animation-no-speed) .sld-arrow-in { offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('M 0,10 0,-10')); + offset-path: path('M 0,10 0,-10'); animation: move var(--sld-arrow-animation-parameters, 0s); } -.sld-cell-direction-bottom .sld-arrow-out { +.sld-cell-direction-bottom :not(.sld-arrow-animation-no-speed) .sld-arrow-out { offset-rotate: 0deg; - offset-path: var(--sld-arrow-offset-path, path('M 0,-10 0,10')); + offset-path: path('M 0,-10 0,10'); animation: move var(--sld-arrow-animation-parameters, 0s); } @keyframes move { @@ -123,7 +123,6 @@ .sld-arrow-animation-low-speed { --sld-arrow-animation-parameters: 3s infinite linear } .sld-arrow-animation-average-speed { --sld-arrow-animation-parameters: 2s infinite linear } .sld-arrow-animation-high-speed { --sld-arrow-animation-parameters: 1s infinite linear } -.sld-arrow-animation-no-speed { --sld-arrow-offset-path: path('') } /* ----------------------------------------------------------------------- */ /* File : components.css ------------------------------------------------- */ /* Stroke black */ diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseKeepFictitiousSwitchNode.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseKeepFictitiousSwitchNode.svg index 3ed10e799..ad4ef3148 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseKeepFictitiousSwitchNode.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseKeepFictitiousSwitchNode.svg @@ -143,7 +143,7 @@ bbs - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseRemoveFictitiousSwitchNode.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseRemoveFictitiousSwitchNode.svg index 673dd8c08..d289e9f18 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseRemoveFictitiousSwitchNode.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestCaseRemoveFictitiousSwitchNode.svg @@ -143,7 +143,7 @@ bbs - + From 0d8083ae4e11dd7cbf4cc604d08e11555b0b7471 Mon Sep 17 00:00:00 2001 From: Thomas ADAM Date: Mon, 27 Mar 2023 17:55:09 +0200 Subject: [PATCH 10/10] Taking into account PR comments on typo Signed-off-by: Thomas ADAM --- .../com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java | 3 ++- .../src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java index c40588013..c71e2cecc 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.java @@ -1,8 +1,9 @@ /** - * Copyright (c) 2019, RTE (http://www.rte-france.com) + * Copyright (c) 2023, RTE (http://www.rte-france.com) * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * SPDX-License-Identifier: MPL-2.0 */ package com.powsybl.sld.util; diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java index 4d043680f..9a8a53d44 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestFeederInfos.java @@ -121,7 +121,6 @@ public void testAnimation() { network.getLoad("l2").getTerminal().setP(501.0); network.getLoad("l2").getTerminal().setQ(0.0); - // Enable animation layoutParameters.setFeederInfosIntraMargin(20); DiagramLabelProvider labelProvider = new DefaultDiagramLabelProvider(network, componentLibrary, layoutParameters) {