aboutsummaryrefslogtreecommitdiff
path: root/src/main/model/layout/BlockLayout.java
blob: f011847cab41b692cea54e22eb18544392e4b58f (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
30
31
32
33
34
35
package model.layout;

import model.html.Node;

import java.awt.*;

// A block style layout.
public class BlockLayout extends Layout {

    // MODIFIES: this
    // EFFECTS: constructs a new BlockLayout
    public BlockLayout(Node node, Layout parent) {
        super(node, parent);
    }

    // MODIFIES: this
    // EFFECTS: recursively constructs the layout tree
    public void layout() {
        this.setLocation(this.getParent().getLocation());
        this.getPreviousSibling().ifPresent(
                sibling -> this.setY(sibling.getY() + sibling.getHeight()));
        this.getPreviousSibling().ifPresent(
                sibling -> System.out.println("bluh" + sibling.getAssociatedNode().getData()));

//        this.setDimension(this.getParent().getDimension());

        for (Layout child : this.getChildren()) {
            child.layout();
            this.setHeight(this.getHeight() + child.getHeight());
        }
        System.out.println(this.getAssociatedNode().getData() + this.getLocation());
        System.out.println(System.identityHashCode(this.getLocation()));
//        System.out.println(this.getAssociatedNode().getData() + this.getDimension());
    }
}