-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge powsybl-network-area-diagram into powsybl-single-line-diagram (#…
…428) * Move nad into powsybl-sld * Use Junit4 instead of Junit5 to have a single testing lib * Single diagram-util module * Replace Verdana font-family with serif generic font-family * Slight fix in README.md * One single version classes * Remove test-jar sld-core Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
- Loading branch information
Showing
632 changed files
with
43,094 additions
and
277 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2022, RTE (http://www.rte-france.com) | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this | ||
file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.powsybl</groupId> | ||
<artifactId>powsybl-diagram</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>powsybl-diagram-util</artifactId> | ||
<name>PowSyBl diagram util</name> | ||
<description>Force layout for PowSyBl Diagram</description> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>templating-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>buildnumber-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<!-- compilation dependencies --> | ||
<dependency> | ||
<groupId>com.powsybl</groupId> | ||
<artifactId>powsybl-tools</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jgrapht</groupId> | ||
<artifactId>jgrapht-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
|
||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
21 changes: 21 additions & 0 deletions
21
diagram-util/src/main/java-templates/com/powsybl/diagram/util/PowsyblDiagramVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) 2022, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.powsybl.diagram.util; | ||
|
||
import com.google.auto.service.AutoService; | ||
import com.powsybl.tools.*; | ||
|
||
/** | ||
* @author Florian Dupuy <florian.dupuy at rte-france.com> | ||
*/ | ||
@AutoService(Version.class) | ||
public class PowsyblDiagramVersion extends AbstractVersion { | ||
|
||
public PowsyblDiagramVersion() { | ||
super("powsybl-diagram", "${project.version}", "${buildNumber}", "${scmBranch}", Long.parseLong("${timestamp}")); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
diagram-util/src/main/java/com/powsybl/diagram/util/forcelayout/BoundingBox.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright (c) 2021, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.powsybl.diagram.util.forcelayout; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* @author Mathilde Grapin <mathilde.grapin at rte-france.com> | ||
*/ | ||
public final class BoundingBox { | ||
|
||
private final double left; | ||
private final double bottom; | ||
private final double right; | ||
private final double top; | ||
|
||
private BoundingBox(double left, double top, double right, double bottom) { | ||
this.left = left; | ||
this.top = top; | ||
this.right = right; | ||
this.bottom = bottom; | ||
if (left > right || bottom < top) { | ||
throw new IllegalStateException("Bounding box with negative width or height"); | ||
} | ||
} | ||
|
||
public static BoundingBox computeBoundingBox(Collection<Point> points) { | ||
double left = points.stream().mapToDouble(p -> p.getPosition().getX()).min().orElse(-2); | ||
double top = points.stream().mapToDouble(p -> p.getPosition().getY()).min().orElse(-2); | ||
double right = points.stream().mapToDouble(p -> p.getPosition().getX()).max().orElse(2); | ||
double bottom = points.stream().mapToDouble(p -> p.getPosition().getY()).max().orElse(2); | ||
return new BoundingBox(left, top, right, bottom); | ||
} | ||
|
||
public double getHeight() { | ||
return bottom - top; | ||
} | ||
|
||
public double getWidth() { | ||
return right - left; | ||
} | ||
|
||
public double getLeft() { | ||
return left; | ||
} | ||
|
||
public double getTop() { | ||
return top; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
diagram-util/src/main/java/com/powsybl/diagram/util/forcelayout/Canvas.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) 2021, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.powsybl.diagram.util.forcelayout; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author Mathilde Grapin <mathilde.grapin at rte-france.com> | ||
*/ | ||
public class Canvas { | ||
private final double width; | ||
private final double height; | ||
private final BoundingBox boundingBox; | ||
private final double margin; | ||
private final double scale; | ||
|
||
public Canvas(BoundingBox boundingBox, double height, double margin) { | ||
this.boundingBox = Objects.requireNonNull(boundingBox); | ||
this.height = height; | ||
this.scale = (height - 2 * margin) / boundingBox.getHeight(); // scale has to be computed and used without margins | ||
this.width = boundingBox.getWidth() * scale + 2 * margin; | ||
this.margin = margin; | ||
} | ||
|
||
public Vector toScreen(Vector position) { | ||
double screenX = (position.getX() - boundingBox.getLeft()) * scale + margin; | ||
double screenY = (position.getY() - boundingBox.getTop()) * scale + margin; | ||
return new Vector(screenX, screenY); | ||
} | ||
|
||
public double getWidth() { | ||
return width; | ||
} | ||
|
||
public double getHeight() { | ||
return height; | ||
} | ||
} |
Oops, something went wrong.