Zone Matrix Layout¶
In this layout, the substations are displayed like elements of a matrix (rows and columns). The user can choose the location of each substation.
Input parameters¶
VoltageLevelLayoutFactory: builder of the layout used by voltage levelsSubstationLayoutFactory: builder of the layout used by substations2D String array: substation matrix position (ex:{{"A", "B", "C"}}= 1 row, 3 columns)
Usage example: The following example displays three substations distributed on two columns and two lines, with an empty area at the middle of the second line.
// build zone graph
Network network = ...
List<String> zone = Arrays.asList("A", "B", "C");
ZoneGraph g = new NetworkGraphBuilder(network).buildZoneGraph(zone);
// Create substation 2D array representation
String[][] substationsIds = {{"A", "B"},
{"D", ""}};
// Create matrix zone layout using 2D array
ZoneLayoutPathFinderFactory pFinderFactory = DijkstraPathFinder::new;
SubstationLayoutFactory sFactory = new HorizontalSubstationLayoutFactory();
VoltageLevelLayoutFactory vFactory = new PositionVoltageLevelLayoutFactory();
MatrixZoneLayoutFactory mFactory = new MatrixZoneLayoutFactory();
Layout matrixLayout = mFactory.create(g, substationsIds, pFinderFactory, sFactory, vFactory);
// Apply matrix zone layout
matrixLayout.run(layoutParameters);
Path finding description¶
Premise:¶
The column width is computed for each column as the maximum width of all the substations on the column
The row height is computed for each row as the maximum height of all the substations on the row
Snakeline lane dimensions (both horizontal and vertical) are set with
LayoutParameters.setZoneLayoutSnakeLinePadding
Example:
ZonePadding |
ZonePadding |
|||||||
|---|---|---|---|---|---|---|---|---|
VL TOP Padding |
VL TOP Padding |
|||||||
ZonePadding |
VL LEFT Padding |
A |
VL RIGHT Padding |
ZonePadding |
VL LEFT Padding |
B |
VL RIGHT Padding |
ZonePadding |
VL BOTTOM Padding |
VL BOTTOM Padding |
|||||||
ZonePadding |
ZonePadding |
|||||||
VL TOP Padding |
VL TOP Padding |
|||||||
ZonePadding |
VL LEFT Padding |
D |
VL RIGHT Padding |
ZonePadding |
VL LEFT Padding |
_ |
VL RIGHT Padding |
ZonePadding |
VL BOTTOM Padding |
VL BOTTOM Padding |
|||||||
ZonePadding |
ZonePadding |
The class MatrixZoneLayout represents the matrix layout.
The class MatrixZoneLayoutModel represents the matrix and the path finder information.
The class Matrix contains an array of MatrixCell.
The class MatrixCell stores information related to the matrix cell:
Position (indices) in the matrix: row, column
The id of the substation graph contained by the cell
Substation positioning¶
In the
MatrixZoneLayoutconstructor, eachSubstationGraphis added to theMatrixZoneLayoutModel(internal model of matrix layout) as following:
for (int row = 0; row < matrix.length; row++) {
for (int col = 0; col < matrix[row].length; col++) {
String id = matrix[row][col];
SubstationGraph sGraph = graph.getSubstationGraph(id);
if (sGraph == null && !id.isEmpty()) {
throw new PowsyblException("Substation '" + id + "' was not found in zone graph '" + getGraph().getId() + "'");
}
model.addSubstationGraph(sGraph, row, col);
}
}
...
Each substation position is computed using this method:
protected void calculateCoordSubstations(LayoutParameters layoutParameters) {
The SubstationLayout is applied on each not empty substation specified as following:
// Display substations on not empty Matrix cell
matrix.stream().filter(c -> !c.isEmpty()).map(MatrixCell::graph).forEach(graph -> layoutBySubstation.get(graph).run(layoutParameters));
Each substation is moved into its matrix position as specified
Snakeline route computation between substations¶
The Grid class contains a 2D-array of Node, each Node representing a pixel of the SLD output file.
Each Node stores :
A position (x and y)
Availability (whether the
Nodecan be used to draw the snakeline or not)A walk-through cost
A parent node reference
The distance to the end point of the snakeline
Exclusion area¶
An exclusion area is an area where all Node have availability equals to false
This area cannot be used to draw a snakeline.
Those areas are:
diagram padding
voltage levels with padding
snakelines right angles
Shorter path computation¶
Dijkstra’s computation steps:
The starting point cost is set to 0
The nearest neighbors (left, right, up and down) are computed (no diagonal moves allowed here)
These neighbors are used only if:
The neighbor is available
The neighbor was not yet visited
To avoid superfluous right angles, the cost is increased when the next point creates a right angle
If no route can be computed by the algorithm, a straight line is drawn from the starting point to the end point of the snakeline (diagonal moves are allowed here)