blob: b09ed109fa385ad892c947e5cc10d64905d9d13f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
package model.layout;
public class DocumentLayout extends Layout {
/*
* INCREDIBLY UNSAFE - but this is actually fine with our code design
* We only reference the node / parent layout from the child layout,
* and so as we aren't referencing them here it (should) be fine
*/
public DocumentLayout() {
super(null, null);
}
// recursively construct the layout tree
public void layout() {
this.location.x = DEFAULT_X;
this.location.y = DEFAULT_Y;
for (Layout child : this.children) {
child.layout();
this.dimension.height = Math.max(this.dimension.height, (child.location.y + child.dimension.height) - this.location.y);
this.dimension.width = Math.max(this.dimension.width, (child.location.x + child.dimension.width) - this.location.x);
}
}
}
|