aboutsummaryrefslogtreecommitdiff
path: root/src/main/model/layout/BlockLayout.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/model/layout/BlockLayout.java')
-rw-r--r--src/main/model/layout/BlockLayout.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/model/layout/BlockLayout.java b/src/main/model/layout/BlockLayout.java
new file mode 100644
index 0000000..8808d80
--- /dev/null
+++ b/src/main/model/layout/BlockLayout.java
@@ -0,0 +1,25 @@
+package model.layout;
+
+import model.html.Node;
+
+import java.awt.*;
+
+public class BlockLayout extends Layout {
+
+ public BlockLayout(Node node, Layout parent) {
+ super(node, parent);
+ }
+
+ public void layout() {
+ this.setLocation(this.getParent().getLocation());
+ this.getPreviousSibling().ifPresent(
+ sibling -> this.setY(sibling.getY() + sibling.getHeight()));
+
+ this.setDimension(this.getParent().getDimension());
+
+ for (Layout child : this.getChildren()) {
+ child.layout();
+ this.setHeight(this.getHeight() + child.getHeight());
+ }
+ }
+}