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

Modify nad and sld api for better consistency #475

Closed
wants to merge 18 commits into from

Conversation

So-Fras
Copy link
Member

@So-Fras So-Fras commented Jan 13, 2023

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem ? If so, link to this issue using '#XXX' and skip the rest
#469

Does this PR introduce a breaking change or deprecate an API? If yes, check the following:

  • The Breaking Change or Deprecated label has been added
  • The migration guide has been updated in the github wiki (What changes might users need to make in their application due to this PR?)

@sonarcloud
Copy link

sonarcloud bot commented Jan 23, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell B 17 Code Smells

51.4% 51.4% Coverage
0.0% 0.0% Duplication

@So-Fras So-Fras changed the title [WIP] Modify nad ans sld api for better consistency [WIP] Modify nad and sld api for better consistency Feb 3, 2023
So-Fras and others added 14 commits March 28, 2023 15:27
…d signature to include filter

Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
…etrization

Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
…arameters

Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Thomas ADAM <tadam@silicom.fr>
@tadam50 tadam50 force-pushed the modify_nad_api_for_better_consistency_with_sld branch from 4bb8f3d to 030f16d Compare March 28, 2023 13:42
@So-Fras So-Fras marked this pull request as ready for review March 28, 2023 14:43
@So-Fras So-Fras changed the title [WIP] Modify nad and sld api for better consistency Modify nad and sld api for better consistency Mar 28, 2023
@So-Fras So-Fras requested a review from flo-dup March 28, 2023 14:44
Copy link
Contributor

@flo-dup flo-dup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! but I think there's still some work/rethinking before it is ready

@@ -0,0 +1,52 @@
package com.powsybl.nad;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright and authorship are missing for the new files of this PR

import com.powsybl.nad.svg.StyleProvider;
import com.powsybl.nad.svg.SvgParameters;

public class NetworkAreaDiagramConfiguration {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could simplify this with DiagramConfig, or just Config?

LayoutParameters layoutParameters = new LayoutParameters();
StyleProvider styleProvider;
LabelProvider labelProvider;
BiFunction<Network, SvgParameters, LabelProvider> labelProviderCreator = DefaultLabelProvider::new;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BiFunction<Network, SvgParameters, LabelProvider> labelProviderCreator = DefaultLabelProvider::new;
LabelProviderFactory labelProviderFactory = DefaultLabelProvider::new;

SvgParameters svgParameters = new SvgParameters();
LayoutParameters layoutParameters = new LayoutParameters();
StyleProvider styleProvider;
LabelProvider labelProvider;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this parameter, we shouldn't create it before build call.

Or in fact it should maybe be build only when calling config.getLabelProvider(). Indeed, one would expect one config to be network-agnostic, because you expect when speaking of config to reuse the same config for different networks. That implies that both StyleProvider and LabelProvider are created only when calling config.getLabelProvider(network). And then similarly for the idProvider.

Comment on lines 27 to 29
private static <R extends LabelProvider> R factory(Network network, SvgParameters svgParameters, BiFunction<Network, SvgParameters, R> function) {
return function.apply(network, svgParameters);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static <R extends LabelProvider> R factory(Network network, SvgParameters svgParameters, BiFunction<Network, SvgParameters, R> function) {
return function.apply(network, svgParameters);
}
@FunctionalInterface
public interface LabelProviderFactory {
LabelProvider create(Network network, SvgParameters svgParameters);
}

Comment on lines 72 to 74
.withSvgParameters(getSvgParameters())
.withStyleProvider(getStyleProvider(network))
.build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indenting isn't right


protected AbstractDiagramLabelProvider(ComponentLibrary componentLibrary, LayoutParameters layoutParameters) {
protected AbstractDiagramLabelProvider(ComponentLibrary componentLibrary, LayoutParameters layoutParameters, SvgParameters svgParameters) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be able to get rid of LayoutParameters here...

return this;
}

public boolean isRemoveFictitiousSwitchNodes() {
return removeFictitiousSwitchNodes;
public double getCgmesScaleFactor() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those cgmes parameters are unexpected here... The smart selector does not allow to pass any parameters, so LayoutParameters were used for cgmes-only parameters.
But ok to keep them in this PR while waiting for another PR to clean that. We could probably delete cmgesUseName, but cgmesScaleFactor and cgmesDiagramName are needed...

Copy link
Member Author

@So-Fras So-Fras Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it does not feel like the right place to put those cgmes parameters. It was indeed a quick and dirty way to deal with them.
I created an issue to track that.

@@ -34,8 +34,8 @@ public class DefaultDiagramLabelProvider extends AbstractDiagramLabelProvider {

protected final Network network;

public DefaultDiagramLabelProvider(Network net, ComponentLibrary componentLibrary, LayoutParameters layoutParameters) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we try to have more consistency between diagrams, we could also take the opportunity to rename this into DefaultLabelProvider

Comment on lines 48 to 52
SingleLineDiagramConfiguration singleLineDiagramConfiguration = new SingleLineDiagramConfigurationBuilder(network)
.withLayoutParameters(layoutParameters)
.withComponentLibrary(getResourcesComponentLibrary())
.withSvgParameters(svgParameters)
.build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid repeating this code block again and again, why don't you factorize it in toSvg? You could do that similarly to what was done before

So-Fras added 2 commits March 29, 2023 11:07
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
…nting

Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
@sonarcloud
Copy link

sonarcloud bot commented Mar 29, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

93.9% 93.9% Coverage
1.9% 1.9% Duplication

…ers to SvgParameters

Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
@So-Fras So-Fras mentioned this pull request Jun 5, 2023
5 tasks
@So-Fras
Copy link
Member Author

So-Fras commented Sep 27, 2023

See new PR #522

@So-Fras So-Fras closed this Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants