This commit is contained in:
@@ -90,29 +90,23 @@ public class RenderableMultidoku {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Coordinate getMaxSudokuCoordinate(Map<Sudoku, Coordinate> sudokusOffset) {
|
private static Coordinate getMaxSudokuCoordinate(Map<Sudoku, Coordinate> sudokusOffset) {
|
||||||
Coordinate maxCoordinate = null;
|
int maxX = 0;
|
||||||
Sudoku maxSudoku = null;
|
int maxY = 0;
|
||||||
float maxDistanceSquared = 0;
|
Sudoku lastSudoku = null;
|
||||||
for (var entry : sudokusOffset.entrySet()) {
|
for (var entry : sudokusOffset.entrySet()) {
|
||||||
Coordinate coordinate = entry.getValue();
|
Coordinate coordinate = entry.getValue();
|
||||||
float distanceSquared = coordinate.getX() * coordinate.getX() + coordinate.getY() * coordinate.getY();
|
if (coordinate.getX() > maxX)
|
||||||
if (maxCoordinate == null) {
|
maxX = coordinate.getX();
|
||||||
maxCoordinate = coordinate;
|
if (coordinate.getY() > maxY)
|
||||||
maxDistanceSquared = distanceSquared;
|
maxY = coordinate.getY();
|
||||||
maxSudoku = entry.getKey();
|
lastSudoku = entry.getKey();
|
||||||
}
|
|
||||||
|
|
||||||
if (distanceSquared > maxDistanceSquared) {
|
|
||||||
maxDistanceSquared = distanceSquared;
|
|
||||||
maxSudoku = entry.getKey();
|
|
||||||
maxCoordinate = coordinate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int blockWidth = maxSudoku.getBlockWidth();
|
Coordinate maxCoordinate = new Coordinate(maxX, maxY);
|
||||||
int blockHeight = maxSudoku.getSize() / blockWidth;
|
// tous les sudokus sont censés faire la même taille
|
||||||
|
int sudokuSize = lastSudoku.getSize();
|
||||||
|
|
||||||
return new Coordinate(maxCoordinate.getX() + maxSudoku.getSize(), maxCoordinate.getY() + maxSudoku.getSize());
|
return new Coordinate(maxCoordinate.getX() + sudokuSize, maxCoordinate.getY() + sudokuSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RenderableMultidoku fromMultidoku(MultiDoku doku) {
|
public static RenderableMultidoku fromMultidoku(MultiDoku doku) {
|
||||||
|
|||||||
Reference in New Issue
Block a user