I have the following case:
- An GridPane divided into cells, so f.e. 6 x 6 = 36 cells
- A concrete number of Elements which need to fit into this area, f.e. 6
- Each element has an area, f.e. {3, 6, 4, 5, 6, 12}, so that the total area is again the overall (36)
And here my question: how do I calculate how many possible options I have to:
Calculate row / colums span (height / width) of the elements : for an area of 6, the different options could for example be 6x1, 1x6, 3x2 and 2x3 .. A necessary condition is that elements need to be a square or a rectangle, so f.e. not an U or T-shape occupying the grid in the cells. Here is where I'm struggeling! so should I do cases like if cases? I guess there is a more efficient way to do so! And which would be the conditions?
Position those elements inside the area
I'm programming in java and javafx.
I tried the following approach so far for calculating span /height/width:
int NumberRow = 6;
int NumberColum = 6;
int columspan;
int rowspan;
int area = 6;
if (area / NumberRow == 1) {
columspan = 1;
rowspan = area;}
if (area/NumberColum== 1) {
columspan = area;
rowspan = 1;
}
// if area modulo NumberColum or NumberRow == 0 it's an multiple..
if (area % NumberColum == 0 ) {
???? --> what would make sense here ?
}
VBox v = new VBox();
v.getChildren().addAll(h1, t, image);
grid.add(v, colum, row, columspan, rowspan);