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

upgrade diagram viewer to powsybl 2023.3.0 #81

Merged
merged 12 commits into from
Nov 20, 2023
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
- name: Checkout sources
uses: actions/[email protected]

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 11
java-version: 17

- name: Build diagram viewer with Maven
run: mvn --file diagram-viewer --batch-mode -P jacoco,checks package
Expand Down
6 changes: 3 additions & 3 deletions diagram-viewer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-parent</artifactId>
<version>4</version>
<version>15</version>
<relativePath/>
</parent>

Expand All @@ -35,15 +35,15 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
<java.version>17</java.version>
<javafx.version>19.0.2.1</javafx.version>
<javafx-mvn-plugin.version>0.0.8</javafx-mvn-plugin.version>
<slf4j-api.version>2.0.7</slf4j-api.version>
<logback.version>1.4.6</logback.version>
<junit.version>4.13.1</junit.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<powsybl.dependencies.version>2023.2.0</powsybl.dependencies.version>
<powsybl.dependencies.version>2023.3.0</powsybl.dependencies.version>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Model(BooleanProperty showNames, NetworkAreaDiagramModel nadModel, Single
this.nadModel = nadModel;
this.sldModel = sldModel;
this.nadModel.getSvgParametersBean().bind(showNames);
this.sldModel.getLayoutParametersBean().bind(showNames);
this.sldModel.getSvgParametersBean().bind(showNames);
}

public void setNetwork(Network network) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.Substation;
import com.powsybl.iidm.network.VoltageLevel;
import com.powsybl.nad.NadParameters;
import com.powsybl.nad.NetworkAreaDiagram;
import com.powsybl.nad.build.iidm.VoltageLevelFilter;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.fxml.FXML;
Expand All @@ -24,6 +26,7 @@
import java.io.IOException;
import java.io.StringWriter;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -54,13 +57,11 @@ protected Task<String> createTask() {
return new Task<>() {
@Override
protected String call() {
NetworkAreaDiagram nad = getNetworkAreaDiagram(network, model, container);
nad.draw(writer,
model.getSvgParameters(),
model.getLayoutParameters(),
model.getStyleProvider(network),
model.getLabelProvider(network),
model.getLayoutFactory());
Predicate<VoltageLevel> vls = getVoltageLevelFilter(network, model, container);
NadParameters nadParameters = new NadParameters();
nadParameters.setLayoutParameters(model.getLayoutParameters());
nadParameters.setSvgParameters(model.getSvgParameters());
NetworkAreaDiagram.draw(network, writer, nadParameters, vls);
return writer.toString();
}
};
Expand All @@ -75,15 +76,15 @@ protected String call() {
nadService.start();
}

private static NetworkAreaDiagram getNetworkAreaDiagram(Network network, NetworkAreaDiagramModel model, Container<?> container) {
private static Predicate<VoltageLevel> getVoltageLevelFilter(Network network, NetworkAreaDiagramModel model, Container<?> container) {
switch (container.getContainerType()) {
case NETWORK:
return new NetworkAreaDiagram((Network) container);
return VoltageLevelFilter.NO_FILTER;
case SUBSTATION:
List<String> vls = ((Substation) container).getVoltageLevelStream().map(VoltageLevel::getId).collect(Collectors.toList());
return new NetworkAreaDiagram(network, vls, model.getDepth());
return VoltageLevelFilter.createVoltageLevelsDepthFilter(network, vls, model.getDepth());
case VOLTAGE_LEVEL:
return new NetworkAreaDiagram(network, container.getId(), model.getDepth());
return VoltageLevelFilter.createVoltageLevelDepthFilter(network, container.getId(), model.getDepth());
default:
throw new AssertionError();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class NetworkAreaDiagramModel extends DiagramModel {
private static final String TOPOLOGICAL_STYLE_PROVIDER = "Topological";

// Layout Parameters
private final LayoutParametersBean layoutParameters;
private final LayoutParametersBean layoutParametersBean;

// SVG Parameters
private final SvgParametersBean svgParameters;
Expand Down Expand Up @@ -67,7 +67,7 @@ public NetworkAreaDiagramModel(ReadOnlyObjectProperty<Integer> depth,
this.layoutFactory.bind(layout);

// Layout parameters
layoutParameters = new LayoutParametersBean(textNodesIncluded, springRepulsionFactor);
layoutParametersBean = new LayoutParametersBean(textNodesIncluded, springRepulsionFactor);

// SVG parameters
svgParameters = new SvgParametersBean(infoAlongEdge,
Expand All @@ -91,7 +91,7 @@ public SvgParameters getSvgParameters() {
}

public LayoutParameters getLayoutParameters() {
return layoutParameters.getLayoutParameters();
return layoutParametersBean.getLayoutParameters();
}

public LabelProvider getLabelProvider(Network network) {
Expand All @@ -114,6 +114,6 @@ public SvgParametersBean getSvgParametersBean() {

public void addListener(ChangeListener<Object> changeListener) {
svgParameters.addListener(changeListener);
layoutParameters.addListener(changeListener);
layoutParametersBean.addListener(changeListener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public SvgParametersBean(// SVG parameters

// Initialize
SvgParameters defaultParameters = new SvgParameters();
idDisplayed.setValue(defaultParameters.isIdDisplayed());
edgeInfoAlongEdge.setValue(defaultParameters.isEdgeInfoAlongEdge());
edgeNameDisplayed.setValue(defaultParameters.isEdgeNameDisplayed());
insertNameDesc.setValue(defaultParameters.isInsertNameDesc());
Expand Down
Loading
Loading