Skip to content

Commit 7812b49

Browse files
committed
Fix code smell
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
1 parent 339c0c1 commit 7812b49

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

network-area-diagram/src/main/java/com/powsybl/nad/svg/DefaultEdgeRendering.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private List<Double> computeInjectionAngles(Graph graph, VoltageLevelNode vlNode
185185
return findAvailableAngles(anglesOtherEdges, nbInjections, svgParameters.getInjectionAperture());
186186
}
187187

188-
private List<Double> findAvailableAngles(List<Double> anglesOtherEdges, int nbAngles, double edgeAperture) {
188+
private List<Double> findAvailableAngles(List<Double> anglesOtherEdges, int nbAngles, double slotAperture) {
189189
if (!anglesOtherEdges.isEmpty()) {
190190
anglesOtherEdges.add(anglesOtherEdges.get(0) + 2 * Math.PI);
191191

@@ -194,16 +194,16 @@ private List<Double> findAvailableAngles(List<Double> anglesOtherEdges, int nbAn
194194
double totalDeltaAvailable = 0.;
195195
for (int i = 0; i < anglesOtherEdges.size() - 1; i++) {
196196
deltaAngles[i] = anglesOtherEdges.get(i + 1) - anglesOtherEdges.get(i);
197-
nbAvailableSlots[i] = (int) Math.floor(deltaAngles[i] / Math.toRadians(edgeAperture));
197+
nbAvailableSlots[i] = (int) Math.floor(deltaAngles[i] / Math.toRadians(slotAperture));
198198
if (nbAvailableSlots[i] > 0) {
199199
totalDeltaAvailable += deltaAngles[i];
200200
}
201201
}
202202

203-
if (nbAngles <= Arrays.stream(nbAvailableSlots).sum()) {
203+
if (nbAngles <= Arrays.stream(nbAvailableSlots).sum() && totalDeltaAvailable >= Math.toRadians(slotAperture)) {
204204
// Insert the angles in the "slots" separated by other edges which are large enough
205205
int[] nbInsertedAngles = computeAnglesInsertedNumber(nbAngles, nbAvailableSlots, totalDeltaAvailable, deltaAngles);
206-
return calculateInsertedAngles(nbInsertedAngles, deltaAngles, edgeAperture, anglesOtherEdges);
206+
return calculateInsertedAngles(nbInsertedAngles, deltaAngles, slotAperture, anglesOtherEdges);
207207
} else {
208208
// Not enough place in the slots: dividing the circle in nbAngles, starting in the middle of the biggest slot
209209
int iMaxDelta = IntStream.range(0, deltaAngles.length).boxed()
@@ -249,14 +249,14 @@ private int[] computeAnglesInsertedNumber(int nbAngles, int[] nbAvailableSlots,
249249
return nbInsertedAngles;
250250
}
251251

252-
private List<Double> calculateInsertedAngles(int[] nbInsertedAngles, double[] deltaAngles, double edgeAperture, List<Double> anglesOtherEdges) {
252+
private List<Double> calculateInsertedAngles(int[] nbInsertedAngles, double[] deltaAngles, double slotAperture, List<Double> anglesOtherEdges) {
253253
List<Double> insertedAngles = new ArrayList<>();
254254
for (int i = 0; i < nbInsertedAngles.length; i++) {
255255
int nbAnglesInDelta = nbInsertedAngles[i];
256256
if (nbAnglesInDelta == 0) {
257257
continue;
258258
}
259-
double extraSpace = deltaAngles[i] - Math.toRadians(edgeAperture) * nbAnglesInDelta;
259+
double extraSpace = deltaAngles[i] - Math.toRadians(slotAperture) * nbAnglesInDelta;
260260
double intraSpace = extraSpace / (nbAnglesInDelta + 1); // space between two added angles and between other edges and first/last angle
261261
double angleStep = (anglesOtherEdges.get(i + 1) - anglesOtherEdges.get(i) - intraSpace) / nbAnglesInDelta;
262262
double startAngle = anglesOtherEdges.get(i) + intraSpace / 2 + angleStep / 2;

0 commit comments

Comments
 (0)