aboutsummaryrefslogtreecommitdiff
path: root/src/main/model/layout/DocumentLayout.java
blob: 92c0b008c12c916a60ad2aca05eb5a8c23bd81f6 (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
26
27
28
29
package model.layout;

import java.awt.*;
import java.util.ArrayList;

// root document layout style
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);
    }

    // MODIFIES: this
    // EFFECTS: recursively constructs the layout tree
    public void layout() {
        this.setLocation(new Point(10, 20));
        this.setDimension(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));

        for (Layout child : this.getChildren()) {
            child.layout();
            this.setHeight(this.getHeight() + child.getHeight());
        }
    }
}