Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SLD] Add label on all nodes if requested #571

Merged
merged 7 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ public List<NodeLabel> getNodeLabels(Node node, Direction direction) {
Objects.requireNonNull(node);

List<NodeLabel> nodeLabels = new ArrayList<>();
if (node instanceof FeederNode) {
getLabelOrNameOrId(node).ifPresent(label -> nodeLabels.add(new NodeLabel(label, getFeederLabelPosition(node, direction), null)));
} else if (node instanceof BusNode) {
if (node instanceof BusNode) {
getLabelOrNameOrId(node).ifPresent(label -> nodeLabels.add(new NodeLabel(label, getBusLabelPosition(), null)));
} else if (node instanceof FeederNode || svgParameters.isDisplayEquipmentNodesLabel() && node instanceof EquipmentNode) {
getLabelOrNameOrId(node).ifPresent(label -> nodeLabels.add(new NodeLabel(label, getLabelPosition(node, direction), null)));
} else if (svgParameters.isDisplayConnectivityNodesId() && node instanceof ConnectivityNode) {
nodeLabels.add(new NodeLabel(node.getId(), getLabelPosition(node, direction), null));
}

return nodeLabels;
Expand Down Expand Up @@ -93,7 +95,7 @@ protected LabelPosition getMiddle3WTDecoratorPosition(Middle3WTNode node, Direct
0, yShift, true, 0);
}

protected LabelPosition getFeederLabelPosition(Node node, Direction direction) {
protected LabelPosition getLabelPosition(Node node, Direction direction) {
double yShift = -LABEL_OFFSET;
String positionName = "";
double angle = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ public class SvgParameters {
private boolean labelDiagonal = false;
private boolean tooltipEnabled = false;
private boolean svgWidthAndHeightAdded = false;
private SvgParameters.CssLocation cssLocation = SvgParameters.CssLocation.INSERTED_IN_SVG;
private CssLocation cssLocation = CssLocation.INSERTED_IN_SVG;
private boolean avoidSVGComponentsDuplication = false;
private String diagramName = null;
private boolean drawStraightWires = false;
private boolean showGrid = false;
private boolean showInternalNodes = false;
private boolean displayCurrentFeederInfo = false;
private boolean displayEquipmentNodesLabel;
private boolean displayConnectivityNodesId;

public SvgParameters() {
}
Expand Down Expand Up @@ -84,6 +86,8 @@ public SvgParameters(SvgParameters other) {
this.showGrid = other.showGrid;
this.showInternalNodes = other.showInternalNodes;
this.displayCurrentFeederInfo = other.displayCurrentFeederInfo;
this.displayEquipmentNodesLabel = other.displayEquipmentNodesLabel;
this.displayConnectivityNodesId = other.displayConnectivityNodesId;
}

public ValueFormatter createValueFormatter() {
Expand Down Expand Up @@ -349,4 +353,22 @@ public SvgParameters setDisplayCurrentFeederInfo(boolean displayCurrentFeederInf
this.displayCurrentFeederInfo = displayCurrentFeederInfo;
return this;
}

public boolean isDisplayEquipmentNodesLabel() {
return displayEquipmentNodesLabel;
}

public SvgParameters setDisplayEquipmentNodesLabel(boolean displayEquipmentNodesLabel) {
this.displayEquipmentNodesLabel = displayEquipmentNodesLabel;
return this;
}

public boolean isDisplayConnectivityNodesId() {
return displayConnectivityNodesId;
}

public SvgParameters setDisplayConnectivityNodesId(boolean displayConnectivityNodesId) {
this.displayConnectivityNodesId = displayConnectivityNodesId;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public abstract class AbstractTestCase {
private static final Pattern SVG_FIX_PATTERN = Pattern.compile(">\\s*(<\\!\\[CDATA\\[.*?]]>)\\s*</", Pattern.DOTALL);

protected boolean debugJsonFiles = false;
protected boolean debugSvgFiles = false;
protected boolean debugSvgFiles = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that debugSvgFiles should be equal to false.

protected boolean overrideTestReferences = false;

protected final ResourcesComponentLibrary componentLibrary = getResourcesComponentLibrary();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,24 @@ public void setUp() {

@Test
void test() {
// build graph
VoltageLevelGraph g = graphBuilder.buildVoltageLevelGraph(vl.getId());
voltageLevelGraphLayout(g);
assertEquals(toString("/TestCase1.json"), toJson(g, "/TestCase1.json"));
}

// Run layout
@Test
void testDisplayEquipmentNodesLabel() {
VoltageLevelGraph g = graphBuilder.buildVoltageLevelGraph(vl.getId());
voltageLevelGraphLayout(g);
svgParameters.setDisplayEquipmentNodesLabel(true);
assertEquals(toString("/TestCase1_equipmentLabels.svg"), toSVG(g, "/TestCase1_equipmentLabels.svg"));
}

// write Json and compare to reference
assertEquals(toString("/TestCase1.json"), toJson(g, "/TestCase1.json"));
@Test
void testDisplayConnectivityNodes() {
VoltageLevelGraph g = graphBuilder.buildVoltageLevelGraph(vl.getId());
voltageLevelGraphLayout(g);
svgParameters.setDisplayConnectivityNodesId(true).setShowInternalNodes(true);
assertEquals(toString("/TestCase1_connectivityLabels.svg"), toSVG(g, "/TestCase1_connectivityLabels.svg"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ void test() {
.setDrawStraightWires(true)
.setShowGrid(true)
.setShowInternalNodes(true)
.setDisplayCurrentFeederInfo(true);
.setDisplayCurrentFeederInfo(true)
.setDisplayEquipmentNodesLabel(true)
.setDisplayConnectivityNodesId(true);

SvgParameters svgParameters1 = new SvgParameters(svgParameters0);

Expand Down Expand Up @@ -78,5 +80,7 @@ void test() {
assertEquals(svgParameters0.isShowGrid(), svgParameters1.isShowGrid());
assertEquals(svgParameters0.isShowInternalNodes(), svgParameters1.isShowInternalNodes());
assertEquals(svgParameters0.isDisplayCurrentFeederInfo(), svgParameters1.isDisplayCurrentFeederInfo());
assertEquals(svgParameters0.isDisplayEquipmentNodesLabel(), svgParameters1.isDisplayEquipmentNodesLabel());
assertEquals(svgParameters0.isDisplayConnectivityNodesId(), svgParameters1.isDisplayConnectivityNodesId());
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading