Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Commit

Permalink
Fix code smell
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
  • Loading branch information
flo-dup committed Jan 25, 2022
1 parent 88d255a commit 17eb406
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/powsybl/nad/layout/AbstractLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void run(Graph graph, LayoutParameters layoutParameters) {
busNodesLayout(graph, layoutParameters);
edgesLayout(graph, layoutParameters);

computeSize(graph, layoutParameters);
computeSize(graph);
}

protected abstract void nodesLayout(Graph graph, LayoutParameters layoutParameters);
Expand All @@ -38,7 +38,7 @@ private void setEdgeVisibility(Node node, BranchEdge branchEdge, BranchEdge.Side
}
}

private void computeSize(Graph graph, LayoutParameters layoutParameters) {
private void computeSize(Graph graph) {
double[] dims = new double[4];
Stream.concat(graph.getTextNodesStream(), graph.getNodesStream()).forEach(node -> {
dims[0] = Math.min(dims[0], node.getX());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/powsybl/nad/model/TextNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
public class TextNode extends AbstractNode {

private final String text;
private static int counter = 0;

public TextNode(String diagramId, String text) {
super(diagramId, null, null);
this.text = Objects.requireNonNull(text);
this.text = Objects.requireNonNull("VL" + counter++);
}

public String getText() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/powsybl/nad/AbstractTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public abstract class AbstractTest {

protected boolean debugSvg = false;
protected boolean debugSvg = true;
protected boolean overrideTestReferences = false;

protected abstract LayoutParameters getLayoutParameters();
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/com/powsybl/nad/svg/TopologicalStyleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.powsybl.nad.svg;

import com.powsybl.ieeecdf.converter.IeeeCdfNetworkFactory;
import com.powsybl.iidm.import_.Importers;
import com.powsybl.iidm.network.Network;
import com.powsybl.nad.AbstractTest;
import com.powsybl.nad.build.iidm.VoltageLevelFilter;
Expand Down Expand Up @@ -53,6 +54,29 @@ protected LabelProvider getLabelProvider(Network network) {
return new DefaultLabelProvider(network);
}

@Test
void testLille() {
Network network = Importers.loadNetwork("/home/dupuyflo/Data/LILLE.xiidm");
// LoadFlow.run(network);
VoltageLevelFilter pgasp = VoltageLevelFilter.createVoltageLevelDepthFilter(network, "P.GASP1", 3);
generateSvgString(network, pgasp, "/pgasp.svg");
VoltageLevelFilter tdvap = VoltageLevelFilter.createVoltageLevelDepthFilter(network, ".TDVAP7", 3);
generateSvgString(network, tdvap, "/tdvap.svg");
VoltageLevelFilter choc = VoltageLevelFilter.createVoltageLevelDepthFilter(network, "CHOC5P4", 3);
generateSvgString(network, choc, "/choc.svg");
VoltageLevelFilter ftai = VoltageLevelFilter.createVoltageLevelDepthFilter(network, "FTAI6P4", 3);
generateSvgString(network, ftai, "/ftai.svg");
VoltageLevelFilter torcy = VoltageLevelFilter.createVoltageLevelDepthFilter(network, "TORCYP3", 3);
generateSvgString(network, torcy, "/torcy.svg");
generateSvgString(network, "/LILLE.svg");
}

// @Test
// void testFrance() {
// Network network = Importers.loadNetwork("/home/dupuyflo/Data/demoCs.xiidm");
// assertEquals(toString("/IEEE_30_bus.svg"), generateSvgString(network, "/France.svg"));
// }

@Test
void testIEEE57() {
Network network = IeeeCdfNetworkFactory.create57();
Expand Down

0 comments on commit 17eb406

Please sign in to comment.