-
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.
* Use new AnimatedFeederInfoStyleProvider for animation * Add 2 thresholds in AnimatedFeederInfoStyleProvider constructor * Update svg test reference files * HvdcTest : fix svg generation at any time Signed-off-by: Thomas ADAM <tadam@silicom.fr> Signed-off-by: BenoitJeanson <benoit.jeanson@rte-france.com>
- Loading branch information
1 parent
9cf2675
commit eb81860
Showing
45 changed files
with
743 additions
and
281 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
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
76 changes: 76 additions & 0 deletions
76
...line-diagram-core/src/main/java/com/powsybl/sld/util/AnimatedFeederInfoStyleProvider.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,76 @@ | ||
/** | ||
* Copyright (c) 2023, 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/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.sld.util; | ||
|
||
import com.powsybl.iidm.network.*; | ||
import com.powsybl.sld.svg.DirectionalFeederInfo; | ||
import com.powsybl.sld.svg.FeederInfo; | ||
|
||
import java.util.*; | ||
|
||
import static com.powsybl.sld.svg.DiagramStyles.STYLE_PREFIX; | ||
|
||
/** | ||
* @author Thomas Adam <tadam at silicom.fr> | ||
*/ | ||
public class AnimatedFeederInfoStyleProvider extends TopologicalStyleProvider { | ||
|
||
private static final String ARROW_ANIMATION = STYLE_PREFIX + "arrow-animation"; | ||
|
||
private static final String ARROW_SPEED = "speed"; | ||
|
||
private static final String ARROW_ANIMATION_NO_SPEED = ARROW_ANIMATION + "-no-" + ARROW_SPEED; | ||
|
||
private static final String ARROW_ANIMATION_LOW_SPEED = ARROW_ANIMATION + "-low-" + ARROW_SPEED; | ||
|
||
private static final String ARROW_ANIMATION_AVERAGE_SPEED = ARROW_ANIMATION + "-average-" + ARROW_SPEED; | ||
|
||
private static final String ARROW_ANIMATION_HIGH_SPEED = ARROW_ANIMATION + "-high-" + ARROW_SPEED; | ||
|
||
private final double threshold1; | ||
|
||
private final double threshold2; | ||
|
||
public AnimatedFeederInfoStyleProvider(Network network, double threshold1, double threshold2) { | ||
super(network); | ||
this.threshold1 = threshold1; | ||
this.threshold2 = threshold2; | ||
} | ||
|
||
@Override | ||
public List<String> getFeederInfoStyles(FeederInfo info) { | ||
List<String> styles = new ArrayList<>(super.getFeederInfoStyles(info)); | ||
if (info instanceof DirectionalFeederInfo) { | ||
DirectionalFeederInfo feederInfo = (DirectionalFeederInfo) info; | ||
feederInfo.getRightLabel().ifPresent(label -> { | ||
double value = Math.abs(feederInfo.getValue()); | ||
if (!Double.isNaN(value) && value > 0) { | ||
if (value > threshold2) { | ||
styles.add(ARROW_ANIMATION_HIGH_SPEED); | ||
} else if (value > threshold1) { | ||
styles.add(ARROW_ANIMATION_AVERAGE_SPEED); | ||
} else { | ||
styles.add(ARROW_ANIMATION_LOW_SPEED); | ||
} | ||
} else { | ||
styles.add(ARROW_ANIMATION_NO_SPEED); | ||
} | ||
}); | ||
} else { | ||
styles.add(ARROW_ANIMATION_NO_SPEED); | ||
} | ||
return styles; | ||
} | ||
|
||
@Override | ||
public List<String> getCssFilenames() { | ||
List<String> styles = new ArrayList<>(super.getCssFilenames()); | ||
styles.add("animations.css"); | ||
return styles; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
single-line-diagram/single-line-diagram-core/src/main/resources/animations.css
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,33 @@ | ||
/* ----------------------------------------------------------------------- */ | ||
/* File : animations.css ------------------------------------------------- */ | ||
/* feeder info */ | ||
.sld-cell-direction-top :not(.sld-arrow-animation-no-speed) .sld-arrow-in { | ||
offset-rotate: 0deg; | ||
offset-path: path('M 0,-10 0,10'); | ||
animation: move var(--sld-arrow-animation-parameters, 0s); | ||
} | ||
.sld-cell-direction-top :not(.sld-arrow-animation-no-speed) .sld-arrow-out { | ||
offset-rotate: 0deg; | ||
offset-path: path('M 0,10 0,-10'); | ||
animation: move var(--sld-arrow-animation-parameters, 0s); | ||
} | ||
.sld-cell-direction-bottom :not(.sld-arrow-animation-no-speed) .sld-arrow-in { | ||
offset-rotate: 0deg; | ||
offset-path: path('M 0,10 0,-10'); | ||
animation: move var(--sld-arrow-animation-parameters, 0s); | ||
} | ||
.sld-cell-direction-bottom :not(.sld-arrow-animation-no-speed) .sld-arrow-out { | ||
offset-rotate: 0deg; | ||
offset-path: path('M 0,-10 0,10'); | ||
animation: move var(--sld-arrow-animation-parameters, 0s); | ||
} | ||
@keyframes move { | ||
to { | ||
offset-distance: 100%; | ||
} | ||
} | ||
|
||
/* Set arrows animation speeds */ | ||
.sld-arrow-animation-low-speed { --sld-arrow-animation-parameters: 3s infinite linear } | ||
.sld-arrow-animation-average-speed { --sld-arrow-animation-parameters: 2s infinite linear } | ||
.sld-arrow-animation-high-speed { --sld-arrow-animation-parameters: 1s infinite linear } |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.