powsybl / powsybl-network-area-diagram

Generation of network area diagrams
Mozilla Public License 2.0
2 stars 0 forks source link

Allow applying repulsion force between springs #93

Closed zamarrenolm closed 2 years ago

zamarrenolm commented 2 years ago

Signed-off-by: Luma zamarrenolm@aia.es

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...) Feature.

What is the current behavior? (You can also link to an open issue here) Diagrams usually contain overlaps or near-overlaps. See the example: diamond-spring-repulsion-factor-0 0

What is the new behavior (if this is a feature change)? An additional force that separates the centers of the edges applying Coulomb's law is added. By default it is disabled. It can be configured using:

new NetworkAreaDiagram(network).draw("output.svg",
    new SvgParams(),
    new LayoutParameters().setSpringRepulsionFactorForceLayout(0.2));

The expected result on the same network is: diamond-spring-repulsion-factor-0 2

The spring repulsion factor is combined with the repulsion parameter used to separate nodes in the graph. The repulsion force between springs is computed between the centers of the springs (the edges of the graph) and applied to its end nodes. The centers of the springs are also repelled from the other nodes in the graph.

sonarcloud[bot] commented 2 years ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication