From a45c19ca61117378f8252fabbbda4c45bef36655 Mon Sep 17 00:00:00 2001 From: Massimo Ferraro Date: Fri, 24 May 2024 17:59:49 +0200 Subject: [PATCH] Add SVG parameters to metadata in network area diagram SVG (#618) Signed-off-by: massimo.ferraro --- .../java/com/powsybl/nad/svg/SvgWriter.java | 22 +- .../nad/svg/metadata/DiagramMetadata.java | 26 ++ .../svg/metadata/SvgParametersMetadata.java | 273 ++++++++++++++++++ .../powsybl/nad/svg/DiagramMetadataTest.java | 1 + .../src/test/resources/3wt.svg | 1 + .../src/test/resources/3wt_disconnected.svg | 1 + .../3wt_disconnected_topological.svg | 1 + .../src/test/resources/3wt_partial.svg | 1 + .../src/test/resources/IEEE_118_bus.svg | 1 + .../test/resources/IEEE_118_bus_partial.svg | 1 + .../IEEE_118_bus_partial_non_connected.svg | 1 + .../src/test/resources/IEEE_14_bus.svg | 1 + .../resources/IEEE_14_bus_disconnection.svg | 1 + .../test/resources/IEEE_14_bus_fictitious.svg | 1 + .../test/resources/IEEE_14_bus_text_nodes.svg | 1 + .../resources/IEEE_14_bus_voltage_filter1.svg | 1 + .../resources/IEEE_14_bus_voltage_filter2.svg | 1 + .../resources/IEEE_14_bus_voltage_filter3.svg | 1 + .../resources/IEEE_14_bus_voltage_filter4.svg | 1 + .../resources/IEEE_14_bus_voltage_filter5.svg | 1 + .../test/resources/IEEE_14_id_prefixed.svg | 1 + .../src/test/resources/IEEE_24_bus.svg | 1 + .../src/test/resources/IEEE_30_bus.svg | 1 + .../src/test/resources/IEEE_57_bus.svg | 1 + .../src/test/resources/current_limits.svg | 1 + .../resources/dangling_line_connected.svg | 1 + .../resources/dangling_line_disconnected.svg | 1 + .../src/test/resources/detailed_text_node.svg | 1 + .../detailed_text_node_no_legend.svg | 1 + .../diamond-spring-repulsion-factor-0.0.svg | 1 + .../diamond-spring-repulsion-factor-0.2.svg | 1 + .../src/test/resources/edge_info_current.svg | 1 + .../resources/edge_info_double_labels.svg | 1 + .../resources/edge_info_missing_label.svg | 1 + .../edge_info_perpendicular_label.svg | 1 + .../resources/edge_info_reactive_power.svg | 1 + .../src/test/resources/edge_info_shift.svg | 1 + .../src/test/resources/edge_with_id.svg | 1 + .../src/test/resources/edge_without_id.svg | 1 + .../src/test/resources/hvdc-vl-depth-1.svg | 1 + .../src/test/resources/hvdc.svg | 1 + .../test/resources/parallel_transformers.svg | 1 + .../src/test/resources/simple-eu-loop100.svg | 1 + .../src/test/resources/simple-eu-loop80.svg | 1 + .../src/test/resources/simple-eu.svg | 1 + .../src/test/resources/tie_line.svg | 1 + .../src/test/resources/tie_line_filtered.svg | 1 + .../src/test/resources/vl_description_id.svg | 1 + .../resources/vl_description_substation.svg | 1 + .../vl_description_substation_id.svg | 1 + .../src/test/resources/voltage_limits.svg | 1 + 51 files changed, 368 insertions(+), 1 deletion(-) create mode 100644 network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/SvgParametersMetadata.java 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 be4316d91..d8a64a195 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 @@ -914,7 +914,27 @@ private void addMetadata(Graph graph, XMLStreamWriter writer) throws XMLStreamEx getPrefixedId(graph.getBusGraphNode1(edge).getDiagramId()), getPrefixedId(graph.getBusGraphNode2(edge).getDiagramId()), edge.getType())); - + metadata.addSvgParameters(String.valueOf(svgParameters.isInsertNameDesc()), String.valueOf(svgParameters.isSvgWidthAndHeightAdded()), + svgParameters.getCssLocation().name(), svgParameters.getSizeConstraint().name(), + String.valueOf(svgParameters.getFixedWidth()), String.valueOf(svgParameters.getFixedHeight()), + String.valueOf(svgParameters.getFixedScale()), getFormattedValue(svgParameters.getArrowShift()), + getFormattedValue(svgParameters.getArrowLabelShift()), getFormattedValue(svgParameters.getConverterStationWidth()), + getFormattedValue(svgParameters.getVoltageLevelCircleRadius()), + getFormattedValue(svgParameters.getFictitiousVoltageLevelCircleRadius()), + getFormattedValue(svgParameters.getTransformerCircleRadius()), getFormattedValue(svgParameters.getNodeHollowWidth()), + getFormattedValue(svgParameters.getEdgesForkLength()), getFormattedValue(svgParameters.getEdgesForkAperture()), + getFormattedValue(svgParameters.getEdgeStartShift()), getFormattedValue(svgParameters.getUnknownBusNodeExtraRadius()), + getFormattedValue(svgParameters.getLoopDistance()), getFormattedValue(svgParameters.getLoopEdgesAperture()), + getFormattedValue(svgParameters.getLoopControlDistance()), String.valueOf(svgParameters.isEdgeInfoAlongEdge()), + String.valueOf(svgParameters.isEdgeNameDisplayed()), getFormattedValue(svgParameters.getInterAnnulusSpace()), + svgParameters.getSvgPrefix(), String.valueOf(svgParameters.isIdDisplayed()), + String.valueOf(svgParameters.isSubstationDescriptionDisplayed()), getFormattedValue(svgParameters.getArrowHeight()), + String.valueOf(svgParameters.isBusLegend()), String.valueOf(svgParameters.isVoltageLevelDetails()), + getFormattedValue(svgParameters.getDetailedTextNodeYShift()), svgParameters.getLanguageTag(), + String.valueOf(svgParameters.getVoltageValuePrecision()), String.valueOf(svgParameters.getPowerValuePrecision()), + String.valueOf(svgParameters.getAngleValuePrecision()), String.valueOf(svgParameters.getCurrentValuePrecision()), + svgParameters.getEdgeInfoDisplayed().name(), getFormattedValue(svgParameters.getPstArrowHeadSize()), + svgParameters.getUndefinedValueSymbol()); writer.writeStartElement(METADATA_ELEMENT_NAME); metadata.writeXml(writer); writer.writeEndElement(); 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 c079b6ff4..947b7f6ff 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 @@ -31,10 +31,12 @@ public class DiagramMetadata { private static final String METADATA_BUS_NODES_ELEMENT_NAME = "busNodes"; private static final String METADATA_NODES_ELEMENT_NAME = "nodes"; private static final String METADATA_EDGES_ELEMENT_NAME = "edges"; + private static final String METADATA_SVG_PARAMETERS_ELEMENT_NAME = "svgParameters"; private final List busNodesMetadata = new ArrayList<>(); private final List nodesMetadata = new ArrayList<>(); private final List edgesMetadata = new ArrayList<>(); + private SvgParametersMetadata svgParametersMetadata; public static DiagramMetadata readFromSvg(InputStream inputStream) throws XMLStreamException { return readFromSvg(XMLInputFactory.newDefaultFactory().createXMLStreamReader(inputStream)); @@ -49,6 +51,7 @@ public static DiagramMetadata readFromSvg(XMLStreamReader reader) throws XMLStre case METADATA_BUS_NODES_ELEMENT_NAME -> readCollection(metadata.busNodesMetadata, new BusNodeMetadata.Reader(), reader); case METADATA_NODES_ELEMENT_NAME -> readCollection(metadata.nodesMetadata, new NodeMetadata.Reader(), reader); case METADATA_EDGES_ELEMENT_NAME -> readCollection(metadata.edgesMetadata, new EdgeMetadata.Reader(), reader); + case METADATA_SVG_PARAMETERS_ELEMENT_NAME -> metadata.svgParametersMetadata = new SvgParametersMetadata.Reader().read(reader); default -> throw new PowsyblException("Unexpected element '" + token + "' in metadata"); } }) @@ -74,6 +77,11 @@ public void writeXml(XMLStreamWriter writer) throws XMLStreamException { writeCollection(busNodesMetadata, METADATA_BUS_NODES_ELEMENT_NAME, writer); writeCollection(nodesMetadata, METADATA_NODES_ELEMENT_NAME, writer); writeCollection(edgesMetadata, METADATA_EDGES_ELEMENT_NAME, writer); + if (svgParametersMetadata != null) { + svgParametersMetadata.write(writer); + } else { + SvgParametersMetadata.writeEmpty(writer); + } writer.writeEndElement(); } @@ -103,4 +111,22 @@ public void addNode(String svgId, String equipmentId, String positionX, String p public void addEdge(String svgId, String equipmentId, String node1SvgId, String node2SvgId, String busNode1SvgId, String busNode2SvgId, String edgeType) { edgesMetadata.add(new EdgeMetadata(svgId, equipmentId, node1SvgId, node2SvgId, busNode1SvgId, busNode2SvgId, edgeType)); } + + public void addSvgParameters(String insertNameDesc, String svgWidthAndHeightAdded, String cssLocation, String sizeConstraint, String fixedWidth, + String fixedHeight, String fixedScale, String arrowShift, String arrowLabelShift, String converterStationWidth, + String voltageLevelCircleRadius, String fictitiousVoltageLevelCircleRadius, String transformerCircleRadius, + String nodeHollowWidth, String edgesForkLength, String edgesForkAperture, String edgeStartShift, String unknownBusNodeExtraRadius, + String loopDistance, String loopEdgesAperture, String loopControlDistance, String edgeInfoAlongEdge, String edgeNameDisplayed, + String interAnnulusSpace, String svgPrefix, String idDisplayed, String substationDescriptionDisplayed, String arrowHeight, + String busLegend, String voltageLevelDetails, String detailedTextNodeYShift, String languageTag, String voltageValuePrecision, + String powerValuePrecision, String angleValuePrecision, String currentValuePrecision, String edgeInfoDisplayed, + String pstArrowHeadSize, String undefinedValueSymbol) { + svgParametersMetadata = new SvgParametersMetadata(insertNameDesc, svgWidthAndHeightAdded, cssLocation, sizeConstraint, fixedWidth, fixedHeight, fixedScale, + arrowShift, arrowLabelShift, converterStationWidth, voltageLevelCircleRadius, fictitiousVoltageLevelCircleRadius, + transformerCircleRadius, nodeHollowWidth, edgesForkLength, edgesForkAperture, edgeStartShift, + unknownBusNodeExtraRadius, loopDistance, loopEdgesAperture, loopControlDistance, edgeInfoAlongEdge, + edgeNameDisplayed, interAnnulusSpace, svgPrefix, idDisplayed, substationDescriptionDisplayed, arrowHeight, + busLegend, voltageLevelDetails, detailedTextNodeYShift, languageTag, voltageValuePrecision, powerValuePrecision, + angleValuePrecision, currentValuePrecision, edgeInfoDisplayed, pstArrowHeadSize, undefinedValueSymbol); + } } diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/SvgParametersMetadata.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/SvgParametersMetadata.java new file mode 100644 index 000000000..be45233bd --- /dev/null +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/metadata/SvgParametersMetadata.java @@ -0,0 +1,273 @@ +/** + * Copyright (c) 2024, 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/. + */ +package com.powsybl.nad.svg.metadata; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import com.powsybl.commons.exceptions.UncheckedXmlStreamException; +import com.powsybl.commons.xml.XmlUtil; + +/** + * @author Massimo Ferraro {@literal } + */ +public class SvgParametersMetadata { + + private static final String ELEMENT_NAME = "svgParameters"; + private static final String INSERT_NAME_DESC = "insertNameDesc"; + private static final String SVG_WIDTH_AND_HEIGHT_ADDED = "svgWidthAndHeightAdded"; + private static final String CSS_LOCATION = "cssLocation"; + private static final String SIZE_CONSTRAINT = "sizeConstraint"; + private static final String FIXED_WIDTH = "fixedWidth"; + private static final String FIXED_HEIGHT = "fixedHeight"; + private static final String FIXED_SCALE = "fixedScale"; + private static final String ARROW_SHIFT = "arrowShift"; + private static final String ARROW_LABEL_SHIFT = "arrowLabelShift"; + private static final String CONVERTER_STATION_WIDTH = "converterStationWidth"; + private static final String VOLTAGE_LEVEL_CIRCLE_RADIUS = "voltageLevelCircleRadius"; + private static final String FICTITIOUS_VOLTAGE_LEVEL_CIRCLE_RADIUS = "fictitiousVoltageLevelCircleRadius"; + private static final String TRANSFORMER_CIRCLE_RADIUS = "transformerCircleRadius"; + private static final String NODE_HOLLOW_WIDTH = "nodeHollowWidth"; + private static final String EDGES_FORK_LENGTH = "edgesForkLength"; + private static final String EDGES_FORK_APERTURE = "edgesForkAperture"; + private static final String EDGE_START_SHIFT = "edgeStartShift"; + private static final String UNKNOWN_BUS_NODE_EXTRA_RADIUS = "unknownBusNodeExtraRadius"; + private static final String LOOP_DISTANCE = "loopDistance"; + private static final String LOOP_EDGES_APERTURE = "loopEdgesAperture"; + private static final String LOOP_CONTROL_DISTANCE = "loopControlDistance"; + private static final String EDGE_INFO_ALONG_EDGE = "edgeInfoAlongEdge"; + private static final String EDGE_NAME_DISPLAYED = "edgeNameDisplayed"; + private static final String INTER_ANNULUS_SPACE = "interAnnulusSpace"; + private static final String SVG_PREFIX = "svgPrefix"; + private static final String ID_DISPLAYED = "idDisplayed"; + private static final String SUBSTATION_DESCRIPTION_DISPLAYED = "substationDescriptionDisplayed"; + private static final String ARROW_HEIGHT = "arrowHeight"; + private static final String BUS_LEGEND = "busLegend"; + private static final String VOLTAGE_LEVEL_DETAILS = "voltageLevelDetails"; + private static final String DETAILED_TEXT_NODE_Y_SHIFT = "detailedTextNodeYShift"; + private static final String LANGUAGE_TAG = "languageTag"; + private static final String VOLTAGE_VALUE_PRECISION = "voltageValuePrecision"; + private static final String POWER_VALUE_PRECISION = "powerValuePrecision"; + private static final String ANGLE_VALUE_PRECISION = "angleValuePrecision"; + private static final String CURRENT_VALUE_PRECISION = "currentValuePrecision"; + private static final String EDGE_INFO_DISPLAYED = "edgeInfoDisplayed"; + private static final String PST_ARROW_HEAD_SIZE = "pstArrowHeadSize"; + private static final String UNDEFINED_VALUE_SYMBOL = "undefinedValueSymbol"; + + private final String insertNameDesc; + private final String svgWidthAndHeightAdded; + private final String cssLocation; + private final String sizeConstraint; + private final String fixedWidth; + private final String fixedHeight; + private final String fixedScale; + private final String arrowShift; + private final String arrowLabelShift; + private final String converterStationWidth; + private final String voltageLevelCircleRadius; + private final String fictitiousVoltageLevelCircleRadius; + private final String transformerCircleRadius; + private final String nodeHollowWidth; + private final String edgesForkLength; + private final String edgesForkAperture; + private final String edgeStartShift; + private final String unknownBusNodeExtraRadius; + private final String loopDistance; + private final String loopEdgesAperture; + private final String loopControlDistance; + private final String edgeInfoAlongEdge; + private final String edgeNameDisplayed; + private final String interAnnulusSpace; + private final String svgPrefix; + private final String idDisplayed; + private final String substationDescriptionDisplayed; + private final String arrowHeight; + private final String busLegend; + private final String voltageLevelDetails; + private final String detailedTextNodeYShift; + private final String languageTag; + private final String voltageValuePrecision; + private final String powerValuePrecision; + private final String angleValuePrecision; + private final String currentValuePrecision; + private final String edgeInfoDisplayed; + private final String pstArrowHeadSize; + private final String undefinedValueSymbol; + + public SvgParametersMetadata(String insertNameDesc, String svgWidthAndHeightAdded, String cssLocation, + String sizeConstraint, String fixedWidth, String fixedHeight, String fixedScale, + String arrowShift, String arrowLabelShift, String converterStationWidth, + String voltageLevelCircleRadius, String fictitiousVoltageLevelCircleRadius, + String transformerCircleRadius, String nodeHollowWidth, String edgesForkLength, + String edgesForkAperture, String edgeStartShift, String unknownBusNodeExtraRadius, + String loopDistance, String loopEdgesAperture, String loopControlDistance, + String edgeInfoAlongEdge, String edgeNameDisplayed, String interAnnulusSpace, + String svgPrefix, String idDisplayed, String substationDescriptionDisplayed, + String arrowHeight, String busLegend, String voltageLevelDetails, + String detailedTextNodeYShift, String languageTag, String voltageValuePrecision, + String powerValuePrecision, String angleValuePrecision, String currentValuePrecision, + String edgeInfoDisplayed, String pstArrowHeadSize, String undefinedValueSymbol) { + this.insertNameDesc = insertNameDesc; + this.svgWidthAndHeightAdded = svgWidthAndHeightAdded; + this.cssLocation = cssLocation; + this.sizeConstraint = sizeConstraint; + this.fixedWidth = fixedWidth; + this.fixedHeight = fixedHeight; + this.fixedScale = fixedScale; + this.arrowShift = arrowShift; + this.arrowLabelShift = arrowLabelShift; + this.converterStationWidth = converterStationWidth; + this.voltageLevelCircleRadius = voltageLevelCircleRadius; + this.fictitiousVoltageLevelCircleRadius = fictitiousVoltageLevelCircleRadius; + this.transformerCircleRadius = transformerCircleRadius; + this.nodeHollowWidth = nodeHollowWidth; + this.edgesForkLength = edgesForkLength; + this.edgesForkAperture = edgesForkAperture; + this.edgeStartShift = edgeStartShift; + this.unknownBusNodeExtraRadius = unknownBusNodeExtraRadius; + this.loopDistance = loopDistance; + this.loopEdgesAperture = loopEdgesAperture; + this.loopControlDistance = loopControlDistance; + this.edgeInfoAlongEdge = edgeInfoAlongEdge; + this.edgeNameDisplayed = edgeNameDisplayed; + this.interAnnulusSpace = interAnnulusSpace; + this.svgPrefix = svgPrefix; + this.idDisplayed = idDisplayed; + this.substationDescriptionDisplayed = substationDescriptionDisplayed; + this.arrowHeight = arrowHeight; + this.busLegend = busLegend; + this.voltageLevelDetails = voltageLevelDetails; + this.detailedTextNodeYShift = detailedTextNodeYShift; + this.languageTag = languageTag; + this.voltageValuePrecision = voltageValuePrecision; + this.powerValuePrecision = powerValuePrecision; + this.angleValuePrecision = angleValuePrecision; + this.currentValuePrecision = currentValuePrecision; + this.edgeInfoDisplayed = edgeInfoDisplayed; + this.pstArrowHeadSize = pstArrowHeadSize; + this.undefinedValueSymbol = undefinedValueSymbol; + } + + String getElementName() { + return ELEMENT_NAME; + } + + void write(XMLStreamWriter writer) throws XMLStreamException { + writer.writeEmptyElement(DiagramMetadata.METADATA_PREFIX, getElementName(), DiagramMetadata.METADATA_NAMESPACE_URI); + writer.writeAttribute(INSERT_NAME_DESC, insertNameDesc); + writer.writeAttribute(SVG_WIDTH_AND_HEIGHT_ADDED, svgWidthAndHeightAdded); + writer.writeAttribute(CSS_LOCATION, cssLocation); + writer.writeAttribute(SIZE_CONSTRAINT, sizeConstraint); + writer.writeAttribute(FIXED_WIDTH, fixedWidth); + writer.writeAttribute(FIXED_HEIGHT, fixedHeight); + writer.writeAttribute(FIXED_SCALE, fixedScale); + writer.writeAttribute(ARROW_SHIFT, arrowShift); + writer.writeAttribute(ARROW_LABEL_SHIFT, arrowLabelShift); + writer.writeAttribute(CONVERTER_STATION_WIDTH, converterStationWidth); + writer.writeAttribute(VOLTAGE_LEVEL_CIRCLE_RADIUS, voltageLevelCircleRadius); + writer.writeAttribute(FICTITIOUS_VOLTAGE_LEVEL_CIRCLE_RADIUS, fictitiousVoltageLevelCircleRadius); + writer.writeAttribute(TRANSFORMER_CIRCLE_RADIUS, transformerCircleRadius); + writer.writeAttribute(NODE_HOLLOW_WIDTH, nodeHollowWidth); + writer.writeAttribute(EDGES_FORK_LENGTH, edgesForkLength); + writer.writeAttribute(EDGES_FORK_APERTURE, edgesForkAperture); + writer.writeAttribute(EDGE_START_SHIFT, edgeStartShift); + writer.writeAttribute(UNKNOWN_BUS_NODE_EXTRA_RADIUS, unknownBusNodeExtraRadius); + writer.writeAttribute(LOOP_DISTANCE, loopDistance); + writer.writeAttribute(LOOP_EDGES_APERTURE, loopEdgesAperture); + writer.writeAttribute(LOOP_CONTROL_DISTANCE, loopControlDistance); + writer.writeAttribute(EDGE_INFO_ALONG_EDGE, edgeInfoAlongEdge); + writer.writeAttribute(EDGE_NAME_DISPLAYED, edgeNameDisplayed); + writer.writeAttribute(INTER_ANNULUS_SPACE, interAnnulusSpace); + writer.writeAttribute(SVG_PREFIX, svgPrefix); + writer.writeAttribute(ID_DISPLAYED, idDisplayed); + writer.writeAttribute(SUBSTATION_DESCRIPTION_DISPLAYED, substationDescriptionDisplayed); + writer.writeAttribute(ARROW_HEIGHT, arrowHeight); + writer.writeAttribute(BUS_LEGEND, busLegend); + writer.writeAttribute(VOLTAGE_LEVEL_DETAILS, voltageLevelDetails); + writer.writeAttribute(DETAILED_TEXT_NODE_Y_SHIFT, detailedTextNodeYShift); + writer.writeAttribute(LANGUAGE_TAG, languageTag); + writer.writeAttribute(VOLTAGE_VALUE_PRECISION, voltageValuePrecision); + writer.writeAttribute(POWER_VALUE_PRECISION, powerValuePrecision); + writer.writeAttribute(ANGLE_VALUE_PRECISION, angleValuePrecision); + writer.writeAttribute(CURRENT_VALUE_PRECISION, currentValuePrecision); + writer.writeAttribute(EDGE_INFO_DISPLAYED, edgeInfoDisplayed); + writer.writeAttribute(PST_ARROW_HEAD_SIZE, pstArrowHeadSize); + writer.writeAttribute(UNDEFINED_VALUE_SYMBOL, undefinedValueSymbol); + } + + static void writeEmpty(XMLStreamWriter writer) throws XMLStreamException { + writer.writeEmptyElement(DiagramMetadata.METADATA_PREFIX, ELEMENT_NAME, DiagramMetadata.METADATA_NAMESPACE_URI); + } + + static class Reader { + + private final String elementName; + + Reader() { + this.elementName = ELEMENT_NAME; + } + + public String getElementName() { + return elementName; + } + + public SvgParametersMetadata read(XMLStreamReader reader) { + try { + String insertNameDesc = reader.getAttributeValue(null, INSERT_NAME_DESC); + String svgWidthAndHeightAdded = reader.getAttributeValue(null, SVG_WIDTH_AND_HEIGHT_ADDED); + String cssLocation = reader.getAttributeValue(null, CSS_LOCATION); + String sizeConstraint = reader.getAttributeValue(null, SIZE_CONSTRAINT); + String fixedWidth = reader.getAttributeValue(null, FIXED_WIDTH); + String fixedHeight = reader.getAttributeValue(null, FIXED_HEIGHT); + String fixedScale = reader.getAttributeValue(null, FIXED_SCALE); + String arrowShift = reader.getAttributeValue(null, ARROW_SHIFT); + String arrowLabelShift = reader.getAttributeValue(null, ARROW_LABEL_SHIFT); + String converterStationWidth = reader.getAttributeValue(null, CONVERTER_STATION_WIDTH); + String voltageLevelCircleRadius = reader.getAttributeValue(null, VOLTAGE_LEVEL_CIRCLE_RADIUS); + String fictitiousVoltageLevelCircleRadius = reader.getAttributeValue(null, FICTITIOUS_VOLTAGE_LEVEL_CIRCLE_RADIUS); + String transformerCircleRadius = reader.getAttributeValue(null, TRANSFORMER_CIRCLE_RADIUS); + String nodeHollowWidth = reader.getAttributeValue(null, NODE_HOLLOW_WIDTH); + String edgesForkLength = reader.getAttributeValue(null, EDGES_FORK_LENGTH); + String edgesForkAperture = reader.getAttributeValue(null, EDGES_FORK_APERTURE); + String edgeStartShift = reader.getAttributeValue(null, EDGE_START_SHIFT); + String unknownBusNodeExtraRadius = reader.getAttributeValue(null, UNKNOWN_BUS_NODE_EXTRA_RADIUS); + String loopDistance = reader.getAttributeValue(null, LOOP_DISTANCE); + String loopEdgesAperture = reader.getAttributeValue(null, LOOP_EDGES_APERTURE); + String loopControlDistance = reader.getAttributeValue(null, LOOP_CONTROL_DISTANCE); + String edgeInfoAlongEdge = reader.getAttributeValue(null, EDGE_INFO_ALONG_EDGE); + String edgeNameDisplayed = reader.getAttributeValue(null, EDGE_NAME_DISPLAYED); + String interAnnulusSpace = reader.getAttributeValue(null, INTER_ANNULUS_SPACE); + String svgPrefix = reader.getAttributeValue(null, SVG_PREFIX); + String idDisplayed = reader.getAttributeValue(null, ID_DISPLAYED); + String substationDescriptionDisplayed = reader.getAttributeValue(null, SUBSTATION_DESCRIPTION_DISPLAYED); + String arrowHeight = reader.getAttributeValue(null, ARROW_HEIGHT); + String busLegend = reader.getAttributeValue(null, BUS_LEGEND); + String voltageLevelDetails = reader.getAttributeValue(null, VOLTAGE_LEVEL_DETAILS); + String detailedTextNodeYShift = reader.getAttributeValue(null, DETAILED_TEXT_NODE_Y_SHIFT); + String languageTag = reader.getAttributeValue(null, LANGUAGE_TAG); + String voltageValuePrecision = reader.getAttributeValue(null, VOLTAGE_VALUE_PRECISION); + String powerValuePrecision = reader.getAttributeValue(null, POWER_VALUE_PRECISION); + String angleValuePrecision = reader.getAttributeValue(null, ANGLE_VALUE_PRECISION); + String currentValuePrecision = reader.getAttributeValue(null, CURRENT_VALUE_PRECISION); + String edgeInfoDisplayed = reader.getAttributeValue(null, EDGE_INFO_DISPLAYED); + String pstArrowHeadSize = reader.getAttributeValue(null, PST_ARROW_HEAD_SIZE); + String undefinedValueSymbol = reader.getAttributeValue(null, UNDEFINED_VALUE_SYMBOL); + XmlUtil.readEndElementOrThrow(reader); + return new SvgParametersMetadata(insertNameDesc, svgWidthAndHeightAdded, cssLocation, sizeConstraint, fixedWidth, fixedHeight, fixedScale, + arrowShift, arrowLabelShift, converterStationWidth, voltageLevelCircleRadius, fictitiousVoltageLevelCircleRadius, + transformerCircleRadius, nodeHollowWidth, edgesForkLength, edgesForkAperture, edgeStartShift, + unknownBusNodeExtraRadius, loopDistance, loopEdgesAperture, loopControlDistance, edgeInfoAlongEdge, + edgeNameDisplayed, interAnnulusSpace, svgPrefix, idDisplayed, substationDescriptionDisplayed, arrowHeight, + busLegend, voltageLevelDetails, detailedTextNodeYShift, languageTag, voltageValuePrecision, powerValuePrecision, + angleValuePrecision, currentValuePrecision, edgeInfoDisplayed, pstArrowHeadSize, undefinedValueSymbol); + } catch (XMLStreamException e) { + throw new UncheckedXmlStreamException(e); + } + } + } +} diff --git a/network-area-diagram/src/test/java/com/powsybl/nad/svg/DiagramMetadataTest.java b/network-area-diagram/src/test/java/com/powsybl/nad/svg/DiagramMetadataTest.java index 799f4f1c1..79f8e63b7 100644 --- a/network-area-diagram/src/test/java/com/powsybl/nad/svg/DiagramMetadataTest.java +++ b/network-area-diagram/src/test/java/com/powsybl/nad/svg/DiagramMetadataTest.java @@ -123,6 +123,7 @@ void testInvalid() throws XMLStreamException { + """; // Checking diff --git a/network-area-diagram/src/test/resources/3wt.svg b/network-area-diagram/src/test/resources/3wt.svg index d9dacf6c1..e91f87327 100644 --- a/network-area-diagram/src/test/resources/3wt.svg +++ b/network-area-diagram/src/test/resources/3wt.svg @@ -64,6 +64,7 @@ + diff --git a/network-area-diagram/src/test/resources/3wt_disconnected.svg b/network-area-diagram/src/test/resources/3wt_disconnected.svg index cd25944da..a9d023e2d 100644 --- a/network-area-diagram/src/test/resources/3wt_disconnected.svg +++ b/network-area-diagram/src/test/resources/3wt_disconnected.svg @@ -63,6 +63,7 @@ + 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 0e6ab4f3a..0dd03a1d3 100644 --- a/network-area-diagram/src/test/resources/3wt_disconnected_topological.svg +++ b/network-area-diagram/src/test/resources/3wt_disconnected_topological.svg @@ -128,6 +128,7 @@ + diff --git a/network-area-diagram/src/test/resources/3wt_partial.svg b/network-area-diagram/src/test/resources/3wt_partial.svg index a5c6982d2..530654972 100644 --- a/network-area-diagram/src/test/resources/3wt_partial.svg +++ b/network-area-diagram/src/test/resources/3wt_partial.svg @@ -64,6 +64,7 @@ + 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 16b7ee32c..072eb9fb5 100644 --- a/network-area-diagram/src/test/resources/IEEE_118_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_118_bus.svg @@ -541,6 +541,7 @@ + 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 6aba81e14..a0286e273 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 @@ -231,6 +231,7 @@ + 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 889d6745a..aed71921b 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 @@ -202,6 +202,7 @@ + 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 a337a3b6e..7cd617811 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus.svg @@ -99,6 +99,7 @@ + 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 2222ef37b..bab5414a2 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 @@ -98,6 +98,7 @@ + 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 088ea544d..1a58486bb 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 @@ -102,6 +102,7 @@ + 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 76fa88246..a028bce56 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 @@ -102,6 +102,7 @@ + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter1.svg b/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter1.svg index bb8f14917..dbdd54d5a 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter1.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter1.svg @@ -145,6 +145,7 @@ + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter2.svg b/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter2.svg index 41f8d6d4a..8d3bcb074 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter2.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter2.svg @@ -166,6 +166,7 @@ + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter3.svg b/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter3.svg index 32dd26c51..803b2c341 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter3.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter3.svg @@ -152,6 +152,7 @@ + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter4.svg b/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter4.svg index ec4c60a0a..d0d62ee59 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter4.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter4.svg @@ -154,6 +154,7 @@ + diff --git a/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter5.svg b/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter5.svg index f4f1acbc0..3375a9074 100644 --- a/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter5.svg +++ b/network-area-diagram/src/test/resources/IEEE_14_bus_voltage_filter5.svg @@ -148,6 +148,7 @@ + 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 758bf6f64..3acef685b 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 @@ -102,6 +102,7 @@ + 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 e8aaf08c3..088f22e90 100644 --- a/network-area-diagram/src/test/resources/IEEE_24_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_24_bus.svg @@ -140,6 +140,7 @@ + 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 d105110d8..feb1e1573 100644 --- a/network-area-diagram/src/test/resources/IEEE_30_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_30_bus.svg @@ -155,6 +155,7 @@ + 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 1ab61ab4a..998ec7c14 100644 --- a/network-area-diagram/src/test/resources/IEEE_57_bus.svg +++ b/network-area-diagram/src/test/resources/IEEE_57_bus.svg @@ -298,6 +298,7 @@ + diff --git a/network-area-diagram/src/test/resources/current_limits.svg b/network-area-diagram/src/test/resources/current_limits.svg index 5e23fdddf..bd802ebdd 100644 --- a/network-area-diagram/src/test/resources/current_limits.svg +++ b/network-area-diagram/src/test/resources/current_limits.svg @@ -62,6 +62,7 @@ + diff --git a/network-area-diagram/src/test/resources/dangling_line_connected.svg b/network-area-diagram/src/test/resources/dangling_line_connected.svg index 80f12d793..d0b7028ec 100644 --- a/network-area-diagram/src/test/resources/dangling_line_connected.svg +++ b/network-area-diagram/src/test/resources/dangling_line_connected.svg @@ -69,6 +69,7 @@ + diff --git a/network-area-diagram/src/test/resources/dangling_line_disconnected.svg b/network-area-diagram/src/test/resources/dangling_line_disconnected.svg index 35b96db74..f80920c99 100644 --- a/network-area-diagram/src/test/resources/dangling_line_disconnected.svg +++ b/network-area-diagram/src/test/resources/dangling_line_disconnected.svg @@ -69,6 +69,7 @@ + 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 a7996b2e2..c9efb6763 100644 --- a/network-area-diagram/src/test/resources/detailed_text_node.svg +++ b/network-area-diagram/src/test/resources/detailed_text_node.svg @@ -127,6 +127,7 @@ + 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 9f3476a98..e5320c1cf 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 @@ -127,6 +127,7 @@ + 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 53882b592..4117aae9d 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 @@ -100,6 +100,7 @@ + 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 0aefc3cb7..188c9b3e1 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 @@ -100,6 +100,7 @@ + diff --git a/network-area-diagram/src/test/resources/edge_info_current.svg b/network-area-diagram/src/test/resources/edge_info_current.svg index 3a2180e9d..9ad64ded1 100644 --- a/network-area-diagram/src/test/resources/edge_info_current.svg +++ b/network-area-diagram/src/test/resources/edge_info_current.svg @@ -62,6 +62,7 @@ + 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 6f8af3934..95da6a769 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 @@ -64,6 +64,7 @@ + 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 337b63ee1..175604775 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 @@ -62,6 +62,7 @@ + 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 a7f9a73df..cbe1d4230 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 @@ -62,6 +62,7 @@ + diff --git a/network-area-diagram/src/test/resources/edge_info_reactive_power.svg b/network-area-diagram/src/test/resources/edge_info_reactive_power.svg index 0a65e3f92..48c109fc1 100644 --- a/network-area-diagram/src/test/resources/edge_info_reactive_power.svg +++ b/network-area-diagram/src/test/resources/edge_info_reactive_power.svg @@ -62,6 +62,7 @@ + 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 13132e77d..9b823e634 100644 --- a/network-area-diagram/src/test/resources/edge_info_shift.svg +++ b/network-area-diagram/src/test/resources/edge_info_shift.svg @@ -69,6 +69,7 @@ + diff --git a/network-area-diagram/src/test/resources/edge_with_id.svg b/network-area-diagram/src/test/resources/edge_with_id.svg index a521d92db..71d2ec073 100644 --- a/network-area-diagram/src/test/resources/edge_with_id.svg +++ b/network-area-diagram/src/test/resources/edge_with_id.svg @@ -69,6 +69,7 @@ + diff --git a/network-area-diagram/src/test/resources/edge_without_id.svg b/network-area-diagram/src/test/resources/edge_without_id.svg index 80f12d793..d0b7028ec 100644 --- a/network-area-diagram/src/test/resources/edge_without_id.svg +++ b/network-area-diagram/src/test/resources/edge_without_id.svg @@ -69,6 +69,7 @@ + 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 9f0ee0d1c..69b7e1b0e 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 @@ -59,6 +59,7 @@ + diff --git a/network-area-diagram/src/test/resources/hvdc.svg b/network-area-diagram/src/test/resources/hvdc.svg index 097d20cc4..9a3794e28 100644 --- a/network-area-diagram/src/test/resources/hvdc.svg +++ b/network-area-diagram/src/test/resources/hvdc.svg @@ -69,6 +69,7 @@ + diff --git a/network-area-diagram/src/test/resources/parallel_transformers.svg b/network-area-diagram/src/test/resources/parallel_transformers.svg index e1565c473..bbf9bf584 100644 --- a/network-area-diagram/src/test/resources/parallel_transformers.svg +++ b/network-area-diagram/src/test/resources/parallel_transformers.svg @@ -64,6 +64,7 @@ + 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 7491f39b9..59ef507eb 100644 --- a/network-area-diagram/src/test/resources/simple-eu-loop100.svg +++ b/network-area-diagram/src/test/resources/simple-eu-loop100.svg @@ -159,6 +159,7 @@ + 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 dccd94bd6..a6cf3e09f 100644 --- a/network-area-diagram/src/test/resources/simple-eu-loop80.svg +++ b/network-area-diagram/src/test/resources/simple-eu-loop80.svg @@ -159,6 +159,7 @@ + diff --git a/network-area-diagram/src/test/resources/simple-eu.svg b/network-area-diagram/src/test/resources/simple-eu.svg index 9997b07d2..3ac712277 100644 --- a/network-area-diagram/src/test/resources/simple-eu.svg +++ b/network-area-diagram/src/test/resources/simple-eu.svg @@ -159,6 +159,7 @@ + diff --git a/network-area-diagram/src/test/resources/tie_line.svg b/network-area-diagram/src/test/resources/tie_line.svg index 349d052bd..0bb68441a 100644 --- a/network-area-diagram/src/test/resources/tie_line.svg +++ b/network-area-diagram/src/test/resources/tie_line.svg @@ -66,6 +66,7 @@ + diff --git a/network-area-diagram/src/test/resources/tie_line_filtered.svg b/network-area-diagram/src/test/resources/tie_line_filtered.svg index 3ad1dafb6..0fb2186f5 100644 --- a/network-area-diagram/src/test/resources/tie_line_filtered.svg +++ b/network-area-diagram/src/test/resources/tie_line_filtered.svg @@ -66,6 +66,7 @@ + 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 5561b9897..33ea23bac 100644 --- a/network-area-diagram/src/test/resources/vl_description_id.svg +++ b/network-area-diagram/src/test/resources/vl_description_id.svg @@ -127,6 +127,7 @@ + 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 c4a48668c..d85507d1f 100644 --- a/network-area-diagram/src/test/resources/vl_description_substation.svg +++ b/network-area-diagram/src/test/resources/vl_description_substation.svg @@ -127,6 +127,7 @@ + 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 fa59fbbde..b7c8f332b 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 @@ -127,6 +127,7 @@ + diff --git a/network-area-diagram/src/test/resources/voltage_limits.svg b/network-area-diagram/src/test/resources/voltage_limits.svg index 6d75ea9b9..ba6c16f4b 100644 --- a/network-area-diagram/src/test/resources/voltage_limits.svg +++ b/network-area-diagram/src/test/resources/voltage_limits.svg @@ -64,6 +64,7 @@ +