-
Notifications
You must be signed in to change notification settings - Fork 12
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
[WIP] adds a branch_labels df param to the get NAD and write NAD methods #942
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Christian Biasuzzi <[email protected]>
Signed-off-by: Christian Biasuzzi <[email protected]>
Signed-off-by: Christian Biasuzzi <[email protected]>
Signed-off-by: Christian Biasuzzi <[email protected]>
Signed-off-by: Christian Biasuzzi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
return (network, svgParameters) -> new DefaultLabelProvider(network, svgParameters) { | ||
@Override | ||
public Optional<EdgeInfo> getEdgeInfo(Graph graph, BranchEdge edge, BranchEdge.Side side) { | ||
CustomBranchLabels bl = branchLabels.get(edge.getEquipmentId()); | ||
String label = null; | ||
EdgeInfo.Direction arrowDirection = null; | ||
if (bl != null) { | ||
label = side == BranchEdge.Side.ONE ? bl.side1 : bl.side2; | ||
arrowDirection = side == BranchEdge.Side.ONE ? bl.arrow1 : bl.arrow2; | ||
} | ||
return Optional.of(new EdgeInfo("ActivePower", arrowDirection, null, label)); | ||
} | ||
|
||
@Override | ||
public String getLabel(Edge edge) { | ||
CustomBranchLabels bl = branchLabels.get(edge.getEquipmentId()); | ||
return (bl != null) ? bl.middle : null; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you open a PR on powsybl-diagram to add such a LabelProvider, with a constructor based on the given map? So that after next powsybl-diagram release we remove this code here.
@@ -416,6 +429,7 @@ def get_network_area_diagram(self, voltage_level_ids: Union[str, List[str]] = No | |||
low_nominal_voltage_bound: low bound to filter voltage level according to nominal voltage | |||
nad_parameters: parameters for network area diagram | |||
fixed_positions: optional dataframe used to set fixed coordinates for diagram elements. Positions for elements not specified in the dataframe will be computed using the current layout. | |||
branch_labels: optional dataframe used to set the labels on a branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
next step should be the other parameters of the LabelProvider
: a dataframe with buses description (bus id / description), a dataframe with voltage level description (vl id / description / details). And then comes the dataframe for the styles. Should we encapsulate all these dataframes in a bigger config object, or would it be ok to have these four dataframes as input at the end?
…ompletes documentation Signed-off-by: Christian Biasuzzi <[email protected]>
Quality Gate passed for 'pypowsybl-parent'Issues Measures |
Quality Gate passed for 'pypowsybl'Issues Measures |
After some discussing and thinking, could you encapsulate the branch_labels dataframe in an object? I think we could call it something like diagram customizer. Indeed, at the end there will be specific customization for specific usecases, each one customizing all the dataframes mentioned in above comment. To that end, we will provide for each usecase a method to build this object. This object would make it easier to use those predefinite customization than if it remains in separated arguments. |
Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
no
What kind of change does this PR introduce?
feature
What is the current behavior?
No label customization available
What is the new behavior (if this is a feature change)?
Adds a branch_labels parameter to the get_network_area_diagram and write_network_area_diagram.
Allows you to set branch labels (on the branch and on the branch edges) from the branch_labels dataframe parameter.
Does this PR introduce a breaking change or deprecate an API?