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