Skip to content

Commit

Permalink
Add method to move Substation & fix VerticalZoneLayout::adaptPaddingT…
Browse files Browse the repository at this point in the history
…oSnakeLines

Signed-off-by: Thomas ADAM <tadam@silicom.fr>
  • Loading branch information
tadam50 committed Sep 20, 2023
1 parent 97a98b4 commit 8508c30
Show file tree
Hide file tree
Showing 7 changed files with 629 additions and 622 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
package com.powsybl.sld.layout;

import com.powsybl.sld.model.graphs.SubstationGraph;
import com.powsybl.sld.model.graphs.VoltageLevelGraph;
import com.powsybl.sld.model.graphs.ZoneGraph;

import java.util.Objects;
Expand All @@ -15,7 +17,6 @@
* @author Thomas Adam <tadam at silicom.fr>
*/
public abstract class AbstractZoneLayout extends AbstractBaseLayout<ZoneGraph> {

protected SubstationLayoutFactory sLayoutFactory;
protected VoltageLevelLayoutFactory vLayoutFactory;

Expand All @@ -35,4 +36,10 @@ public void run(LayoutParameters layoutParameters) {
}

protected abstract void calculateCoordSubstations(LayoutParameters layoutParameters);

protected void move(SubstationGraph subGraph, double dx, double dy) {
for (VoltageLevelGraph vlGraph : subGraph.getVoltageLevels()) {
vlGraph.setCoord(vlGraph.getX() + dx, vlGraph.getY() + dy);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ protected void calculateCoordSubstations(LayoutParameters layoutParameters) {
// Calculate the objects coordinates inside the zone graph
Layout sLayout = sLayoutFactory.create(subGraph, vLayoutFactory);
sLayout.run(layoutParameters);
for (VoltageLevelGraph vlGraph : subGraph.getVoltageLevels()) {
vlGraph.setCoord(vlGraph.getX() + zoneWidth, vlGraph.getY());
}

move(subGraph, zoneWidth, 0);

zoneWidth += subGraph.getWidth();
zoneHeight = Math.max(zoneHeight, subGraph.getHeight());
}
Expand All @@ -76,9 +76,7 @@ public void manageSnakeLines(LayoutParameters layoutParameters) {
private void adaptPaddingToSnakeLines(LayoutParameters layoutParameters) {
double heightSnakeLinesTop = AbstractLayout.getHeightSnakeLines(layoutParameters, TOP, infosNbSnakeLines);
for (SubstationGraph subGraph : getGraph().getSubstations()) {
for (VoltageLevelGraph vlGraph : subGraph.getVoltageLevels()) {
vlGraph.setCoord(vlGraph.getX(), vlGraph.getY() + heightSnakeLinesTop);
}
move(subGraph, 0, heightSnakeLinesTop);
}
double heightSnakeLinesBottom = AbstractLayout.getHeightSnakeLines(layoutParameters, BOTTOM, infosNbSnakeLines);
double zoneHeight = getGraph().getHeight() + heightSnakeLinesTop + heightSnakeLinesBottom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ protected void calculateCoordSubstations(LayoutParameters layoutParameters) {
Layout sLayout = sLayoutFactory.create(subGraph, vLayoutFactory);
sLayout.run(layoutParameters);

for (VoltageLevelGraph vlGraph : subGraph.getVoltageLevels()) {
vlGraph.setCoord(vlGraph.getX(), vlGraph.getY() + zoneHeight);
}
move(subGraph, 0, zoneHeight);

zoneHeight += subGraph.getHeight() - diagramPadding.getTop();
zoneWidth = Math.max(zoneWidth, subGraph.getWidth());
}
Expand Down Expand Up @@ -106,8 +105,11 @@ private void adaptPaddingToSnakeLines(LayoutParameters layoutParameters) {
double y = diagramPadding.getTop()
+ getGraph().getVoltageLevelStream().findFirst().map(vlg -> getHeightHorizontalSnakeLines(vlg.getId(), TOP, layoutParameters)).orElse(0.);

for (SubstationGraph subGraph : getGraph().getSubstations()) {
move(subGraph, widthSnakeLinesLeft, y + voltageLevelPadding.getTop());
}

for (VoltageLevelGraph vlGraph : getGraph().getVoltageLevels()) {
vlGraph.setCoord(diagramPadding.getLeft() + voltageLevelPadding.getLeft() + widthSnakeLinesLeft, y + voltageLevelPadding.getTop());
y += vlGraph.getHeight() + getHeightHorizontalSnakeLines(vlGraph.getId(), BOTTOM, layoutParameters);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"nominalVoltage" : 380.0
},
"x" : 261.0,
"y" : 271.0,
"y" : 512.0,
"nodes" : [ {
"type" : "INTERNAL",
"id" : "INTERNAL_vl1_dgen1-bgen1",
Expand Down Expand Up @@ -2812,8 +2812,8 @@
"name" : "vl2",
"nominalVoltage" : 225.0
},
"x" : 261.0,
"y" : 880.0,
"x" : 1191.0,
"y" : 512.0,
"nodes" : [ {
"type" : "INTERNAL",
"id" : "INTERNAL_vl2_dgen4-bgen4",
Expand Down Expand Up @@ -4464,8 +4464,8 @@
"name" : "vl3",
"nominalVoltage" : 225.0
},
"x" : 261.0,
"y" : 1459.0,
"x" : 1841.0,
"y" : 512.0,
"nodes" : [ {
"type" : "INTERNAL",
"id" : "INTERNAL_vl3_dload4-bload4",
Expand Down Expand Up @@ -5301,7 +5301,7 @@
"componentType" : "TWO_WINDINGS_TRANSFORMER",
"fictitious" : true,
"x" : 241.0,
"y" : 455.5,
"y" : 696.5,
"orientation" : "DOWN",
"name" : "trf1",
"equipmentId" : "trf1",
Expand All @@ -5321,7 +5321,7 @@
"componentType" : "TWO_WINDINGS_TRANSFORMER",
"fictitious" : true,
"x" : 211.0,
"y" : 745.0,
"y" : 681.5,
"orientation" : "DOWN",
"name" : "trf2",
"equipmentId" : "trf2",
Expand All @@ -5341,8 +5341,7 @@
"componentType" : "TWO_WINDINGS_TRANSFORMER",
"fictitious" : true,
"x" : 181.0,
"y" : 1034.5,
"orientation" : "DOWN",
"y" : 971.0,
"name" : "trf3",
"equipmentId" : "trf3",
"voltageLevelInfosLeg1" : {
Expand All @@ -5360,9 +5359,9 @@
"id" : "trf4",
"componentType" : "TWO_WINDINGS_TRANSFORMER",
"fictitious" : true,
"x" : 736.0,
"y" : 760.0,
"orientation" : "LEFT",
"x" : 1201.0,
"y" : 632.0,
"orientation" : "RIGHT",
"name" : "trf4",
"equipmentId" : "trf4",
"voltageLevelInfosLeg1" : {
Expand All @@ -5381,7 +5380,7 @@
"componentType" : "TWO_WINDINGS_TRANSFORMER",
"fictitious" : true,
"x" : 151.0,
"y" : 1007.0,
"y" : 654.0,
"orientation" : "DOWN",
"name" : "trf5",
"equipmentId" : "trf5",
Expand All @@ -5400,8 +5399,9 @@
"id" : "trf6",
"componentType" : "THREE_WINDINGS_TRANSFORMER",
"fictitious" : true,
"x" : 636.0,
"y" : 790.0,
"x" : 1566.0,
"y" : 1031.0,
"orientation" : "DOWN",
"name" : "trf6",
"equipmentId" : "trf6",
"voltageLevelInfosLeg1" : {
Expand All @@ -5424,8 +5424,8 @@
"id" : "trf7",
"componentType" : "THREE_WINDINGS_TRANSFORMER",
"fictitious" : true,
"x" : 586.0,
"y" : 820.0,
"x" : 1516.0,
"y" : 1061.0,
"name" : "trf7",
"equipmentId" : "trf7",
"voltageLevelInfosLeg1" : {
Expand All @@ -5448,8 +5448,8 @@
"id" : "trf8",
"componentType" : "THREE_WINDINGS_TRANSFORMER",
"fictitious" : true,
"x" : 686.0,
"y" : 1399.0,
"x" : 1616.0,
"y" : 662.0,
"orientation" : "DOWN",
"name" : "trf8",
"equipmentId" : "trf8",
Expand All @@ -5475,133 +5475,133 @@
"node1" : "trf1_ONE",
"node2" : "trf1"
} ],
"snakeLine" : [ 436.0, 271.0, 436.0, 211.0, 241.0, 211.0, 241.0, 455.5 ]
"snakeLine" : [ 436.0, 512.0, 436.0, 452.0, 241.0, 452.0, 241.0, 696.5 ]
}, {
"id" : "EDGE_trf1_TWO",
"nodes" : [ {
"node1" : "trf1_TWO",
"node2" : "trf1"
} ],
"snakeLine" : [ 436.0, 880.0, 436.0, 700.0, 241.0, 700.0, 241.0, 455.5 ]
"snakeLine" : [ 1366.0, 512.0, 1366.0, 941.0, 241.0, 941.0, 241.0, 696.5 ]
}, {
"id" : "EDGE_trf2_ONE",
"nodes" : [ {
"node1" : "trf2_ONE",
"node2" : "trf2"
} ],
"snakeLine" : [ 986.0, 271.0, 986.0, 181.0, 211.0, 181.0, 211.0, 745.0 ]
"snakeLine" : [ 986.0, 512.0, 986.0, 422.0, 211.0, 422.0, 211.0, 681.5 ]
}, {
"id" : "EDGE_trf2_TWO",
"nodes" : [ {
"node1" : "trf2_TWO",
"node2" : "trf2"
} ],
"snakeLine" : [ 736.0, 1249.0, 736.0, 1309.0, 211.0, 1309.0, 211.0, 745.0 ]
"snakeLine" : [ 1666.0, 881.0, 1666.0, 941.0, 211.0, 941.0, 211.0, 681.5 ]
}, {
"id" : "EDGE_trf3_ONE",
"nodes" : [ {
"node1" : "trf3_ONE",
"node2" : "trf3"
} ],
"snakeLine" : [ 536.0, 640.0, 536.0, 730.0, 181.0, 730.0, 181.0, 1034.5 ]
"snakeLine" : [ 536.0, 881.0, 536.0, 971.0, 181.0, 971.0, 181.0, 971.0 ]
}, {
"id" : "EDGE_trf3_TWO",
"nodes" : [ {
"node1" : "trf3_TWO",
"node2" : "trf3"
} ],
"snakeLine" : [ 786.0, 1249.0, 786.0, 1339.0, 181.0, 1339.0, 181.0, 1034.5 ]
"snakeLine" : [ 1716.0, 881.0, 1716.0, 971.0, 181.0, 971.0, 181.0, 971.0 ]
}, {
"id" : "EDGE_trf4_ONE",
"nodes" : [ {
"node1" : "trf4_ONE",
"node2" : "trf4"
} ],
"snakeLine" : [ 936.0, 640.0, 936.0, 760.0, 736.0, 760.0 ]
"snakeLine" : [ 936.0, 881.0, 936.0, 632.0, 1201.0, 632.0 ]
}, {
"id" : "EDGE_trf4_TWO",
"nodes" : [ {
"node1" : "trf4_TWO",
"node2" : "trf4"
} ],
"snakeLine" : [ 536.0, 880.0, 536.0, 760.0, 736.0, 760.0 ]
"snakeLine" : [ 1466.0, 512.0, 1466.0, 632.0, 1201.0, 632.0 ]
}, {
"id" : "EDGE_trf5_ONE",
"nodes" : [ {
"node1" : "trf5_ONE",
"node2" : "trf5"
} ],
"snakeLine" : [ 586.0, 271.0, 586.0, 151.0, 151.0, 151.0, 151.0, 1007.0 ]
"snakeLine" : [ 586.0, 512.0, 586.0, 392.0, 151.0, 392.0, 151.0, 654.0 ]
}, {
"id" : "EDGE_trf5_TWO",
"nodes" : [ {
"node1" : "trf5_TWO",
"node2" : "trf5"
} ],
"snakeLine" : [ 336.0, 1803.0, 336.0, 1863.0, 151.0, 1863.0, 151.0, 1007.0 ]
"snakeLine" : [ 1916.0, 856.0, 1916.0, 916.0, 151.0, 916.0, 151.0, 654.0 ]
}, {
"id" : "EDGE_trf6_ONE",
"nodes" : [ {
"node1" : "trf6_ONE",
"node2" : "trf6"
} ],
"snakeLine" : [ 636.0, 271.0, 636.0, 121.0, 121.0, 121.0, 121.0, 790.0, 636.0, 790.0 ]
"snakeLine" : [ 636.0, 512.0, 636.0, 362.0, 121.0, 362.0, 121.0, 1031.0, 1566.0, 1031.0 ]
}, {
"id" : "EDGE_trf6_TWO",
"nodes" : [ {
"node1" : "trf6_TWO",
"node2" : "trf6"
} ],
"snakeLine" : [ 636.0, 880.0, 636.0, 790.0 ]
"snakeLine" : [ 1566.0, 512.0, 1566.0, 1031.0 ]
}, {
"id" : "EDGE_trf6_THREE",
"nodes" : [ {
"node1" : "trf6_THREE",
"node2" : "trf6"
} ],
"snakeLine" : [ 386.0, 1459.0, 386.0, 1369.0, 2111.0, 1369.0, 2111.0, 790.0, 636.0, 790.0 ]
"snakeLine" : [ 1966.0, 512.0, 1966.0, 1001.0, 3041.0, 1001.0, 3041.0, 1031.0, 1566.0, 1031.0 ]
}, {
"id" : "EDGE_trf7_ONE",
"nodes" : [ {
"node1" : "trf7_ONE",
"node2" : "trf7"
} ],
"snakeLine" : [ 686.0, 640.0, 686.0, 820.0, 586.0, 820.0 ]
"snakeLine" : [ 686.0, 881.0, 686.0, 692.0, 1516.0, 692.0 ]
}, {
"id" : "EDGE_trf7_TWO",
"nodes" : [ {
"node1" : "trf7_TWO",
"node2" : "trf7"
} ],
"snakeLine" : [ 586.0, 880.0, 586.0, 820.0 ]
"snakeLine" : [ 1516.0, 512.0, 1516.0, 692.0 ]
}, {
"id" : "EDGE_trf7_THREE",
"nodes" : [ {
"node1" : "trf7_THREE",
"node2" : "trf7"
} ],
"snakeLine" : [ 436.0, 1803.0, 436.0, 1893.0, 2141.0, 1893.0, 2141.0, 820.0, 586.0, 820.0 ]
"snakeLine" : [ 2016.0, 856.0, 2016.0, 946.0, 3071.0, 946.0, 3071.0, 1061.0, 1516.0, 1061.0 ]
}, {
"id" : "EDGE_trf8_ONE",
"nodes" : [ {
"node1" : "trf8_ONE",
"node2" : "trf8"
} ],
"snakeLine" : [ 886.0, 271.0, 886.0, 91.0, 91.0, 91.0, 91.0, 1399.0, 686.0, 1399.0 ]
"snakeLine" : [ 886.0, 512.0, 886.0, 332.0, 91.0, 332.0, 91.0, 1031.0, 1616.0, 1031.0 ]
}, {
"id" : "EDGE_trf8_TWO",
"nodes" : [ {
"node1" : "trf8_TWO",
"node2" : "trf8"
} ],
"snakeLine" : [ 686.0, 1249.0, 686.0, 1399.0 ]
"snakeLine" : [ 1616.0, 881.0, 1616.0, 1031.0 ]
}, {
"id" : "EDGE_trf8_THREE",
"nodes" : [ {
"node1" : "trf8_THREE",
"node2" : "trf8"
} ],
"snakeLine" : [ 486.0, 1459.0, 486.0, 1399.0, 686.0, 1399.0 ]
"snakeLine" : [ 2066.0, 512.0, 2066.0, 662.0, 1616.0, 662.0 ]
} ],
"lineEdges" : [ ]
}, {
Expand All @@ -5613,7 +5613,7 @@
"nominalVoltage" : 380.0
},
"x" : 261.0,
"y" : 2043.0,
"y" : 1150.0,
"nodes" : [ {
"type" : "INTERNAL",
"id" : "INTERNAL_vlSubst2_dhvdc_lcc21_2-bhvdc_lcc21_2",
Expand Down Expand Up @@ -6129,20 +6129,20 @@
"node1" : "line1_ONE",
"node2" : "line1_TWO"
} ],
"snakeLine" : [ 736.0, 271.0, 736.0, 61.0, 61.0, 61.0, 61.0, 1923.0, 386.0, 1923.0, 386.0, 2043.0 ]
"snakeLine" : [ 736.0, 512.0, 736.0, 302.0, 61.0, 302.0, 61.0, 976.0, 386.0, 976.0, 386.0, 1150.0 ]
}, {
"id" : "hvdc_lcc",
"nodes" : [ {
"node1" : "hvdc_lcc_ONE",
"node2" : "hvdc_lcc_TWO"
} ],
"snakeLine" : [ 286.0, 271.0, 286.0, 31.0, 31.0, 31.0, 31.0, 1953.0, 286.0, 1953.0, 286.0, 2043.0 ]
"snakeLine" : [ 286.0, 512.0, 286.0, 272.0, 31.0, 272.0, 31.0, 1006.0, 286.0, 1006.0, 286.0, 1150.0 ]
}, {
"id" : "hvdc_vsc",
"nodes" : [ {
"node1" : "hvdc_vsc_ONE",
"node2" : "hvdc_vsc_TWO"
} ],
"snakeLine" : [ 336.0, 271.0, 336.0, 1.0, 1.0, 1.0, 1.0, 1983.0, 336.0, 1983.0, 336.0, 2043.0 ]
"snakeLine" : [ 336.0, 512.0, 336.0, 242.0, 1.0, 242.0, 1.0, 1036.0, 336.0, 1036.0, 336.0, 1150.0 ]
} ]
}
Loading

0 comments on commit 8508c30

Please sign in to comment.