Layouts¶
A layout is the way in which the elements of a graph are arranged.
It is possible to use your own graph layout implementation, but there are also existing layouts in powsybl-diagram, ready to use.
Layouts for voltage levels¶
Existing implementations¶
PositionVoltageLevelLayout¶
This layout positions the different elements inside a voltage level according to the following process:
Clean the graph to have the expected patterns (see Graph Refiner)
Detect the cells (intern / extern / shunt) (see Cell detection)
Organize the cells into blocks (see CellBlockDecomposer)
Compute real coordinates of busNode and blocks connected to busbars (see PositionFinder)
The PositionVoltageLevelLayoutFactoryParameters class¶
This class gathers the parameters that customize the way PositionVoltageLevelLayout behaves, from the preliminary
graph cleaning (see Graph Refiner) to the block/position computation (see
CellBlockDecomposer and PositionFinder):
feederStacked(defaulttrue): whetherLegPrimaryBlocksharing the same non-bus extremity should be detected and marked as stackable, so that the corresponding feeders can later be stacked on top of each other instead of being spread out horizontally.
Default value ( |
Value changed ( |
removeUnnecessaryFictitiousNodes(defaulttrue): whether theGraphRefinershould remove the redundantFICTITIOUSnodes of the graph (i.e. nodes with only two adjacent edges that can be bypassed with a single edge). Combined withLayoutParameters.adaptCellHeightToContent, keeping these nodes makes the feeder cell taller, since each remaining fictitious node is counted as an extra block when computing the cell height.
Default value ( |
Value changed ( |
substituteSingularFictitiousByFeederNode(defaulttrue): whether theGraphRefinershould replaceINTERNALnodes having a single neighbor by a fictitiousFeederNode.
Default value ( |
Value changed ( |
substituteInternalMiddle2wtByEquipmentNodes(defaulttrue): whether theGraphRefinershould replace, by simpleEquipmentNode, the feeder/middle nodes of a two-winding transformer whose both ends are in the same voltage level, in order to avoid unnecessary snake lines.
Default value ( |
Value changed ( |
exceptionIfPatternNotHandled(defaultfalse): whether an exception should be thrown when the block decomposition algorithm cannot fully merge the blocks of a cell (see CellBlockDecomposer); whenfalse, the remaining blocks are simply gathered into anUndefinedBlockand the diagram building continues.
|
|
|---|---|
Default value ( |
Value changed ( |
handleShunts(defaultfalse): whetherPositionFinderimplementations should takeShuntCellinto account when computing theList<Subsection>(see Subsection). Below,loadAandloadBare linked by a shunt jumper, whileloadMidis an unrelated feeder attached in between them on the busbar. With the defaultfalse, the shunt jumper is not taken into account when ordering the feeders, soloadMidstays betweenloadAandloadB, and the jumper wire ends up crossing straight throughloadMid’s own wire. Withtrue,loadMidis moved out of the way (to the left ofloadA), leaving a clean, crossing-free path for the jumper betweenloadAandloadB(at the cost of a wider diagram).
Default value ( |
Value changed ( |
busInfoMap(default empty): a map giving, for someBusNodeids, on whichSide(LEFT/RIGHT) extra information about the bus should be displayed; this is taken into account byBlockPositionnerto reserve the corresponding space. Below, two busbar sections (bbs1andbbs2) connected by a sectionalizing breaker have bus info indicators configured on the left and right sides respectively (bbs1 -> Side.LEFT,bbs2 -> Side.RIGHT). With the default empty map, no extra space is reserved for the indicators, causing them to overlap right on top of their adjacent feeder connections and switches. WithbusInfoMapconfigured,BlockPositionnerextends each busbar section by reserving a dedicated cell on the specified side, completely separating the indicators from the feeders.
Default value ( |
Value changed ( |
The PositionFinder class¶
The PositionFinder interface, and its available implementations (PositionPredefined and PositionByClustering),
are described in a dedicated page: see Position of BusNodes and Cells order.
RandomVoltageLevelLayout¶
With this layout, the graph node coordinates are randomly fixed:
Between 0 and
widthfor the x coordinate;Between 0 and
heightfor the y coordinate. Thewidthandheightvariables are provided by the user.
CgmesVoltageLevelLayout¶
With this layout, the elements of the graph are arranged according to the data included in the CGMES DL profile.
Choosing a VoltageLevelLayout¶
The voltageLevelLayoutFactoryCreator attribute in the SldParameters class is the customization parameter to use to choose a specific VoltageLevelLayout.
The VoltageLevelLayoutFactoryCreator creates a VoltageLevelLayoutFactory which in turn creates a VoltageLevelLayout.
Choose a specific PositionVoltageLevelLayout¶
Static methods are available in the VoltageLevelLayoutFactoryCreator interface to help users manipulate those objects.
Some examples are shown below.
Example 1
PositionVoltageLevelLayout using default parameters:
VoltageLevelLayoutFactoryCreator voltageLevelLayoutFactoryCreator = VoltageLevelLayoutFactoryCreator.newPositionVoltageLevelLayoutFactoryCreator();
SldParameters sldParameters = new SldParameters().setVoltageLevelLayoutFactoryCreator(voltageLevelLayoutFactoryCreator);
Example 2
PositionVoltageLevelLayout with a chosen PositionFinder:
VoltageLevelLayoutFactoryCreator voltageLevelLayoutFactoryCreator = VoltageLevelLayoutFactoryCreator.newPositionVoltageLevelLayoutFactoryCreator(positionFinder);
SldParameters sldParameters = new SldParameters().setVoltageLevelLayoutFactoryCreator(voltageLevelLayoutFactoryCreator);
Example 3
PositionVoltageLevelLayout with chosen PositionVoltageLevelLayoutFactoryParameters:
VoltageLevelLayoutFactoryCreator voltageLevelLayoutFactoryCreator = VoltageLevelLayoutFactoryCreator.newPositionVoltageLevelLayoutFactoryCreator(positionVoltageLevelLayoutFactoryParameters);
SldParameters sldParameters = new SldParameters().setVoltageLevelLayoutFactoryCreator(voltageLevelLayoutFactoryCreator);
Example 4
PositionVoltageLevelLayout with a chosen PositionFinder and chosen PositionVoltageLevelLayoutFactoryParameters:
VoltageLevelLayoutFactoryCreator voltageLevelLayoutFactoryCreator = VoltageLevelLayoutFactoryCreator.newPositionVoltageLevelLayoutFactoryCreator(positionFinder, positionVoltageLevelLayoutFactoryParameters);
SldParameters sldParameters = new SldParameters().setVoltageLevelLayoutFactoryCreator(voltageLevelLayoutFactoryCreator);
Use the SmartVoltageLevelLayoutFactory¶
The SmartVoltageLevelLayoutFactory picks the “best” VoltageLevelLayout according to the information available in the network.
There is also a static method in the VoltageLevelLayoutFactoryCreator interface to help users pick the SmartVoltageLevelLayoutFactory:
VoltageLevelLayoutFactoryCreator voltageLevelLayoutFactoryCreator = VoltageLevelLayoutFactoryCreator.newSmartVoltageLevelLayoutFactoryCreator();
SldParameters sldParameters = new SldParameters().setVoltageLevelLayoutFactoryCreator(voltageLevelLayoutFactoryCreator);
Creating and using your own VoltageLevelLayout¶
A VoltageLevelLayout only has to implement the Layout interface, i.e. implement a run(LayoutParameters layoutParameters)
method, in charge of computing the coordinates of the nodes of the VoltageLevelGraph it was built from
(typically by iterating over graph.getNodes() and setting node.setX(...) / node.setY(...), as done for instance
by RandomVoltageLevelLayout). The AbstractVoltageLevelLayout class can be extended to get direct access to the
underlying VoltageLevelGraph (through getGraph()), but this is not mandatory.
You will also need a VoltageLevelLayoutFactory, whose only purpose is to create your VoltageLevelLayout instances
from a VoltageLevelGraph:
public class MyVoltageLevelLayout implements Layout {
// ...
@Override
public void run(LayoutParameters layoutParameters) {
// compute the coordinates of the nodes of the graph
}
}
public class MyVoltageLevelLayoutFactory implements VoltageLevelLayoutFactory {
@Override
public Layout create(VoltageLevelGraph graph) {
return new MyVoltageLevelLayout(graph);
}
}
Once your VoltageLevelLayoutFactory is ready, you can use it in the SldParameters class,
either directly:
SldParameters sldParameters = new SldParameters().setVoltageLevelLayoutFactoryCreator(network -> new MyVoltageLevelLayoutFactory());
or by wrapping it into a VoltageLevelLayoutFactoryCreator, which gives you access to the Network if your factory
needs it:
VoltageLevelLayoutFactoryCreator voltageLevelLayoutFactoryCreator = network -> new MyVoltageLevelLayoutFactory();
SldParameters sldParameters = new SldParameters().setVoltageLevelLayoutFactoryCreator(voltageLevelLayoutFactoryCreator);
Note
The following voltage level layout factories are available: SmartVoltageLevelLayoutFactory (the default), CgmesVoltageLevelLayoutFactory, RandomVoltageLevelLayoutFactory, PositionVoltageLevelLayoutFactory
Layouts for substations¶
A substation layout arranges, relative to one another, the VoltageLevelGraph of the different VoltageLevel of a
substation (each one already laid out thanks to a VoltageLevelLayout), and computes the snake lines connecting them
(the edges of the SubstationGraph, see Requirements for implementing a custom GraphBuilder).
Existing implementations¶
HorizontalSubstationLayout¶
With this layout, the VoltageLevelGraph are placed side by side horizontally, ordered as they were added to the
SubstationGraph (by default, NetworkGraphBuilder adds them by descending nominal voltage), and vertically aligned according to the
LayoutParameters.getBusbarsAlignment() parameter (aligning on the first, the last, or the middle busbar section, or
without any alignment).
VerticalSubstationLayout¶
With this layout, the VoltageLevelGraph are stacked vertically, ordered as they appear in the SubstationGraph
(i.e. by descending nominal voltage), each one below the previous one.
Choosing a SubstationLayout¶
The substationLayoutFactory attribute in the SldParameters class is the customization
parameter to use to choose a specific SubstationLayout: it takes a SubstationLayoutFactory, for example a
HorizontalSubstationLayoutFactory (the default) or a VerticalSubstationLayoutFactory.
SldParameters sldParameters = new SldParameters().setSubstationLayoutFactory(new VerticalSubstationLayoutFactory());
Creating and using your own SubstationLayout¶
Similarly, a SubstationLayout also has to implement the Layout interface. Its run(LayoutParameters layoutParameters)
method is in charge of positioning the different VoltageLevelGraph of the SubstationGraph relative to one another
(each of them being already laid out thanks to its own VoltageLevelLayout), and of computing the coordinates of the
snake lines connecting them.
The corresponding SubstationLayoutFactory creates your SubstationLayout instances from a SubstationGraph and the
VoltageLevelLayoutFactory used to lay out each VoltageLevelGraph:
public class MySubstationLayout implements Layout {
// ...
@Override
public void run(LayoutParameters layoutParameters) {
// position the voltage level graphs relative to each other and compute the snake lines
}
}
public class MySubstationLayoutFactory implements SubstationLayoutFactory {
@Override
public Layout create(SubstationGraph graph, VoltageLevelLayoutFactory vLayoutFactory) {
return new MySubstationLayout(graph, vLayoutFactory);
}
}
Your SubstationLayoutFactory can then be set in the SldParameters class:
SldParameters sldParameters = new SldParameters().setSubstationLayoutFactory(new MySubstationLayoutFactory());
Note
The following substation layout factories are available HorizontalSubstationLayoutFactory (the default) or a VerticalSubstationLayoutFactory
Layouts for multi-substation graphs¶
Multi-substation graphs can use a matrix-like layout for the different substations. See Zone Matrix Layout for more details.