Skip to content

Commit

Permalink
Merge branch 'main' into Documentation2
Browse files Browse the repository at this point in the history
Signed-off-by: BenoitJeanson <[email protected]>
  • Loading branch information
BenoitJeanson committed May 2, 2023
2 parents 924f907 + 39b4eb0 commit 9f4a7bc
Show file tree
Hide file tree
Showing 337 changed files with 7,034 additions and 15,139 deletions.
6 changes: 3 additions & 3 deletions diagram-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-diagram</artifactId>
<version>3.2.0-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>
</parent>

<artifactId>powsybl-diagram-util</artifactId>
Expand Down Expand Up @@ -51,8 +51,8 @@

<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ public class ValueFormatter {

private final int powerValuePrecision;
private final int voltageValuePrecision;
private final int currentValuePrecision;
private final int angleValuePrecision;
private final DecimalFormat format;
private final String undefinedValueSymbol;

public ValueFormatter(int powerValuePrecision, int voltageValuePrecision, int angleValuePrecision, Locale locale, String undefinedValueSymbol) {
public ValueFormatter(int powerValuePrecision, int voltageValuePrecision, int currentValuePrecision, int angleValuePrecision, Locale locale, String undefinedValueSymbol) {
this.powerValuePrecision = powerValuePrecision;
this.voltageValuePrecision = voltageValuePrecision;
this.currentValuePrecision = currentValuePrecision;
this.angleValuePrecision = angleValuePrecision;
this.format = new DecimalFormat();
format.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(locale));
Expand Down Expand Up @@ -63,4 +65,14 @@ private void setFractionDigits(int precision) {
format.setMaximumFractionDigits(precision);
format.setMinimumFractionDigits(precision);
}

public String formatCurrent(double current, String unit) {
setFractionDigits(currentValuePrecision);
String valueFormatted = Double.isNaN(current) ? undefinedValueSymbol : format.format(current);
return unit.isEmpty() ? valueFormatted : (valueFormatted + " " + unit);
}

public String formatCurrent(double current) {
return formatCurrent(current, "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
*/
package com.powsybl.diagram.util.forcelayout;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;

/**
* @author Thomas Adam <tadam at silicom.fr>
*/
public class BoundingBoxTest {
class BoundingBoxTest {

@Test
public void test() {
void test() {
List<Point> points = new ArrayList<>();
points.add(new Point(1.0, 2.0));
points.add(new Point(3.0, 4.0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
*/
package com.powsybl.diagram.util.forcelayout;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;

/**
* @author Thomas Adam <tadam at silicom.fr>
*/
public class CanvasTest {
class CanvasTest {

@Test
public void test() {
void test() {
List<Point> points = new ArrayList<>();
points.add(new Point(1.0, 2.0));
points.add(new Point(3.0, 4.0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
*/
package com.powsybl.diagram.util.forcelayout;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* @author Thomas Adam <tadam at silicom.fr>
*/
public class VectorTest {
class VectorTest {

@Test
public void test() {
void test() {
Vector vector = new Vector(1.0, 2.0);
assertEquals(2.24, vector.magnitude(), 0.01);
assertEquals(5.0, vector.magnitudeSquare(), 0.0);
Expand Down
2 changes: 1 addition & 1 deletion distribution-diagram/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<artifactId>powsybl-diagram</artifactId>
<groupId>com.powsybl</groupId>
<version>3.2.0-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>
</parent>

<packaging>pom</packaging>
Expand Down
16 changes: 3 additions & 13 deletions network-area-diagram/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-diagram</artifactId>
<version>3.2.0-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>
</parent>

<artifactId>powsybl-network-area-diagram</artifactId>
Expand Down Expand Up @@ -53,8 +53,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -82,16 +82,6 @@
<artifactId>powsybl-config-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-loadflow-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-open-loadflow</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.powsybl.commons.config.BaseVoltagesConfig;
import com.powsybl.nad.model.*;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.UncheckedIOException;
Expand All @@ -22,6 +24,8 @@
*/
public abstract class AbstractStyleProvider implements StyleProvider {

protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractStyleProvider.class);

private final BaseVoltagesConfig baseVoltagesConfig;

protected AbstractStyleProvider() {
Expand Down Expand Up @@ -87,11 +91,22 @@ public List<String> getSideEdgeStyleClasses(BranchEdge edge, BranchEdge.Side sid
@Override
public List<String> getEdgeInfoStyles(EdgeInfo info) {
List<String> styles = new LinkedList<>();
if (info.getInfoType().equals(EdgeInfo.ACTIVE_POWER)) {
styles.add(CLASSES_PREFIX + "active");
} else if (info.getInfoType().equals(EdgeInfo.REACTIVE_POWER)) {
styles.add(CLASSES_PREFIX + "reactive");
String infoType = info.getInfoType();
switch (infoType) {
case EdgeInfo.ACTIVE_POWER:
styles.add(CLASSES_PREFIX + "active");
break;
case EdgeInfo.REACTIVE_POWER:
styles.add(CLASSES_PREFIX + "reactive");
break;
case EdgeInfo.CURRENT:
styles.add(CLASSES_PREFIX + "current");
break;
default:
LOGGER.warn("The \"{}\" type of information is not handled", infoType);
break;
}

info.getDirection().ifPresent(direction -> styles.add(
CLASSES_PREFIX + (direction == EdgeInfo.Direction.IN ? "state-in" : "state-out")));
return styles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class EdgeInfo {
public static final String ACTIVE_POWER = "ActivePower";
public static final String REACTIVE_POWER = "ReactivePower";
public static final String CURRENT = "Current";

private final String infoType;
private final Direction arrowDirection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import com.powsybl.nad.model.*;

import java.util.List;
import java.util.Optional;

/**
* @author Florian Dupuy <florian.dupuy at rte-france.com>
*/
public interface LabelProvider {
List<EdgeInfo> getEdgeInfos(Graph graph, BranchEdge edge, BranchEdge.Side side);
Optional<EdgeInfo> getEdgeInfo(Graph graph, BranchEdge edge, BranchEdge.Side side);

List<EdgeInfo> getEdgeInfos(Graph graph, ThreeWtEdge edge);
Optional<EdgeInfo> getEdgeInfo(Graph graph, ThreeWtEdge edge);

String getLabel(Edge edge);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class SvgParameters {
private double loopEdgesAperture = Math.toRadians(60);
private double loopControlDistance = 40;
private boolean edgeInfoAlongEdge = true;
private boolean edgeNameDisplayed = true;
private boolean edgeNameDisplayed = false;
private double interAnnulusSpace = 5;
private String svgPrefix = "";
private boolean idDisplayed = false;
Expand All @@ -52,9 +52,12 @@ public class SvgParameters {
private int voltageValuePrecision = 1;
private int powerValuePrecision = 0;
private int angleValuePrecision = 1;
private int currentValuePrecision = 0;
private EdgeInfoEnum edgeInfoDisplayed = EdgeInfoEnum.ACTIVE_POWER;
private double pstArrowHeadSize = 8;
private String undefinedValueSymbol = "";


public enum CssLocation {
INSERTED_IN_SVG, EXTERNAL_IMPORTED, EXTERNAL_NO_IMPORT
}
Expand Down Expand Up @@ -103,6 +106,8 @@ public SvgParameters(SvgParameters other) {
this.voltageValuePrecision = other.voltageValuePrecision;
this.powerValuePrecision = other.powerValuePrecision;
this.angleValuePrecision = other.angleValuePrecision;
this.currentValuePrecision = other.currentValuePrecision;
this.edgeInfoDisplayed = other.edgeInfoDisplayed;
this.pstArrowHeadSize = other.pstArrowHeadSize;
this.undefinedValueSymbol = other.undefinedValueSymbol;
}
Expand Down Expand Up @@ -429,6 +434,15 @@ public SvgParameters setPowerValuePrecision(int powerValuePrecision) {
return this;
}

public int getCurrentValuePrecision() {
return currentValuePrecision;
}

public SvgParameters setCurrentValuePrecision(int currentValuePrecision) {
this.currentValuePrecision = currentValuePrecision;
return this;
}

public int getAngleValuePrecision() {
return angleValuePrecision;
}
Expand All @@ -439,7 +453,22 @@ public SvgParameters setAngleValuePrecision(int angleValuePrecision) {
}

public ValueFormatter createValueFormatter() {
return new ValueFormatter(powerValuePrecision, voltageValuePrecision, angleValuePrecision, Locale.forLanguageTag(languageTag), undefinedValueSymbol);
return new ValueFormatter(powerValuePrecision, voltageValuePrecision, currentValuePrecision, angleValuePrecision, Locale.forLanguageTag(languageTag), undefinedValueSymbol);
}

public enum EdgeInfoEnum {
ACTIVE_POWER,
REACTIVE_POWER,
CURRENT;
}

public EdgeInfoEnum getEdgeInfoDisplayed() {
return this.edgeInfoDisplayed;
}

public SvgParameters setEdgeInfoDisplayed(EdgeInfoEnum edgeInfoDisplayed) {
this.edgeInfoDisplayed = edgeInfoDisplayed;
return this;
}

public double getPstArrowHeadSize() {
Expand Down
Loading

0 comments on commit 9f4a7bc

Please sign in to comment.