aboutsummaryrefslogtreecommitdiff
path: root/src/main/model/layout/BlockLayout.java
blob: 92640355952c9f5d22694acdffac9b1c8ab360ab (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
package model.layout;

import model.html.Node;

import java.awt.*;

public class BlockLayout extends Layout {

    public BlockLayout(Node node, Layout parent) {
        super(node, parent);
    }

    // recursively construct the layout tree
    public void layout() {
        this.location = (Point) this.parent.location.clone();
        this.previousSibling.ifPresent(
                sibling ->  this.location.y = sibling.location.y + sibling.dimension.height);
//        this.previousSibling.ifPresent(
//                sibling -> System.out.println("bluh" + sibling.associatedNode.data()));

//        this.dimension = (Dimension) this.parent.dimension.clone();

        for (Layout child : this.children) {
            child.layout();
            this.dimension.height += child.dimension.height;
        }
//        System.out.println(this.associatedNode.data() + this.location);
//        System.out.println(System.identityHashCode(this.location));
//        System.out.println(this.associatedNode.data() + this.dimension);
    }
}