Migration guide v2.7.0 - powsybl/powsybl-diagram GitHub Wiki
Migrate powsybl-core version to v4.6.0
In this release, powsybl-core version has been updated from version 4.5.1 to 4.6.0. From this release, the base-voltages.yml default file is in powsybl-commons artifact from powsybl-core, instead of in each repository using this configuration class. This allows a unique configuration file across the full powsybl ecosystem. Aside this, no other migration issue should affect you on powsybl-line-diagram. Nonetheless, if you are also using powsybl-core directly, please refer to powsybl-core migration guide to fix any issue due to that migration.
API simplified
Diagram API simplified
In this release, the "Diagram" API has been simplified: classes VoltageLevelDiagram and SubstationDiagram have been removed and replaced by a SingleLineDiagram classes containing only static methods to draw the diagram. For instance, the following example taken from README.md:
ComponentLibrary componentLibrary = new ConvergenceComponentLibrary();
LayoutParameters layoutParameters = new LayoutParameters()
.setAdaptCellHeightToContent(true)
.setCssLocation(LayoutParameters.CssLocation.INSERTED_IN_SVG);
VoltageLevelDiagram
.build(new NetworkGraphBuilder(network), "N", new SmartVoltageLevelLayoutFactory(network), false)
.writeSvg("",
new DefaultSVGWriter(componentLibrary, layoutParameters),
new DefaultDiagramLabelProvider(network, componentLibrary, layoutParameters),
new TopologicalStyleProvider(network),
Paths.get("/tmp/n.svg"));
can be replaced by following single line:
SingleLineDiagram.draw(network, "N", "/tmp/n.svg");
This simpler API introduced following changes or new behaviours:
- The parameter
useNameof diagrams API is now withinLayoutParameter. UseLayoutParameter::setUseNameto change its value. SmartVoltageLevelLayoutFactoryis used by default inSingleLineDiagramclass.TopologicalStyleProvideris used by default inSingleLineDiagramclass, hence the classDefaultDiagramStyleProviderhas been renamed toBasicStyleProvider.- The CSS is embedded by default:
LayoutParameters::getCssLocationisCssLocation.INSERTED_IN_SVGby default. - The cell height is adapted to content by default:
LayoutParameters::isAdaptCellHeightToContentistrueby default.
SVGWriter API simplified
In this release, the SVGWriter interface has been simplified. All methods have been replaced by a single one:
GraphMetadata write(String prefixId, Graph graph, DiagramLabelProvider initProvider, DiagramStyleProvider styleProvider, Writer writer);
If you were using the methods with a Writer this change should be transparent.
If you were using the methods with a Path, either use the new SingleLineDiagram API, or create a Writer from your Path.
Layout interfaces merged
Starting from this release, the SubstationLayout, VoltageLevelLayout and ZoneLayoutlayout interfaces have been merged into a single Layout interface.
Replacing ambiguous getters
getNodes
Starting from this release, node keyword is used only for Node class, and not anymore for nodes (meaning vertices) of ZoneGraph and SubstationGraph. Hence the methods SubstationGraph::getNodes and ZoneGraph::getNodes are renamed to Graph::getVoltageLevels and ZoneGraph::getSubstations respectively. A new method has been introduced to access all the nodes corresponding to a graph: Graph::getAllNodesStream.
getGraph
Starting from this release, graph keyword is used only for Graph class, and not anymore for VoltageLevelGraph class (unless when obvious). This way:
- method
Node::getGraphhas been renamed toNode::getVoltageLevelGraph - method
LBSCluster::getGraphhas been renamed toLBSCluster::getVoltageLevelGraph - method
Block::getGraphhas been renamed toBlock::getVoltageLevelGraph - method
Cell::getGraphhas been renamed toCell::getVoltageLevelGraph
Nonetheless, RawGraphBuilder.VoltageLevelBuilder::getGraph has been kept and RawGraphBuilder.SubstationBuilder::getSsGraph has been replaced by RawGraphBuilder.SubstationBuilder::getGraph, as the substation keyword is already held by the builder class.