1 | for (int i = 0; i < blocks.size(); i++) {↵ | | 1 | for (int i = 0; i < blocks.size(); i++) {↵
|
2 | Block block = (Block) blocks.get(i);↵ | | 2 | Block block = (Block) blocks.get(i);↵
|
3 | Size2D size = block.arrange(g2, RectangleConstraint.NONE);↵ | | 3 | Size2D size = block.arrange(g2, RectangleConstraint.NONE);↵
|
4 | if (y + size.height <= height) {↵ | | 4 | if (x + size.width <= width) {↵
|
5 | itemsInColumn.add(block);↵ | | 5 | itemsInRow.add(block);↵
|
6 | block.setBounds(↵ | | 6 | block.setBounds(↵
|
7 | new Rectangle2D.Double(x, y, size.width, size.height)↵ | | 7 | new Rectangle2D.Double(x, y, size.width, size.height)↵
|
8 | );↵ | | 8 | );↵
|
9 | y = y + size.height + this.verticalGap;↵ | | 9 | x = x + size.width + this.horizontalGap;↵
|
10 | maxWidth = Math.max(maxWidth, size.width);↵ | | 10 | maxHeight = Math.max(maxHeight, size.height);↵
|
11 | }↵ | | 11 | }↵
|
12 | else {↵ | | 12 | else {↵
|
13 | if (itemsInColumn.isEmpty()) {↵ | | 13 | if (itemsInRow.isEmpty()) {↵
|
14 | // place in this column (truncated) anyway↵ | | 14 | // place in this row (truncated) anyway↵
|
15 | block.setBounds(↵ | | 15 | block.setBounds(↵
|
16 | new Rectangle2D.Double(↵ | | 16 | new Rectangle2D.Double(↵
|
17 | x, y, size.width, Math.min(size.height, height - y)↵ | | 17 | x, y, Math.min(size.width, width - x), size.height↵
|
18 | )↵ | | 18 | )↵
|
19 | );↵ | | 19 | );↵
|
20 | y = 0.0;↵ | | 20 | x = 0.0;↵
|
21 | x = x + size.width + this.horizontalGap;↵ | | 21 | y = y + size.height + this.verticalGap;↵
|
22 | }↵ | | 22 | }↵
|
23 | else {↵ | | 23 | else {↵
|
24 | // start new column↵ | | 24 | // start new row↵
|
25 | itemsInColumn.clear();↵ | | 25 | itemsInRow.clear();↵
|
26 | x = x + maxWidth + this.horizontalGap;↵ | | 26 | x = ↵
|
27 | y = 0.0↵ | | 27 | 0.0;↵
|
28 | ;↵ | | 28 | y = y + maxHeight + this.verticalGap;↵
|
29 | maxWidth = size.width;↵ | | 29 | maxHeight = size.height;↵
|
30 | block.setBounds(↵ | | 30 | block.setBounds(↵
|
31 | new Rectangle2D.Double(↵ | | 31 | new Rectangle2D.Double(↵
|
32 | x, y, size.width, Math.min(size.height, height)↵ | | 32 | x, y, Math.min(size.width, width), size.height↵
|
33 | )↵ | | 33 | )↵
|
34 | );↵ | | 34 | );↵
|
35 | y = size.height + this.verticalGap;↵ | | 35 | x = size.width + this.horizontalGap;↵
|
36 | itemsInColumn.add(block);↵ | | 36 | itemsInRow.add(block);↵
|
37 | | | 37 |
|