From 39ad85d8d9622d04203d0dd0e15f0962ffa750d5 Mon Sep 17 00:00:00 2001 From: Florian Dupuy Date: Fri, 25 Nov 2022 12:49:02 +0100 Subject: [PATCH 1/6] Format metadata using Locale.US Signed-off-by: Florian Dupuy --- .../main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java index c0c09c2fa..066480e2c 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java @@ -12,6 +12,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import java.util.Locale; /** * @author Luma Zamarreño @@ -51,7 +52,7 @@ void write(DiagramMetadata.WritingContext ctx) throws XMLStreamException { } private static String formatted(double value) { - return String.format(POSITION_COORD_FORMAT, value); + return String.format(Locale.US, POSITION_COORD_FORMAT, value); } static class Reader implements MetadataItemReader { From 31dedc542cd8cbacb222a60e31d1cef39e46e70e Mon Sep 17 00:00:00 2001 From: Florian Dupuy Date: Fri, 25 Nov 2022 13:00:44 +0100 Subject: [PATCH 2/6] BusNode and node metadata differientated Signed-off-by: Florian Dupuy --- .../svg/metadata/AbstractMetadataItem.java | 3 +- .../nad/svg/metadata/BusNodeMetadata.java | 32 +++++++++++++++++++ .../nad/svg/metadata/DiagramMetadata.java | 12 ++----- .../nad/svg/metadata/NodeMetadata.java | 9 ------ 4 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java index c9d33dc71..1dbc53618 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java @@ -33,8 +33,7 @@ public Identifiable getIdentifiable() { abstract String getElementName(); void write(DiagramMetadata.WritingContext ctx) throws XMLStreamException { - String elementName = ctx.overrideElementName ? ctx.elementName : getElementName(); - ctx.writer.writeEmptyElement(DiagramMetadata.METADATA_PREFIX, elementName, DiagramMetadata.METADATA_NAMESPACE_URI); + ctx.writer.writeEmptyElement(DiagramMetadata.METADATA_PREFIX, getElementName(), DiagramMetadata.METADATA_NAMESPACE_URI); ctx.writer.writeAttribute(DIAGRAM_ID_ATTRIBUTE, ctx.diagramIdToSvgId.apply(identifiable.getDiagramId())); ctx.writer.writeAttribute(EQUIPMENT_ID_ATTRIBUTE, identifiable.getEquipmentId()); } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java new file mode 100644 index 000000000..28e7e119f --- /dev/null +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java @@ -0,0 +1,32 @@ +package com.powsybl.nad.svg.metadata; + +import com.powsybl.nad.model.Identifiable; + +import javax.xml.stream.XMLStreamReader; + +public class BusNodeMetadata extends AbstractMetadataItem { + private static final String ELEMENT_NAME = "busNode"; + + public BusNodeMetadata(Identifiable identifiable) { + super(identifiable); + } + + @Override + String getElementName() { + return ELEMENT_NAME; + } + + static class Reader implements AbstractMetadataItem.MetadataItemReader { + @Override + public String getElementName() { + return ELEMENT_NAME; + } + + public BusNodeMetadata read(XMLStreamReader reader) { + Identifiable deserializedIdentifiable = readIdentifiable(reader); + // Read busNode-specific metadata + // ... + return new BusNodeMetadata(deserializedIdentifiable); + } + } +} diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java index ba9d598ba..22208825c 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java @@ -35,7 +35,7 @@ public class DiagramMetadata { private static final String METADATA_NODES_ELEMENT_NAME = "nodes"; private static final String METADATA_EDGES_ELEMENT_NAME = "edges"; - private final List busNodesMetadata = new ArrayList<>(); + private final List busNodesMetadata = new ArrayList<>(); private final List nodesMetadata = new ArrayList<>(); private final List edgesMetadata = new ArrayList<>(); @@ -50,7 +50,7 @@ public static DiagramMetadata readXml(XMLStreamReader reader) throws XMLStreamEx String token = reader.getLocalName(); switch (token) { case METADATA_BUS_NODES_ELEMENT_NAME: - readCollection(metadata.busNodesMetadata, METADATA_BUS_NODES_ELEMENT_NAME, NodeMetadata.Reader.forBusNodes(), reader); + readCollection(metadata.busNodesMetadata, METADATA_BUS_NODES_ELEMENT_NAME, new BusNodeMetadata.Reader(), reader); break; case METADATA_NODES_ELEMENT_NAME: readCollection(metadata.nodesMetadata, METADATA_NODES_ELEMENT_NAME, new NodeMetadata.Reader(), reader); @@ -80,8 +80,6 @@ private static diagramIdToSvgId; - boolean overrideElementName = false; - String elementName; WritingContext(UnaryOperator diagramIdToSvgId, XMLStreamWriter writer) { this.writer = writer; @@ -101,11 +99,7 @@ public void writeXml(WritingContext ctx) throws XMLStreamException { ctx.writer.writeStartElement(METADATA_PREFIX, METADATA_DIAGRAM_ELEMENT_NAME, METADATA_NAMESPACE_URI); ctx.writer.writeNamespace(METADATA_PREFIX, METADATA_NAMESPACE_URI); - ctx.overrideElementName = true; - ctx.elementName = NodeMetadata.getBusNodeElementName(); writeCollection(busNodesMetadata, METADATA_BUS_NODES_ELEMENT_NAME, ctx); - ctx.overrideElementName = false; - writeCollection(nodesMetadata, METADATA_NODES_ELEMENT_NAME, ctx); writeCollection(edgesMetadata, METADATA_EDGES_ELEMENT_NAME, ctx); ctx.writer.writeEndElement(); @@ -127,7 +121,7 @@ private static void writeCollection( } public void addBusNode(BusNode node) { - busNodesMetadata.add(new NodeMetadata(node, node.getPosition())); + busNodesMetadata.add(new BusNodeMetadata(node)); } public void addNode(Node node) { diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java index 066480e2c..95d8cb939 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java @@ -21,7 +21,6 @@ public class NodeMetadata extends AbstractMetadataItem { private final Point position; private static final String ELEMENT_NAME = "node"; - private static final String BUS_NODE_ELEMENT_NAME = "busNode"; private static final String POSITION_X_ATTRIBUTE = "x"; private static final String POSITION_Y_ATTRIBUTE = "y"; private static final String POSITION_COORD_FORMAT = "%.2f"; @@ -31,10 +30,6 @@ public NodeMetadata(Identifiable identifiable, Point position) { this.position = position; } - public static String getBusNodeElementName() { - return BUS_NODE_ELEMENT_NAME; - } - public Point getPosition() { return position; } @@ -63,10 +58,6 @@ static class Reader implements MetadataItemReader { this(ELEMENT_NAME); } - static Reader forBusNodes() { - return new Reader(BUS_NODE_ELEMENT_NAME); - } - private Reader(String elementName) { this.elementName = elementName; } From bb4d9526702289ddb5da79b082910ab628d397e7 Mon Sep 17 00:00:00 2001 From: Florian Dupuy Date: Fri, 25 Nov 2022 13:45:46 +0100 Subject: [PATCH 3/6] Update unit tests references Signed-off-by: Florian Dupuy --- .../src/test/resources/3wt.svg | 6 +- .../src/test/resources/3wt_disconnected.svg | 4 +- .../3wt_disconnected_topological.svg | 4 +- .../src/test/resources/3wt_partial.svg | 6 +- .../src/test/resources/IEEE_118_bus.svg | 236 +++++++++--------- .../test/resources/IEEE_118_bus_partial.svg | 64 ++--- .../IEEE_118_bus_partial_non_connected.svg | 54 ++-- .../src/test/resources/IEEE_14_bus.svg | 28 +-- .../resources/IEEE_14_bus_disconnection.svg | 26 +- .../test/resources/IEEE_14_bus_fictitious.svg | 28 +-- .../test/resources/IEEE_14_bus_text_nodes.svg | 28 +-- .../test/resources/IEEE_14_id_prefixed.svg | 28 +-- .../src/test/resources/IEEE_24_bus.svg | 48 ++-- .../src/test/resources/IEEE_30_bus.svg | 60 ++--- .../src/test/resources/IEEE_57_bus.svg | 114 ++++----- .../src/test/resources/current_limits.svg | 4 +- .../src/test/resources/detailed_text_node.svg | 4 +- .../detailed_text_node_no_legend.svg | 4 +- .../diamond-spring-repulsion-factor-0.0.svg | 30 +-- .../diamond-spring-repulsion-factor-0.2.svg | 30 +-- .../resources/edge_info_double_labels.svg | 6 +- .../resources/edge_info_missing_label.svg | 4 +- .../edge_info_perpendicular_label.svg | 4 +- .../src/test/resources/edge_info_shift.svg | 10 +- .../src/test/resources/hvdc-vl-depth-1.svg | 4 +- .../src/test/resources/hvdc.svg | 10 +- .../test/resources/parallel_transformers.svg | 6 +- .../src/test/resources/simple-eu-loop100.svg | 24 +- .../src/test/resources/simple-eu-loop80.svg | 24 +- .../src/test/resources/simple-eu.svg | 24 +- .../src/test/resources/vl_description_id.svg | 4 +- .../resources/vl_description_substation.svg | 4 +- .../vl_description_substation_id.svg | 4 +- .../src/test/resources/voltage_limits.svg | 6 +- 34 files changed, 470 insertions(+), 470 deletions(-) diff --git a/network-area-diagram/src/test/resources/3wt.svg b/network-area-diagram/src/test/resources/3wt.svg index 724109e35..b2c1d145a 100644 --- a/network-area-diagram/src/test/resources/3wt.svg +++ b/network-area-diagram/src/test/resources/3wt.svg @@ -49,9 +49,9 @@ - - - + + + diff --git a/network-area-diagram/src/test/resources/3wt_disconnected.svg b/network-area-diagram/src/test/resources/3wt_disconnected.svg index e58d01e75..7c27cf99e 100644 --- a/network-area-diagram/src/test/resources/3wt_disconnected.svg +++ b/network-area-diagram/src/test/resources/3wt_disconnected.svg @@ -49,8 +49,8 @@ - - + + diff --git a/network-area-diagram/src/test/resources/3wt_disconnected_topological.svg b/network-area-diagram/src/test/resources/3wt_disconnected_topological.svg index 959c7a218..8436f2775 100644 --- a/network-area-diagram/src/test/resources/3wt_disconnected_topological.svg +++ b/network-area-diagram/src/test/resources/3wt_disconnected_topological.svg @@ -114,8 +114,8 @@ - - + + diff --git a/network-area-diagram/src/test/resources/3wt_partial.svg b/network-area-diagram/src/test/resources/3wt_partial.svg index 1fe57d8eb..cb6853f40 100644 --- a/network-area-diagram/src/test/resources/3wt_partial.svg +++ b/network-area-diagram/src/test/resources/3wt_partial.svg @@ -49,9 +49,9 @@ - - - + + + diff --git a/network-area-diagram/src/test/resources/IEEE_118_bus.svg b/network-area-diagram/src/test/resources/IEEE_118_bus.svg index c5b9fad27..521043de7 100644 --- a/network-area-diagram/src/test/resources/IEEE_118_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_118_bus.svg @@ -114,124 +114,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_118_bus_partial.svg b/network-area-diagram/src/test/resources/IEEE_118_bus_partial.svg index 8e841fab6..86363bf16 100644 --- a/network-area-diagram/src/test/resources/IEEE_118_bus_partial.svg +++ b/network-area-diagram/src/test/resources/IEEE_118_bus_partial.svg @@ -114,38 +114,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_118_bus_partial_non_connected.svg b/network-area-diagram/src/test/resources/IEEE_118_bus_partial_non_connected.svg index 0077dc45e..6cf448be5 100644 --- a/network-area-diagram/src/test/resources/IEEE_118_bus_partial_non_connected.svg +++ b/network-area-diagram/src/test/resources/IEEE_118_bus_partial_non_connected.svg @@ -114,33 +114,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus.svg b/network-area-diagram/src/test/resources/IEEE_14_bus.svg index 450bdae60..4015482e4 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus.svg @@ -49,20 +49,20 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus_disconnection.svg b/network-area-diagram/src/test/resources/IEEE_14_bus_disconnection.svg index 1544fbfef..2a48b4b48 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus_disconnection.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus_disconnection.svg @@ -49,19 +49,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus_fictitious.svg b/network-area-diagram/src/test/resources/IEEE_14_bus_fictitious.svg index 29eb54b98..c756073f0 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus_fictitious.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus_fictitious.svg @@ -49,20 +49,20 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus_text_nodes.svg b/network-area-diagram/src/test/resources/IEEE_14_bus_text_nodes.svg index e38645e32..145cb9f16 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus_text_nodes.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus_text_nodes.svg @@ -49,20 +49,20 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_14_id_prefixed.svg b/network-area-diagram/src/test/resources/IEEE_14_id_prefixed.svg index 97848eb04..b359b6b84 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_id_prefixed.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_id_prefixed.svg @@ -49,20 +49,20 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_24_bus.svg b/network-area-diagram/src/test/resources/IEEE_24_bus.svg index fc57dc3ef..fa7584d73 100644 --- a/network-area-diagram/src/test/resources/IEEE_24_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_24_bus.svg @@ -49,30 +49,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_30_bus.svg b/network-area-diagram/src/test/resources/IEEE_30_bus.svg index a0f96fed7..5156807c8 100644 --- a/network-area-diagram/src/test/resources/IEEE_30_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_30_bus.svg @@ -49,36 +49,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_57_bus.svg b/network-area-diagram/src/test/resources/IEEE_57_bus.svg index 3301f66ea..98d727433 100644 --- a/network-area-diagram/src/test/resources/IEEE_57_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_57_bus.svg @@ -114,63 +114,63 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/current_limits.svg b/network-area-diagram/src/test/resources/current_limits.svg index b25a4e57c..ee127b7a4 100644 --- a/network-area-diagram/src/test/resources/current_limits.svg +++ b/network-area-diagram/src/test/resources/current_limits.svg @@ -49,8 +49,8 @@ - - + + diff --git a/network-area-diagram/src/test/resources/detailed_text_node.svg b/network-area-diagram/src/test/resources/detailed_text_node.svg index 872a34a42..326bab53d 100644 --- a/network-area-diagram/src/test/resources/detailed_text_node.svg +++ b/network-area-diagram/src/test/resources/detailed_text_node.svg @@ -114,8 +114,8 @@ - - + + diff --git a/network-area-diagram/src/test/resources/detailed_text_node_no_legend.svg b/network-area-diagram/src/test/resources/detailed_text_node_no_legend.svg index 796af3c1b..eba7a6f66 100644 --- a/network-area-diagram/src/test/resources/detailed_text_node_no_legend.svg +++ b/network-area-diagram/src/test/resources/detailed_text_node_no_legend.svg @@ -114,8 +114,8 @@ - - + + diff --git a/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.0.svg b/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.0.svg index ee7581fb5..ab228c392 100644 --- a/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.0.svg +++ b/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.0.svg @@ -49,21 +49,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.2.svg b/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.2.svg index 663b705b6..7fab42be4 100644 --- a/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.2.svg +++ b/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.2.svg @@ -49,21 +49,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/edge_info_double_labels.svg b/network-area-diagram/src/test/resources/edge_info_double_labels.svg index 209dae544..05ccbef45 100644 --- a/network-area-diagram/src/test/resources/edge_info_double_labels.svg +++ b/network-area-diagram/src/test/resources/edge_info_double_labels.svg @@ -49,9 +49,9 @@ - - - + + + diff --git a/network-area-diagram/src/test/resources/edge_info_missing_label.svg b/network-area-diagram/src/test/resources/edge_info_missing_label.svg index 13b55872d..be3282a36 100644 --- a/network-area-diagram/src/test/resources/edge_info_missing_label.svg +++ b/network-area-diagram/src/test/resources/edge_info_missing_label.svg @@ -49,8 +49,8 @@ - - + + diff --git a/network-area-diagram/src/test/resources/edge_info_perpendicular_label.svg b/network-area-diagram/src/test/resources/edge_info_perpendicular_label.svg index 5750b5c4f..d4ec97582 100644 --- a/network-area-diagram/src/test/resources/edge_info_perpendicular_label.svg +++ b/network-area-diagram/src/test/resources/edge_info_perpendicular_label.svg @@ -49,8 +49,8 @@ - - + + diff --git a/network-area-diagram/src/test/resources/edge_info_shift.svg b/network-area-diagram/src/test/resources/edge_info_shift.svg index 40f9cb5a9..b47b80ae5 100644 --- a/network-area-diagram/src/test/resources/edge_info_shift.svg +++ b/network-area-diagram/src/test/resources/edge_info_shift.svg @@ -49,11 +49,11 @@ - - - - - + + + + + diff --git a/network-area-diagram/src/test/resources/hvdc-vl-depth-1.svg b/network-area-diagram/src/test/resources/hvdc-vl-depth-1.svg index bacdd4af2..d9deadd59 100644 --- a/network-area-diagram/src/test/resources/hvdc-vl-depth-1.svg +++ b/network-area-diagram/src/test/resources/hvdc-vl-depth-1.svg @@ -49,8 +49,8 @@ - - + + diff --git a/network-area-diagram/src/test/resources/hvdc.svg b/network-area-diagram/src/test/resources/hvdc.svg index ad5abb5bd..bf639ea24 100644 --- a/network-area-diagram/src/test/resources/hvdc.svg +++ b/network-area-diagram/src/test/resources/hvdc.svg @@ -49,11 +49,11 @@ - - - - - + + + + + diff --git a/network-area-diagram/src/test/resources/parallel_transformers.svg b/network-area-diagram/src/test/resources/parallel_transformers.svg index 2ac324e57..bc5e4ff30 100644 --- a/network-area-diagram/src/test/resources/parallel_transformers.svg +++ b/network-area-diagram/src/test/resources/parallel_transformers.svg @@ -49,9 +49,9 @@ - - - + + + diff --git a/network-area-diagram/src/test/resources/simple-eu-loop100.svg b/network-area-diagram/src/test/resources/simple-eu-loop100.svg index 1a9e59395..285e077d2 100644 --- a/network-area-diagram/src/test/resources/simple-eu-loop100.svg +++ b/network-area-diagram/src/test/resources/simple-eu-loop100.svg @@ -114,18 +114,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/simple-eu-loop80.svg b/network-area-diagram/src/test/resources/simple-eu-loop80.svg index d7fb16c75..8ebc7f023 100644 --- a/network-area-diagram/src/test/resources/simple-eu-loop80.svg +++ b/network-area-diagram/src/test/resources/simple-eu-loop80.svg @@ -114,18 +114,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/simple-eu.svg b/network-area-diagram/src/test/resources/simple-eu.svg index 68828dc6d..ff8929258 100644 --- a/network-area-diagram/src/test/resources/simple-eu.svg +++ b/network-area-diagram/src/test/resources/simple-eu.svg @@ -114,18 +114,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/vl_description_id.svg b/network-area-diagram/src/test/resources/vl_description_id.svg index f06d28fc3..7712d8691 100644 --- a/network-area-diagram/src/test/resources/vl_description_id.svg +++ b/network-area-diagram/src/test/resources/vl_description_id.svg @@ -114,8 +114,8 @@ - - + + diff --git a/network-area-diagram/src/test/resources/vl_description_substation.svg b/network-area-diagram/src/test/resources/vl_description_substation.svg index 99e26180d..3e5405257 100644 --- a/network-area-diagram/src/test/resources/vl_description_substation.svg +++ b/network-area-diagram/src/test/resources/vl_description_substation.svg @@ -114,8 +114,8 @@ - - + + diff --git a/network-area-diagram/src/test/resources/vl_description_substation_id.svg b/network-area-diagram/src/test/resources/vl_description_substation_id.svg index f2a877c36..1fea1bef1 100644 --- a/network-area-diagram/src/test/resources/vl_description_substation_id.svg +++ b/network-area-diagram/src/test/resources/vl_description_substation_id.svg @@ -114,8 +114,8 @@ - - + + diff --git a/network-area-diagram/src/test/resources/voltage_limits.svg b/network-area-diagram/src/test/resources/voltage_limits.svg index 7296fead6..302b96419 100644 --- a/network-area-diagram/src/test/resources/voltage_limits.svg +++ b/network-area-diagram/src/test/resources/voltage_limits.svg @@ -49,9 +49,9 @@ - - - + + + From fddf139de55a4fe5d1351c9b857dccd76e8f3d59 Mon Sep 17 00:00:00 2001 From: Florian Dupuy Date: Fri, 25 Nov 2022 13:46:34 +0100 Subject: [PATCH 4/6] Metadata: WriterContext to XmlStreamWriter & remove Identifiable Signed-off-by: Florian Dupuy --- .../java/com/powsybl/nad/svg/SvgWriter.java | 9 ++-- .../svg/metadata/AbstractMetadataItem.java | 53 +++++-------------- .../nad/svg/metadata/BusNodeMetadata.java | 9 ++-- .../nad/svg/metadata/DiagramMetadata.java | 52 ++++++------------ .../nad/svg/metadata/EdgeMetadata.java | 7 ++- .../nad/svg/metadata/NodeMetadata.java | 52 ++++++------------ 6 files changed, 57 insertions(+), 125 deletions(-) diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/SvgWriter.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/SvgWriter.java index 3cb97a186..36a66c92a 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/SvgWriter.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/SvgWriter.java @@ -786,12 +786,13 @@ private void addStyle(XMLStreamWriter writer) throws XMLStreamException { private void addMetadata(Graph graph, XMLStreamWriter writer) throws XMLStreamException { DiagramMetadata metadata = new DiagramMetadata(); - graph.getBusNodesStream().forEach(metadata::addBusNode); - graph.getNodesStream().forEach(metadata::addNode); - graph.getEdgesStream().forEach(metadata::addEdge); + graph.getBusNodesStream().forEach(busNode -> metadata.addBusNode(getPrefixedId(busNode.getDiagramId()), busNode.getEquipmentId())); + graph.getNodesStream().forEach(node -> metadata.addNode(getPrefixedId(node.getDiagramId()), node.getEquipmentId(), + getFormattedValue(node.getX()), getFormattedValue(node.getY()))); + graph.getEdgesStream().forEach(edge -> metadata.addEdge(getPrefixedId(edge.getDiagramId()), edge.getEquipmentId())); writer.writeStartElement(METADATA_ELEMENT_NAME); - metadata.writeXml(this::getPrefixedId, writer); + metadata.writeXml(writer); writer.writeEndElement(); } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java index 1dbc53618..28788edde 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java @@ -11,6 +11,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; import java.util.Optional; /** @@ -20,22 +21,20 @@ public abstract class AbstractMetadataItem { private static final String DIAGRAM_ID_ATTRIBUTE = "diagramId"; private static final String EQUIPMENT_ID_ATTRIBUTE = "equipmentId"; - private final Identifiable identifiable; + private final String svgId; + private final String equipmentId; - protected AbstractMetadataItem(Identifiable identifiable) { - this.identifiable = identifiable; - } - - public Identifiable getIdentifiable() { - return identifiable; + protected AbstractMetadataItem(String svgId, String equipmentId) { + this.svgId = svgId; + this.equipmentId = equipmentId; } abstract String getElementName(); - void write(DiagramMetadata.WritingContext ctx) throws XMLStreamException { - ctx.writer.writeEmptyElement(DiagramMetadata.METADATA_PREFIX, getElementName(), DiagramMetadata.METADATA_NAMESPACE_URI); - ctx.writer.writeAttribute(DIAGRAM_ID_ATTRIBUTE, ctx.diagramIdToSvgId.apply(identifiable.getDiagramId())); - ctx.writer.writeAttribute(EQUIPMENT_ID_ATTRIBUTE, identifiable.getEquipmentId()); + void write(XMLStreamWriter writer) throws XMLStreamException { + writer.writeEmptyElement(DiagramMetadata.METADATA_PREFIX, getElementName(), DiagramMetadata.METADATA_NAMESPACE_URI); + writer.writeAttribute(DIAGRAM_ID_ATTRIBUTE, svgId); + writer.writeAttribute(EQUIPMENT_ID_ATTRIBUTE, equipmentId); } interface MetadataItemReader { @@ -44,35 +43,11 @@ interface MetadataItemReader { I read(XMLStreamReader reader); } - static Identifiable readIdentifiable(XMLStreamReader reader) { - String diagramId = reader.getAttributeValue(null, DIAGRAM_ID_ATTRIBUTE); - String equipmentId = reader.getAttributeValue(null, EQUIPMENT_ID_ATTRIBUTE); - return new DeserializedIdentifiable(diagramId, equipmentId); + static String readDiagramId(XMLStreamReader reader) { + return reader.getAttributeValue(null, DIAGRAM_ID_ATTRIBUTE); } - static class DeserializedIdentifiable implements Identifiable { - - private final String diagramId; - private final String equipmentId; - - DeserializedIdentifiable(String diagramId, String equipmentId) { - this.diagramId = diagramId; - this.equipmentId = equipmentId; - } - - @Override - public String getDiagramId() { - return diagramId; - } - - @Override - public String getEquipmentId() { - return equipmentId; - } - - @Override - public Optional getName() { - return Optional.empty(); - } + static String readEquipmentId(XMLStreamReader reader) { + return reader.getAttributeValue(null, EQUIPMENT_ID_ATTRIBUTE); } } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java index 28e7e119f..053585025 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java @@ -7,8 +7,8 @@ public class BusNodeMetadata extends AbstractMetadataItem { private static final String ELEMENT_NAME = "busNode"; - public BusNodeMetadata(Identifiable identifiable) { - super(identifiable); + public BusNodeMetadata(String svgId, String equipmentId) { + super(svgId, equipmentId); } @Override @@ -23,10 +23,7 @@ public String getElementName() { } public BusNodeMetadata read(XMLStreamReader reader) { - Identifiable deserializedIdentifiable = readIdentifiable(reader); - // Read busNode-specific metadata - // ... - return new BusNodeMetadata(deserializedIdentifiable); + return new BusNodeMetadata(readDiagramId(reader), readEquipmentId(reader)); } } } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java index 22208825c..b28cb6169 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java @@ -77,58 +77,40 @@ private static diagramIdToSvgId; - - WritingContext(UnaryOperator diagramIdToSvgId, XMLStreamWriter writer) { - this.writer = writer; - this.diagramIdToSvgId = diagramIdToSvgId; - } - } - public void writeXml(XMLStreamWriter writer) throws XMLStreamException { - writeXml(new WritingContext(UnaryOperator.identity(), writer)); - } - - public void writeXml(UnaryOperator diagramIdToSvgId, XMLStreamWriter writer) throws XMLStreamException { - writeXml(new WritingContext(diagramIdToSvgId, writer)); - } - - public void writeXml(WritingContext ctx) throws XMLStreamException { - ctx.writer.writeStartElement(METADATA_PREFIX, METADATA_DIAGRAM_ELEMENT_NAME, METADATA_NAMESPACE_URI); - ctx.writer.writeNamespace(METADATA_PREFIX, METADATA_NAMESPACE_URI); + writer.writeStartElement(METADATA_PREFIX, METADATA_DIAGRAM_ELEMENT_NAME, METADATA_NAMESPACE_URI); + writer.writeNamespace(METADATA_PREFIX, METADATA_NAMESPACE_URI); - writeCollection(busNodesMetadata, METADATA_BUS_NODES_ELEMENT_NAME, ctx); - writeCollection(nodesMetadata, METADATA_NODES_ELEMENT_NAME, ctx); - writeCollection(edgesMetadata, METADATA_EDGES_ELEMENT_NAME, ctx); - ctx.writer.writeEndElement(); + writeCollection(busNodesMetadata, METADATA_BUS_NODES_ELEMENT_NAME, writer); + writeCollection(nodesMetadata, METADATA_NODES_ELEMENT_NAME, writer); + writeCollection(edgesMetadata, METADATA_EDGES_ELEMENT_NAME, writer); + writer.writeEndElement(); } private static void writeCollection( Collection items, String collectionElementName, - WritingContext ctx) throws XMLStreamException { + XMLStreamWriter writer) throws XMLStreamException { if (items.isEmpty()) { - ctx.writer.writeEmptyElement(METADATA_PREFIX, collectionElementName, METADATA_NAMESPACE_URI); + writer.writeEmptyElement(METADATA_PREFIX, collectionElementName, METADATA_NAMESPACE_URI); } else { - ctx.writer.writeStartElement(METADATA_PREFIX, collectionElementName, METADATA_NAMESPACE_URI); + writer.writeStartElement(METADATA_PREFIX, collectionElementName, METADATA_NAMESPACE_URI); for (M item : items) { - item.write(ctx); + item.write(writer); } - ctx.writer.writeEndElement(); + writer.writeEndElement(); } } - public void addBusNode(BusNode node) { - busNodesMetadata.add(new BusNodeMetadata(node)); + public void addBusNode(String svgId, String equipmentId) { + busNodesMetadata.add(new BusNodeMetadata(svgId, equipmentId)); } - public void addNode(Node node) { - nodesMetadata.add(new NodeMetadata(node, node.getPosition())); + public void addNode(String svgId, String equipmentId, String positionX, String positionY) { + nodesMetadata.add(new NodeMetadata(svgId, equipmentId, positionX, positionY)); } - public void addEdge(Edge edge) { - edgesMetadata.add(new EdgeMetadata(edge)); + public void addEdge(String svgId, String equipmentId) { + edgesMetadata.add(new EdgeMetadata(svgId, equipmentId)); } } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java index 983256f49..9af48048d 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java @@ -18,8 +18,8 @@ public class EdgeMetadata extends AbstractMetadataItem { private static final String ELEMENT_NAME = "edge"; - public EdgeMetadata(Identifiable identifiable) { - super(identifiable); + public EdgeMetadata(String svgId, String equipmentId) { + super(svgId, equipmentId); } @Override @@ -34,10 +34,9 @@ public String getElementName() { } public EdgeMetadata read(XMLStreamReader reader) { - Identifiable deserializedIdentifiable = readIdentifiable(reader); // Read edge-specific metadata // ... - return new EdgeMetadata(deserializedIdentifiable); + return new EdgeMetadata(readDiagramId(reader), readEquipmentId(reader)); } } } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java index 95d8cb939..860986548 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java @@ -12,26 +12,25 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; import java.util.Locale; /** * @author Luma Zamarreño */ public class NodeMetadata extends AbstractMetadataItem { - private final Point position; - private static final String ELEMENT_NAME = "node"; private static final String POSITION_X_ATTRIBUTE = "x"; private static final String POSITION_Y_ATTRIBUTE = "y"; private static final String POSITION_COORD_FORMAT = "%.2f"; - public NodeMetadata(Identifiable identifiable, Point position) { - super(identifiable); - this.position = position; - } + private final String positionX; + private final String positionY; - public Point getPosition() { - return position; + public NodeMetadata(String svgId, String equipmentId, String positionX, String positionY) { + super(svgId, equipmentId); + this.positionX = positionX; + this.positionY = positionY; } @Override @@ -40,14 +39,10 @@ String getElementName() { } @Override - void write(DiagramMetadata.WritingContext ctx) throws XMLStreamException { - super.write(ctx); - ctx.writer.writeAttribute(POSITION_X_ATTRIBUTE, formatted(position.getX())); - ctx.writer.writeAttribute(POSITION_Y_ATTRIBUTE, formatted(position.getY())); - } - - private static String formatted(double value) { - return String.format(Locale.US, POSITION_COORD_FORMAT, value); + void write(XMLStreamWriter writer) throws XMLStreamException { + super.write(writer); + writer.writeAttribute(POSITION_X_ATTRIBUTE, positionX); + writer.writeAttribute(POSITION_Y_ATTRIBUTE, positionY); } static class Reader implements MetadataItemReader { @@ -55,11 +50,7 @@ static class Reader implements MetadataItemReader { private final String elementName; Reader() { - this(ELEMENT_NAME); - } - - private Reader(String elementName) { - this.elementName = elementName; + this.elementName = ELEMENT_NAME; } @Override @@ -68,22 +59,9 @@ public String getElementName() { } public NodeMetadata read(XMLStreamReader reader) { - Identifiable deserializedIdentifiable = readIdentifiable(reader); - Point position = readPoint(reader); - return new NodeMetadata(deserializedIdentifiable, position); - } - - private static Point readPoint(XMLStreamReader reader) { - double x = parseDouble(reader.getAttributeValue(null, POSITION_X_ATTRIBUTE)); - double y = parseDouble(reader.getAttributeValue(null, POSITION_Y_ATTRIBUTE)); - return new Point(x, y); - } - - private static double parseDouble(String s) { - if (s == null || s.isEmpty()) { - return Double.NaN; - } - return Double.parseDouble(s); + return new NodeMetadata(readDiagramId(reader), readEquipmentId(reader), + reader.getAttributeValue(null, POSITION_X_ATTRIBUTE), + reader.getAttributeValue(null, POSITION_Y_ATTRIBUTE)); } } } From e4e6ec16dc6675b87f9b08cdab1296fce3cc39ae Mon Sep 17 00:00:00 2001 From: Florian Dupuy Date: Fri, 25 Nov 2022 13:48:17 +0100 Subject: [PATCH 5/6] Metadata: Rename diagramId to svgId Signed-off-by: Florian Dupuy --- .../svg/metadata/AbstractMetadataItem.java | 2 +- .../src/main/resources/nad-metadata_V1_0.xsd | 8 +- .../src/test/resources/3wt.svg | 16 +- .../src/test/resources/3wt_disconnected.svg | 14 +- .../3wt_disconnected_topological.svg | 14 +- .../src/test/resources/3wt_partial.svg | 16 +- .../src/test/resources/IEEE_118_bus.svg | 844 +++++++++--------- .../test/resources/IEEE_118_bus_partial.svg | 224 ++--- .../IEEE_118_bus_partial_non_connected.svg | 166 ++-- .../src/test/resources/IEEE_14_bus.svg | 96 +- .../resources/IEEE_14_bus_disconnection.svg | 94 +- .../test/resources/IEEE_14_bus_fictitious.svg | 96 +- .../test/resources/IEEE_14_bus_text_nodes.svg | 96 +- .../test/resources/IEEE_14_id_prefixed.svg | 96 +- .../src/test/resources/IEEE_24_bus.svg | 172 ++-- .../src/test/resources/IEEE_30_bus.svg | 202 ++--- .../src/test/resources/IEEE_57_bus.svg | 358 ++++---- .../src/test/resources/current_limits.svg | 10 +- .../src/test/resources/detailed_text_node.svg | 10 +- .../detailed_text_node_no_legend.svg | 10 +- .../diamond-spring-repulsion-factor-0.0.svg | 92 +- .../diamond-spring-repulsion-factor-0.2.svg | 92 +- .../resources/edge_info_double_labels.svg | 16 +- .../resources/edge_info_missing_label.svg | 10 +- .../edge_info_perpendicular_label.svg | 10 +- .../src/test/resources/edge_info_shift.svg | 24 +- .../src/test/resources/hvdc-vl-depth-1.svg | 10 +- .../src/test/resources/hvdc.svg | 30 +- .../test/resources/parallel_transformers.svg | 14 +- .../src/test/resources/simple-eu-loop100.svg | 80 +- .../src/test/resources/simple-eu-loop80.svg | 80 +- .../src/test/resources/simple-eu.svg | 80 +- .../src/test/resources/vl_description_id.svg | 10 +- .../resources/vl_description_substation.svg | 10 +- .../vl_description_substation_id.svg | 10 +- .../src/test/resources/voltage_limits.svg | 14 +- 36 files changed, 1562 insertions(+), 1564 deletions(-) diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java index 28788edde..cf2135d0f 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java @@ -18,7 +18,7 @@ * @author Luma Zamarreño */ public abstract class AbstractMetadataItem { - private static final String DIAGRAM_ID_ATTRIBUTE = "diagramId"; + private static final String DIAGRAM_ID_ATTRIBUTE = "svgId"; private static final String EQUIPMENT_ID_ATTRIBUTE = "equipmentId"; private final String svgId; diff --git a/network-area-diagram/src/main/resources/nad-metadata_V1_0.xsd b/network-area-diagram/src/main/resources/nad-metadata_V1_0.xsd index f91e8bdb6..d87dc101a 100644 --- a/network-area-diagram/src/main/resources/nad-metadata_V1_0.xsd +++ b/network-area-diagram/src/main/resources/nad-metadata_V1_0.xsd @@ -46,19 +46,17 @@ - + - - - + - + diff --git a/network-area-diagram/src/test/resources/3wt.svg b/network-area-diagram/src/test/resources/3wt.svg index b2c1d145a..94705c973 100644 --- a/network-area-diagram/src/test/resources/3wt.svg +++ b/network-area-diagram/src/test/resources/3wt.svg @@ -49,18 +49,18 @@ - - - + + + - - - - + + + + - + diff --git a/network-area-diagram/src/test/resources/3wt_disconnected.svg b/network-area-diagram/src/test/resources/3wt_disconnected.svg index 7c27cf99e..af24c65ca 100644 --- a/network-area-diagram/src/test/resources/3wt_disconnected.svg +++ b/network-area-diagram/src/test/resources/3wt_disconnected.svg @@ -49,17 +49,17 @@ - - + + - - - - + + + + - + diff --git a/network-area-diagram/src/test/resources/3wt_disconnected_topological.svg b/network-area-diagram/src/test/resources/3wt_disconnected_topological.svg index 8436f2775..99652aa96 100644 --- a/network-area-diagram/src/test/resources/3wt_disconnected_topological.svg +++ b/network-area-diagram/src/test/resources/3wt_disconnected_topological.svg @@ -114,17 +114,17 @@ - - + + - - - - + + + + - + diff --git a/network-area-diagram/src/test/resources/3wt_partial.svg b/network-area-diagram/src/test/resources/3wt_partial.svg index cb6853f40..b1df12e34 100644 --- a/network-area-diagram/src/test/resources/3wt_partial.svg +++ b/network-area-diagram/src/test/resources/3wt_partial.svg @@ -49,18 +49,18 @@ - - - + + + - - - - + + + + - + diff --git a/network-area-diagram/src/test/resources/IEEE_118_bus.svg b/network-area-diagram/src/test/resources/IEEE_118_bus.svg index 521043de7..a9a7ea89f 100644 --- a/network-area-diagram/src/test/resources/IEEE_118_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_118_bus.svg @@ -114,432 +114,432 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_118_bus_partial.svg b/network-area-diagram/src/test/resources/IEEE_118_bus_partial.svg index 86363bf16..af3fbef6a 100644 --- a/network-area-diagram/src/test/resources/IEEE_118_bus_partial.svg +++ b/network-area-diagram/src/test/resources/IEEE_118_bus_partial.svg @@ -114,122 +114,122 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_118_bus_partial_non_connected.svg b/network-area-diagram/src/test/resources/IEEE_118_bus_partial_non_connected.svg index 6cf448be5..89c5bbe7b 100644 --- a/network-area-diagram/src/test/resources/IEEE_118_bus_partial_non_connected.svg +++ b/network-area-diagram/src/test/resources/IEEE_118_bus_partial_non_connected.svg @@ -114,93 +114,93 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus.svg b/network-area-diagram/src/test/resources/IEEE_14_bus.svg index 4015482e4..b4b7385fa 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus.svg @@ -49,58 +49,58 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus_disconnection.svg b/network-area-diagram/src/test/resources/IEEE_14_bus_disconnection.svg index 2a48b4b48..04ca279fd 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus_disconnection.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus_disconnection.svg @@ -49,57 +49,57 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus_fictitious.svg b/network-area-diagram/src/test/resources/IEEE_14_bus_fictitious.svg index c756073f0..268436c31 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus_fictitious.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus_fictitious.svg @@ -49,58 +49,58 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus_text_nodes.svg b/network-area-diagram/src/test/resources/IEEE_14_bus_text_nodes.svg index 145cb9f16..b90238dba 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus_text_nodes.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus_text_nodes.svg @@ -49,58 +49,58 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_14_id_prefixed.svg b/network-area-diagram/src/test/resources/IEEE_14_id_prefixed.svg index b359b6b84..c6e6fc8af 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_id_prefixed.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_id_prefixed.svg @@ -49,58 +49,58 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_24_bus.svg b/network-area-diagram/src/test/resources/IEEE_24_bus.svg index fa7584d73..ffc5dbd30 100644 --- a/network-area-diagram/src/test/resources/IEEE_24_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_24_bus.svg @@ -49,96 +49,96 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_30_bus.svg b/network-area-diagram/src/test/resources/IEEE_30_bus.svg index 5156807c8..406ff7fe9 100644 --- a/network-area-diagram/src/test/resources/IEEE_30_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_30_bus.svg @@ -49,111 +49,111 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/IEEE_57_bus.svg b/network-area-diagram/src/test/resources/IEEE_57_bus.svg index 98d727433..c18a2b289 100644 --- a/network-area-diagram/src/test/resources/IEEE_57_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_57_bus.svg @@ -114,189 +114,189 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/current_limits.svg b/network-area-diagram/src/test/resources/current_limits.svg index ee127b7a4..228088cf1 100644 --- a/network-area-diagram/src/test/resources/current_limits.svg +++ b/network-area-diagram/src/test/resources/current_limits.svg @@ -49,15 +49,15 @@ - - + + - - + + - + diff --git a/network-area-diagram/src/test/resources/detailed_text_node.svg b/network-area-diagram/src/test/resources/detailed_text_node.svg index 326bab53d..e154ac8fe 100644 --- a/network-area-diagram/src/test/resources/detailed_text_node.svg +++ b/network-area-diagram/src/test/resources/detailed_text_node.svg @@ -114,15 +114,15 @@ - - + + - - + + - + diff --git a/network-area-diagram/src/test/resources/detailed_text_node_no_legend.svg b/network-area-diagram/src/test/resources/detailed_text_node_no_legend.svg index eba7a6f66..c2aa25d5e 100644 --- a/network-area-diagram/src/test/resources/detailed_text_node_no_legend.svg +++ b/network-area-diagram/src/test/resources/detailed_text_node_no_legend.svg @@ -114,15 +114,15 @@ - - + + - - + + - + diff --git a/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.0.svg b/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.0.svg index ab228c392..f3f425fe4 100644 --- a/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.0.svg +++ b/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.0.svg @@ -49,56 +49,56 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.2.svg b/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.2.svg index 7fab42be4..c40d92522 100644 --- a/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.2.svg +++ b/network-area-diagram/src/test/resources/diamond-spring-repulsion-factor-0.2.svg @@ -49,56 +49,56 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/edge_info_double_labels.svg b/network-area-diagram/src/test/resources/edge_info_double_labels.svg index 05ccbef45..e89cd877f 100644 --- a/network-area-diagram/src/test/resources/edge_info_double_labels.svg +++ b/network-area-diagram/src/test/resources/edge_info_double_labels.svg @@ -49,18 +49,18 @@ - - - + + + - - - - + + + + - + diff --git a/network-area-diagram/src/test/resources/edge_info_missing_label.svg b/network-area-diagram/src/test/resources/edge_info_missing_label.svg index be3282a36..732110bbc 100644 --- a/network-area-diagram/src/test/resources/edge_info_missing_label.svg +++ b/network-area-diagram/src/test/resources/edge_info_missing_label.svg @@ -49,15 +49,15 @@ - - + + - - + + - + diff --git a/network-area-diagram/src/test/resources/edge_info_perpendicular_label.svg b/network-area-diagram/src/test/resources/edge_info_perpendicular_label.svg index d4ec97582..b54413870 100644 --- a/network-area-diagram/src/test/resources/edge_info_perpendicular_label.svg +++ b/network-area-diagram/src/test/resources/edge_info_perpendicular_label.svg @@ -49,15 +49,15 @@ - - + + - - + + - + diff --git a/network-area-diagram/src/test/resources/edge_info_shift.svg b/network-area-diagram/src/test/resources/edge_info_shift.svg index b47b80ae5..ff44ee76e 100644 --- a/network-area-diagram/src/test/resources/edge_info_shift.svg +++ b/network-area-diagram/src/test/resources/edge_info_shift.svg @@ -49,22 +49,22 @@ - - - - - + + + + + - - - + + + - - - - + + + + diff --git a/network-area-diagram/src/test/resources/hvdc-vl-depth-1.svg b/network-area-diagram/src/test/resources/hvdc-vl-depth-1.svg index d9deadd59..a300f2a5f 100644 --- a/network-area-diagram/src/test/resources/hvdc-vl-depth-1.svg +++ b/network-area-diagram/src/test/resources/hvdc-vl-depth-1.svg @@ -49,15 +49,15 @@ - - + + - - + + - + diff --git a/network-area-diagram/src/test/resources/hvdc.svg b/network-area-diagram/src/test/resources/hvdc.svg index bf639ea24..f12eaa7c0 100644 --- a/network-area-diagram/src/test/resources/hvdc.svg +++ b/network-area-diagram/src/test/resources/hvdc.svg @@ -49,25 +49,25 @@ - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + diff --git a/network-area-diagram/src/test/resources/parallel_transformers.svg b/network-area-diagram/src/test/resources/parallel_transformers.svg index bc5e4ff30..c84607355 100644 --- a/network-area-diagram/src/test/resources/parallel_transformers.svg +++ b/network-area-diagram/src/test/resources/parallel_transformers.svg @@ -49,17 +49,17 @@ - - - + + + - - + + - - + + diff --git a/network-area-diagram/src/test/resources/simple-eu-loop100.svg b/network-area-diagram/src/test/resources/simple-eu-loop100.svg index 285e077d2..e59f61a2f 100644 --- a/network-area-diagram/src/test/resources/simple-eu-loop100.svg +++ b/network-area-diagram/src/test/resources/simple-eu-loop100.svg @@ -114,50 +114,50 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/simple-eu-loop80.svg b/network-area-diagram/src/test/resources/simple-eu-loop80.svg index 8ebc7f023..2c71ab0e9 100644 --- a/network-area-diagram/src/test/resources/simple-eu-loop80.svg +++ b/network-area-diagram/src/test/resources/simple-eu-loop80.svg @@ -114,50 +114,50 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/simple-eu.svg b/network-area-diagram/src/test/resources/simple-eu.svg index ff8929258..22ab27a61 100644 --- a/network-area-diagram/src/test/resources/simple-eu.svg +++ b/network-area-diagram/src/test/resources/simple-eu.svg @@ -114,50 +114,50 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/network-area-diagram/src/test/resources/vl_description_id.svg b/network-area-diagram/src/test/resources/vl_description_id.svg index 7712d8691..53f006e18 100644 --- a/network-area-diagram/src/test/resources/vl_description_id.svg +++ b/network-area-diagram/src/test/resources/vl_description_id.svg @@ -114,15 +114,15 @@ - - + + - - + + - + diff --git a/network-area-diagram/src/test/resources/vl_description_substation.svg b/network-area-diagram/src/test/resources/vl_description_substation.svg index 3e5405257..452917a61 100644 --- a/network-area-diagram/src/test/resources/vl_description_substation.svg +++ b/network-area-diagram/src/test/resources/vl_description_substation.svg @@ -114,15 +114,15 @@ - - + + - - + + - + diff --git a/network-area-diagram/src/test/resources/vl_description_substation_id.svg b/network-area-diagram/src/test/resources/vl_description_substation_id.svg index 1fea1bef1..c5fa72004 100644 --- a/network-area-diagram/src/test/resources/vl_description_substation_id.svg +++ b/network-area-diagram/src/test/resources/vl_description_substation_id.svg @@ -114,15 +114,15 @@ - - + + - - + + - + diff --git a/network-area-diagram/src/test/resources/voltage_limits.svg b/network-area-diagram/src/test/resources/voltage_limits.svg index 302b96419..440f39bce 100644 --- a/network-area-diagram/src/test/resources/voltage_limits.svg +++ b/network-area-diagram/src/test/resources/voltage_limits.svg @@ -49,17 +49,17 @@ - - - + + + - - + + - - + + From bfe42842f3c7b4fe70862bfa76a0392b4609b528 Mon Sep 17 00:00:00 2001 From: Florian Dupuy Date: Fri, 25 Nov 2022 13:50:36 +0100 Subject: [PATCH 6/6] Remove unused imports / variables Signed-off-by: Florian Dupuy --- .../com/powsybl/nad/svg/metadata/AbstractMetadataItem.java | 3 --- .../java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java | 2 -- .../java/com/powsybl/nad/svg/metadata/DiagramMetadata.java | 4 ---- .../main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java | 2 -- .../main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java | 5 ----- 5 files changed, 16 deletions(-) diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java index cf2135d0f..4915fbe11 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/AbstractMetadataItem.java @@ -7,12 +7,9 @@ */ package com.powsybl.nad.svg.metadata; -import com.powsybl.nad.model.Identifiable; - import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; -import java.util.Optional; /** * @author Luma Zamarreño diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java index 053585025..9c828352f 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/BusNodeMetadata.java @@ -1,7 +1,5 @@ package com.powsybl.nad.svg.metadata; -import com.powsybl.nad.model.Identifiable; - import javax.xml.stream.XMLStreamReader; public class BusNodeMetadata extends AbstractMetadataItem { diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java index b28cb6169..a8483711f 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/DiagramMetadata.java @@ -8,9 +8,6 @@ package com.powsybl.nad.svg.metadata; import com.powsybl.commons.xml.XmlUtil; -import com.powsybl.nad.model.BusNode; -import com.powsybl.nad.model.Edge; -import com.powsybl.nad.model.Node; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; @@ -20,7 +17,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.function.UnaryOperator; /** * @author Thomas Adam diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java index 9af48048d..5f10b44f8 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/EdgeMetadata.java @@ -7,8 +7,6 @@ */ package com.powsybl.nad.svg.metadata; -import com.powsybl.nad.model.Identifiable; - import javax.xml.stream.XMLStreamReader; /** diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java index 860986548..acfa0efe0 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/NodeMetadata.java @@ -7,13 +7,9 @@ */ package com.powsybl.nad.svg.metadata; -import com.powsybl.nad.model.Identifiable; -import com.powsybl.nad.model.Point; - import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; -import java.util.Locale; /** * @author Luma Zamarreño @@ -22,7 +18,6 @@ public class NodeMetadata extends AbstractMetadataItem { private static final String ELEMENT_NAME = "node"; private static final String POSITION_X_ATTRIBUTE = "x"; private static final String POSITION_Y_ATTRIBUTE = "y"; - private static final String POSITION_COORD_FORMAT = "%.2f"; private final String positionX; private final String positionY;