forked from powsybl/powsybl-diagram
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
- Loading branch information
0 parents
commit e3f58b1
Showing
343 changed files
with
62,443 additions
and
0 deletions.
There are no files selected for viewing
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,29 @@ | ||
# Maven projects | ||
cgmes-dl/target | ||
cgmes-dl/cgmes-dl-conversion/target | ||
cgmes-dl/cgmes-iidm-extensions/target | ||
cgmes-gl/target | ||
cgmes-gl/cgmes-gl-conversion/target | ||
cgmes-gl/cgmes-gl-iidm-extensions/target | ||
substation-diagram/substation-diagram-cgmes/target | ||
substation-diagram/substation-diagram-core/target | ||
substation-diagram/substation-diagram-util/target | ||
substation-diagram/substation-diagram-view/target | ||
substation-diagram/target | ||
substation-webviewer/target | ||
target | ||
|
||
# IntelliJ | ||
/.idea | ||
*.iml | ||
|
||
# Compilation settings | ||
install.cfg | ||
|
||
# Eclipse projects | ||
.classpath | ||
.project | ||
org.eclipse.core.resources.prefs | ||
org.eclipse.jdt.core.prefs | ||
org.eclipse.m2e.core.prefs | ||
org.eclipse.jdt.groovy.core.prefs |
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 @@ | ||
language: java | ||
|
||
dist: trusty | ||
sudo: required | ||
|
||
jdk: | ||
- oraclejdk8 | ||
|
||
addons: | ||
sonarcloud: | ||
organization: "powsybl-ci-github" | ||
token: | ||
secure: ${SONAR_TOKEN} | ||
|
||
install: | ||
# Build powsybl-core | ||
- git clone https://github.com/powsybl/powsybl-core powsybl/powsybl-core | ||
- pushd powsybl/powsybl-core && mvn --batch-mode -DskipTests install && popd | ||
|
||
script: | ||
- mvn --batch-mode -Pjacoco,checks clean verify sonar:sonar |
Large diffs are not rendered by default.
Oops, something went wrong.
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,22 @@ | ||
version: '{build}' | ||
os: Windows Server 2012 | ||
install: | ||
- ps: | | ||
Add-Type -AssemblyName System.IO.Compression.FileSystem | ||
if (!(Test-Path -Path "C:\maven" )) { | ||
(new-object System.Net.WebClient).DownloadFile( | ||
'http://www.us.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.zip', | ||
'C:\maven-bin.zip' | ||
) | ||
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\maven-bin.zip", "C:\maven") | ||
} | ||
- cmd: SET M2_HOME=C:\maven\apache-maven-3.2.5 | ||
- cmd: SET PATH=%M2_HOME%\bin;%JAVA_HOME%\bin;%PATH% | ||
before_build: | ||
- git clone https://github.com/powsybl/powsybl-core.git powsybl/powsybl-core | ||
- ps: | | ||
pushd powsybl/powsybl-core | ||
mvn -DskipTests install --batch-mode | ||
popd | ||
build_script: | ||
- mvn clean package --batch-mode |
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,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2019, 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-single-line-diagram</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>powsybl-base-voltage-color</artifactId> | ||
<name>Base Voltages color configuration</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.powsybl</groupId> | ||
<artifactId>powsybl-commons</artifactId> | ||
<version>${powsyblcore.version}</version> | ||
</dependency> | ||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
100 changes: 100 additions & 0 deletions
100
base-voltage-color/src/main/java/com/powsybl/basevoltage/BaseVoltageColor.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,100 @@ | ||
/** | ||
* Copyright (c) 2019, 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.basevoltage; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
|
||
import org.yaml.snakeyaml.Yaml; | ||
import org.yaml.snakeyaml.constructor.Constructor; | ||
|
||
import com.powsybl.commons.config.PlatformConfig; | ||
|
||
/** | ||
* | ||
* @author Massimo Ferraro <[email protected]> | ||
*/ | ||
public class BaseVoltageColor { | ||
|
||
private static final String CONFIG_FILE = "base-voltages.yml"; | ||
|
||
private final BaseVoltagesConfig config; | ||
|
||
public BaseVoltageColor(Path configFile) throws IOException { | ||
Objects.requireNonNull(configFile); | ||
Yaml yaml = new Yaml(new Constructor(BaseVoltagesConfig.class)); | ||
InputStream configInputStream = Files.newInputStream(configFile); | ||
config = yaml.load(configInputStream); | ||
} | ||
|
||
public BaseVoltageColor() throws IOException { | ||
this(PlatformConfig.defaultConfig().getConfigDir().resolve(CONFIG_FILE)); | ||
} | ||
|
||
public List<String> getProfiles() { | ||
return config.getBaseVoltages() | ||
.stream() | ||
.map(BaseVoltageConfig::getProfile) | ||
.distinct() | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public String getDefaultProfile() { | ||
return config.getDefaultProfile(); | ||
} | ||
|
||
public List<String> getBaseVoltageNames(String profile) { | ||
Objects.requireNonNull(profile); | ||
return config.getBaseVoltages() | ||
.stream() | ||
.filter(baseVoltage -> baseVoltage.getProfile().equals(profile)) | ||
.map(BaseVoltageConfig::getName) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public String getBaseVoltageName(double voltage, String profile) { | ||
Objects.requireNonNull(profile); | ||
return config.getBaseVoltages() | ||
.stream() | ||
.filter(baseVoltage -> baseVoltage.getProfile().equals(profile) | ||
&& baseVoltage.getMinValue() <= voltage | ||
&& baseVoltage.getMaxValue() > voltage) | ||
.map(BaseVoltageConfig::getName) | ||
.findFirst() | ||
.orElse(null); | ||
} | ||
|
||
public String getColor(String baseVoltageName, String profile) { | ||
Objects.requireNonNull(baseVoltageName); | ||
Objects.requireNonNull(profile); | ||
return config.getBaseVoltages() | ||
.stream() | ||
.filter(baseVoltage -> baseVoltage.getProfile().equals(profile) | ||
&& baseVoltage.getName().equals(baseVoltageName)) | ||
.map(BaseVoltageConfig::getColor) | ||
.findFirst() | ||
.orElse(null); | ||
} | ||
|
||
public String getColor(double voltage, String profile) { | ||
Objects.requireNonNull(profile); | ||
return config.getBaseVoltages() | ||
.stream() | ||
.filter(baseVoltage -> baseVoltage.getProfile().equals(profile) | ||
&& baseVoltage.getMinValue() <= voltage | ||
&& baseVoltage.getMaxValue() > voltage) | ||
.map(BaseVoltageConfig::getColor) | ||
.findFirst() | ||
.orElse(null); | ||
} | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
base-voltage-color/src/main/java/com/powsybl/basevoltage/BaseVoltageConfig.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,61 @@ | ||
/** | ||
* Copyright (c) 2019, 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.basevoltage; | ||
|
||
/** | ||
* | ||
* @author Massimo Ferraro <[email protected]> | ||
*/ | ||
public class BaseVoltageConfig { | ||
|
||
private String name; | ||
private double minValue; | ||
private double maxValue; | ||
private String color; | ||
private String profile; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public double getMinValue() { | ||
return minValue; | ||
} | ||
|
||
public void setMinValue(double minValue) { | ||
this.minValue = minValue; | ||
} | ||
|
||
public double getMaxValue() { | ||
return maxValue; | ||
} | ||
|
||
public void setMaxValue(double maxValue) { | ||
this.maxValue = maxValue; | ||
} | ||
|
||
public String getColor() { | ||
return color; | ||
} | ||
|
||
public void setColor(String color) { | ||
this.color = color; | ||
} | ||
|
||
public String getProfile() { | ||
return profile; | ||
} | ||
|
||
public void setProfile(String profile) { | ||
this.profile = profile; | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
base-voltage-color/src/main/java/com/powsybl/basevoltage/BaseVoltagesConfig.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,36 @@ | ||
/** | ||
* Copyright (c) 2019, 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.basevoltage; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* | ||
* @author Massimo Ferraro <[email protected]> | ||
*/ | ||
public class BaseVoltagesConfig { | ||
|
||
private List<BaseVoltageConfig> baseVoltages; | ||
private String defaultProfile; | ||
|
||
public List<BaseVoltageConfig> getBaseVoltages() { | ||
return baseVoltages; | ||
} | ||
|
||
public void setBaseVoltages(List<BaseVoltageConfig> baseVoltages) { | ||
this.baseVoltages = baseVoltages; | ||
} | ||
|
||
public String getDefaultProfile() { | ||
return defaultProfile; | ||
} | ||
|
||
public void setDefaultProfile(String defaultProfile) { | ||
this.defaultProfile = defaultProfile; | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
base-voltage-color/src/test/java/com/powsybl/basevoltage/BaseVoltageColorTest.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,58 @@ | ||
/** | ||
* Copyright (c) 2019, 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.basevoltage; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNull; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Arrays; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* | ||
* @author Massimo Ferraro <[email protected]> | ||
*/ | ||
public class BaseVoltageColorTest { | ||
|
||
@Test | ||
public void test() throws IOException, URISyntaxException { | ||
Path configFile = Paths.get(getClass().getResource("/base-voltages.yml").toURI()); | ||
BaseVoltageColor baseVoltageColor = new BaseVoltageColor(configFile); | ||
// getProfiles | ||
assertEquals(Arrays.asList("RTE"), baseVoltageColor.getProfiles()); | ||
// getDefaultProfile | ||
assertEquals("RTE", baseVoltageColor.getDefaultProfile()); | ||
// getBaseVoltageNames | ||
assertEquals(Arrays.asList("400", "225"), baseVoltageColor.getBaseVoltageNames("RTE")); | ||
// getBaseVoltageName | ||
assertNull(baseVoltageColor.getBaseVoltageName(500, "RTE")); | ||
assertEquals("400", baseVoltageColor.getBaseVoltageName(450, "RTE")); | ||
assertEquals("400", baseVoltageColor.getBaseVoltageName(400, "RTE")); | ||
assertEquals("400", baseVoltageColor.getBaseVoltageName(300, "RTE")); | ||
assertEquals("225", baseVoltageColor.getBaseVoltageName(250, "RTE")); | ||
assertEquals("225", baseVoltageColor.getBaseVoltageName(180, "RTE")); | ||
assertNull(baseVoltageColor.getBaseVoltageName(150, "RTE")); | ||
// getColor by name | ||
assertEquals("#BBBBBBB", baseVoltageColor.getColor("400", "RTE")); | ||
assertEquals("#AAAAAAA", baseVoltageColor.getColor("225", "RTE")); | ||
assertNull(baseVoltageColor.getColor("150", "RTE")); | ||
// getColor by voltage | ||
assertNull(baseVoltageColor.getColor(500, "RTE")); | ||
assertEquals("#BBBBBBB", baseVoltageColor.getColor(450, "RTE")); | ||
assertEquals("#BBBBBBB", baseVoltageColor.getColor(400, "RTE")); | ||
assertEquals("#BBBBBBB", baseVoltageColor.getColor(300, "RTE")); | ||
assertEquals("#AAAAAAA", baseVoltageColor.getColor(250, "RTE")); | ||
assertEquals("#AAAAAAA", baseVoltageColor.getColor(180, "RTE")); | ||
assertNull(baseVoltageColor.getColor(150, "RTE")); | ||
} | ||
|
||
} |
Oops, something went wrong.