From fe1aef32c5d3ec170478f950b2f3daf394a8d533 Mon Sep 17 00:00:00 2001 From: Sophie Frasnedo Date: Thu, 16 Mar 2023 16:07:26 +0100 Subject: [PATCH] first ideas to add an unknown component Signed-off-by: Sophie Frasnedo --- .../sld/library/ComponentTypeName.java | 1 + .../com/powsybl/sld/svg/DefaultSVGWriter.java | 7 ++--- .../ConvergenceLibrary/components.css | 1 + .../ConvergenceLibrary/components.json | 29 ++++++++++++++++++ .../FlatDesignLibrary/components.css | 1 + .../FlatDesignLibrary/components.json | 30 +++++++++++++++++++ 6 files changed, 65 insertions(+), 4 deletions(-) diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/library/ComponentTypeName.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/library/ComponentTypeName.java index a1110f3a6..5fa5f9c6d 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/library/ComponentTypeName.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/library/ComponentTypeName.java @@ -32,6 +32,7 @@ public final class ComponentTypeName { public static final String DANGLING_LINE = "DANGLING_LINE"; public static final String PHASE_SHIFT_TRANSFORMER = "PHASE_SHIFT_TRANSFORMER"; public static final String PHASE_SHIFT_TRANSFORMER_LEG = "PHASE_SHIFT_TRANSFORMER_LEG"; + public static final String UNKNOWN_COMPONENT = "UNKNOWN_COMPONENT"; private ComponentTypeName() { throw new AssertionError(); 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..785bc1f79 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 @@ -8,10 +8,7 @@ import com.powsybl.diagram.util.ValueFormatter; import com.powsybl.sld.layout.LayoutParameters; -import com.powsybl.sld.library.AnchorPoint; -import com.powsybl.sld.library.Component; -import com.powsybl.sld.library.ComponentLibrary; -import com.powsybl.sld.library.ComponentSize; +import com.powsybl.sld.library.*; import com.powsybl.sld.model.cells.Cell; import com.powsybl.sld.model.coordinate.Direction; import com.powsybl.sld.model.coordinate.Orientation; @@ -573,6 +570,8 @@ protected void incorporateComponents(String prefixId, Graph graph, Node node, Po transformComponent(node, shift, g); if (componentLibrary.getSvgElements(componentType) != null) { insertComponentSVGIntoDocumentSVG(prefixId, componentType, g, graph, node, labelProvider, styleProvider); + } else if (!(componentType.equals(PHASE_SHIFT_TRANSFORMER_LEG) || componentType.equals(TWO_WINDINGS_TRANSFORMER_LEG) || componentType.equals(THREE_WINDINGS_TRANSFORMER_LEG) || componentType.equals(DANGLING_LINE) || componentType.equals(BUSBAR_SECTION))) { + insertComponentSVGIntoDocumentSVG(prefixId, UNKNOWN_COMPONENT, g, graph, node, labelProvider, styleProvider); } } diff --git a/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.css b/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.css index 94536e456..95cafd7ed 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.css +++ b/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.css @@ -29,6 +29,7 @@ .sld-node {stroke: none; fill: black} .sld-flash {stroke: none; fill: black} .sld-lock {stroke: none; fill: black} +.sld-unknown {stroke: none; fill: black} /* Fonts */ .sld-label {stroke: none; fill: black; font: 8px serif} .sld-angle, .sld-voltage {font: 10px serif} diff --git a/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.json b/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.json index 01bfda11b..9afe99820 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.json +++ b/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.json @@ -360,6 +360,35 @@ } ], "styleClass" : "sld-lock" }, { + "type" : "UNKNOWN_COMPONENT", + "anchorPoints" : [ { + "x" : 6.0, + "y" : 0.0, + "orientation" : "VERTICAL" + }, { + "x" : 6.0, + "y" : 12.0, + "orientation" : "VERTICAL" + }, { + "x" : 0.0, + "y" : 6.0, + "orientation" : "HORIZONTAL" + }, { + "x" : 12.0, + "y" : 6.0, + "orientation" : "HORIZONTAL" + } ], + "size" : { + "width" : 12.0, + "height" : 12.0 + }, + "transformations" : {}, + "subComponents" : [ { + "name" : "UNKNOWN_COMPONENT", + "fileName" : "unknown-component.svg" + } ], + "styleClass" : "sld-unknown" + },{ "type" : "ARROW_ACTIVE", "size" : { "width" : 10.0, diff --git a/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.css b/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.css index 6d8d2232a..6b702b27e 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.css +++ b/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.css @@ -17,6 +17,7 @@ .sld-node {stroke: none; fill: black} .sld-flash {stroke: none; fill: black} .sld-lock {stroke: none; fill: black} +.sld-unknown {stroke: none; fill: black} /* Fonts */ .sld-label {stroke: none; fill: black; font: 8px serif} .sld-angle, .sld-voltage {font: 10px serif} diff --git a/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.json b/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.json index deea510f2..55c5dc196 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.json +++ b/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.json @@ -428,6 +428,36 @@ ], "styleClass": "sld-node" }, + { + "type" : "UNKNOWN_COMPONENT", + "anchorPoints" : [ { + "x" : 6.0, + "y" : 0.0, + "orientation" : "VERTICAL" + }, { + "x" : 6.0, + "y" : 12.0, + "orientation" : "VERTICAL" + }, { + "x" : 0.0, + "y" : 6.0, + "orientation" : "HORIZONTAL" + }, { + "x" : 12.0, + "y" : 6.0, + "orientation" : "HORIZONTAL" + } ], + "size" : { + "width" : 12.0, + "height" : 12.0 + }, + "transformations" : {}, + "subComponents" : [ { + "name" : "UNKNOWN_COMPONENT", + "fileName" : "unknown-component.svg" + } ], + "styleClass" : "sld-unknown" + }, { "type": "ARROW_ACTIVE", "size": {