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

Remove stroke on Nodes #81

Merged
merged 8 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 13 additions & 2 deletions src/main/java/com/powsybl/nad/svg/SvgParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ public class SvgParameters {
private double voltageLevelCircleRadius = 0.3;
private double fictitiousVoltageLevelCircleRadius = 0.15;
private double transformerCircleRadius = 0.2;
private double nodeHollowWidth = 0.1;
private double nodeHollowWidth = 0.15;
private double edgesForkLength = 0.8;
private double edgesForkAperture = Math.toRadians(60);
private double edgeStartShift = 0.03;
private double edgeStartShift = 0.02;
private double unknownBusNodeExtraRadius = 0.1;
private double loopDistance = 1.2;
private double loopEdgesAperture = Math.toRadians(60);
private double loopControlDistance = 0.4;
private boolean textNodeBackground = true;
private boolean edgeInfoAlongEdge = true;
private double interAnnulusSpace = 0.05;
private String svgPrefix = "";

public enum CssLocation {
Expand Down Expand Up @@ -74,6 +75,7 @@ public SvgParameters(SvgParameters other) {
this.textNodeBackground = other.textNodeBackground;
this.edgeInfoAlongEdge = other.edgeInfoAlongEdge;
this.svgPrefix = other.svgPrefix;
this.interAnnulusSpace = other.interAnnulusSpace;
}

public Padding getDiagramPadding() {
Expand Down Expand Up @@ -285,6 +287,15 @@ public SvgParameters setEdgeInfoAlongEdge(boolean edgeInfoAlongEdge) {
return this;
}

public double getInterAnnulusSpace() {
return interAnnulusSpace;
}

public SvgParameters setInterAnnulusSpace(double interAnnulusSpace) {
this.interAnnulusSpace = interAnnulusSpace;
return this;
}

public String getSvgPrefix() {
return svgPrefix;
}
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/com/powsybl/nad/svg/SvgWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,11 @@ private void drawNode(Graph graph, XMLStreamWriter writer, VoltageLevelNode vlNo
writer.writeAttribute(CIRCLE_RADIUS_ATTRIBUTE, getFormattedValue(nodeOuterRadius + svgParameters.getUnknownBusNodeExtraRadius()));
}

int nbBuses = vlNode.getBusNodes().size();
double busInnerRadius = 0;
List<Edge> traversingBusEdges = new ArrayList<>();

for (BusNode busNode : vlNode.getBusNodes()) {
double busOuterRadius = busInnerRadius + nodeOuterRadius / nbBuses;
double busInnerRadius = getBusAnnulusInnerRadius(busNode, vlNode, svgParameters);
double busOuterRadius = getBusAnnulusOuterRadius(busNode, vlNode, svgParameters);
if (busInnerRadius == 0) {
writer.writeEmptyElement(CIRCLE_ELEMENT_NAME);
writer.writeAttribute(CIRCLE_RADIUS_ATTRIBUTE, getFormattedValue(busOuterRadius));
Expand All @@ -460,7 +459,6 @@ private void drawNode(Graph graph, XMLStreamWriter writer, VoltageLevelNode vlNo
}
writer.writeAttribute(ID_ATTRIBUTE, getPrefixedId(busNode.getDiagramId()));
addStylesIfAny(writer, styleProvider.getNodeStyleClasses(busNode));
busInnerRadius = busOuterRadius;
traversingBusEdges.addAll(graph.getBusEdges(busNode));
}
}
Expand Down Expand Up @@ -704,10 +702,19 @@ protected static double getVoltageLevelCircleRadius(VoltageLevelNode vlNode, Svg
return Math.min(Math.max(nbBuses, 1), 2) * svgParameters.getVoltageLevelCircleRadius();
}

public static double getBusAnnulusInnerRadius(BusNode node, VoltageLevelNode vlNode, SvgParameters svgParameters) {
if (node.getIndex() == 0) {
return 0;
}
int nbNeighbours = node.getNbNeighbouringBusNodes();
double unitaryRadius = SvgWriter.getVoltageLevelCircleRadius(vlNode, svgParameters) / (nbNeighbours + 1);
return node.getIndex() * unitaryRadius + svgParameters.getInterAnnulusSpace() / 2;
}

public static double getBusAnnulusOuterRadius(BusNode node, VoltageLevelNode vlNode, SvgParameters svgParameters) {
int nbNeighbours = node.getNbNeighbouringBusNodes();
double unitaryRadius = SvgWriter.getVoltageLevelCircleRadius(vlNode, svgParameters) / (nbNeighbours + 1);
return (node.getIndex() + 1) * unitaryRadius;
return (node.getIndex() + 1) * unitaryRadius - svgParameters.getInterAnnulusSpace() / 2;
}

public String getPrefixedId(String id) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/nominalStyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.nad-3wt-edges polyline {stroke: var(--nad-vl-color, lightgrey); stroke-width: 0.05; fill: none}
.nad-text-edges {stroke: black; stroke-width: 0.02; stroke-dasharray: .03,.05}
.nad-branch-edges .nad-disconnected polyline {stroke-dasharray: .1,.1}
.nad-vl-nodes circle, .nad-vl-nodes path {fill: var(--nad-vl-color, lightblue); stroke-width: 0.05; stroke: white; stroke-linejoin:round}
.nad-vl-nodes circle, .nad-vl-nodes path {fill: var(--nad-vl-color, lightblue)}
.nad-vl-nodes circle.nad-unknown-busnode {stroke: lightgrey; stroke-dasharray: .05,.05; fill: none}
.nad-hvdc-edge polyline.nad-hvdc {stroke: grey; stroke-width: 0.2}
.nad-3wt-nodes circle {stroke: var(--nad-vl-color, lightgrey); stroke-width: 0.05; fill: none}
Expand Down Expand Up @@ -34,10 +34,10 @@
40% {stroke: #FFEB3B; stroke-width: 0.15}
}
@keyframes node-over-blink {
0%, 80%, 100% {stroke: white; stroke-width: 0.05}
0%, 80%, 100% {stroke: white; stroke-width: 0}
40% {stroke: #ff5722; stroke-width: 0.15}
}
@keyframes node-under-blink {
0%, 80%, 100% {stroke: white; stroke-width: 0.05}
0%, 80%, 100% {stroke: white; stroke-width: 0}
40% {stroke: #00BCD4; stroke-width: 0.15}
}
2 changes: 1 addition & 1 deletion src/main/resources/topologicalStyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.nad-3wt-edges polyline {stroke: var(--nad-vl-color, lightgrey); stroke-width: 0.05; fill: none}
.nad-text-edges {stroke: black; stroke-width: 0.02; stroke-dasharray: .03,.05}
.nad-branch-edges .nad-disconnected polyline {stroke-dasharray: .1,.1}
.nad-vl-nodes circle, .nad-vl-nodes path {fill: var(--nad-vl-color, lightgrey); stroke-width: 0.05; stroke: white; stroke-linejoin:round}
.nad-vl-nodes circle, .nad-vl-nodes path {fill: var(--nad-vl-color, lightgrey)}
.nad-vl-nodes circle.nad-unknown-busnode {stroke: var(--nad-vl-color, #808080); stroke-dasharray: .05,.05; fill: none}
.nad-hvdc-edge polyline.nad-hvdc {stroke: grey; stroke-width: 0.2}
.nad-3wt-nodes circle {stroke: var(--nad-vl-color, lightgrey); stroke-width: 0.05; fill: none}
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/com/powsybl/nad/svg/SvgParametersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void test() {
.setLoopControlDistance(1.)
.setTextNodeBackground(false)
.setEdgeInfoAlongEdge(false)
.setSvgPrefix("TestPrefix");
.setSvgPrefix("TestPrefix")
.setInterAnnulusSpace(0.25);

SvgParameters svgParameters1 = new SvgParameters(svgParameters0);

Expand Down Expand Up @@ -72,5 +73,6 @@ void test() {
assertEquals(svgParameters0.isTextNodeBackground(), svgParameters1.isTextNodeBackground());
assertEquals(svgParameters0.isEdgeInfoAlongEdge(), svgParameters1.isEdgeInfoAlongEdge());
assertEquals(svgParameters0.getSvgPrefix(), svgParameters1.getSvgPrefix());
assertEquals(svgParameters0.getInterAnnulusSpace(), svgParameters1.getInterAnnulusSpace());
}
}
32 changes: 16 additions & 16 deletions src/test/resources/3wt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions src/test/resources/3wt_disconnected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions src/test/resources/3wt_partial.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading