Skip to content

Commit

Permalink
rename previous simple force layout to springy
Browse files Browse the repository at this point in the history
Signed-off-by: Luma <[email protected]>
  • Loading branch information
zamarrenolm committed Jan 10, 2024
1 parent 76cd39f commit 54de632
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
*
* @author Mathilde Grapin {@literal <mathilde.grapin at rte-france.com>}
*/
public class ForceLayout<V, E> extends AbstractForceLayout<V, E> {
private static final Logger LOGGER = LoggerFactory.getLogger(ForceLayout.class);
public class ForceLayoutSpringy<V, E> extends AbstractForceLayout<V, E> {
private static final Logger LOGGER = LoggerFactory.getLogger(ForceLayoutSpringy.class);
private static final double DEFAULT_REPULSION = 800.0;
private static final double DEFAULT_FRICTION = 500;
private static final double DEFAULT_MAX_SPEED = 100;
Expand All @@ -53,30 +53,30 @@ public class ForceLayout<V, E> extends AbstractForceLayout<V, E> {
private double maxSpeed;
private double springRepulsionFactor;

public ForceLayout(Graph<V, E> graph) {
public ForceLayoutSpringy(Graph<V, E> graph) {
super(graph);
this.friction = DEFAULT_FRICTION;
this.maxSpeed = DEFAULT_MAX_SPEED;
this.repulsion = DEFAULT_REPULSION;
this.springRepulsionFactor = DEFAULT_SPRING_REPULSION_FACTOR;
}

public ForceLayout<V, E> setRepulsion(double repulsion) {
public ForceLayoutSpringy<V, E> setRepulsion(double repulsion) {
this.repulsion = repulsion;
return this;
}

public ForceLayout<V, E> setFriction(double friction) {
public ForceLayoutSpringy<V, E> setFriction(double friction) {
this.friction = friction;
return this;
}

public ForceLayout<V, E> setMaxSpeed(double maxSpeed) {
public ForceLayoutSpringy<V, E> setMaxSpeed(double maxSpeed) {
this.maxSpeed = maxSpeed;
return this;
}

public ForceLayout<V, E> setSpringRepulsionFactor(double springRepulsionFactor) {
public ForceLayoutSpringy<V, E> setSpringRepulsionFactor(double springRepulsionFactor) {
this.springRepulsionFactor = springRepulsionFactor;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
package com.powsybl.nad.layout;

import com.powsybl.diagram.util.forcelayout.ForceLayout;
import com.powsybl.diagram.util.forcelayout.ForceLayoutSpringy;
import com.powsybl.diagram.util.forcelayout.Vector;
import com.powsybl.nad.model.Edge;
import com.powsybl.nad.model.Graph;
Expand All @@ -27,7 +27,7 @@ public class BasicForceLayout extends AbstractLayout {
@Override
protected void nodesLayout(Graph graph, LayoutParameters layoutParameters) {
org.jgrapht.Graph<Node, Edge> jgraphtGraph = graph.getJgraphtGraph(layoutParameters.isTextNodesForceLayout());
ForceLayout<Node, Edge> forceLayout = new ForceLayout<>(jgraphtGraph);
ForceLayoutSpringy<Node, Edge> forceLayout = new ForceLayoutSpringy<>(jgraphtGraph);
forceLayout.setSpringRepulsionFactor(layoutParameters.getSpringRepulsionFactorForceLayout());
forceLayout.setMaxSteps(layoutParameters.getMaxSteps());

Expand All @@ -50,7 +50,7 @@ protected void nodesLayout(Graph graph, LayoutParameters layoutParameters) {
}
}

private void setInitialPositions(ForceLayout<Node, Edge> forceLayout, Graph graph) {
private void setInitialPositions(ForceLayoutSpringy<Node, Edge> forceLayout, Graph graph) {
Map<Node, com.powsybl.diagram.util.forcelayout.Point> initialPoints = getInitialNodePositions().entrySet().stream()
// Only accept positions for nodes in the graph
.filter(nodePosition -> graph.getNode(nodePosition.getKey()).isPresent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* @author Luma Zamarreno {@literal <zamarrenolm at aia.es>}
*/
class ForceLayoutTest extends AbstractTest {
class ForceLayoutSpringyTest extends AbstractTest {

@BeforeEach
void setup() {
Expand Down

0 comments on commit 54de632

Please sign in to comment.