diff options
author | j-james | 2022-12-03 05:59:16 +0000 |
---|---|---|
committer | j-james | 2022-12-03 05:59:16 +0000 |
commit | 35741efd699e67382367411fcb991e2366a6774f (patch) | |
tree | b145a8460bb272d11426e05c3153608d8888db40 /src/main/model/layout | |
parent | a164c6c77d67c4622cb393c3a92b19acf371a58e (diff) |
Add class and function comments
Diffstat (limited to 'src/main/model/layout')
-rw-r--r-- | src/main/model/layout/BlockLayout.java | 5 | ||||
-rw-r--r-- | src/main/model/layout/DocumentLayout.java | 3 | ||||
-rw-r--r-- | src/main/model/layout/FlexLayout.java | 1 | ||||
-rw-r--r-- | src/main/model/layout/InlineLayout.java | 4 | ||||
-rw-r--r-- | src/main/model/layout/Layout.java | 7 |
5 files changed, 20 insertions, 0 deletions
diff --git a/src/main/model/layout/BlockLayout.java b/src/main/model/layout/BlockLayout.java index c2ec40d..7f59dc6 100644 --- a/src/main/model/layout/BlockLayout.java +++ b/src/main/model/layout/BlockLayout.java @@ -4,12 +4,17 @@ 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( diff --git a/src/main/model/layout/DocumentLayout.java b/src/main/model/layout/DocumentLayout.java index 84f58f2..299be25 100644 --- a/src/main/model/layout/DocumentLayout.java +++ b/src/main/model/layout/DocumentLayout.java @@ -2,6 +2,7 @@ package model.layout; import java.awt.*; +// root document layout style public class DocumentLayout extends Layout { /* @@ -13,6 +14,8 @@ public class DocumentLayout extends Layout { super(null, null); } + // MODIFIES: this + // EFFECTS: recursively constructs the layout tree public void layout() { this.setLocation(new Point(0, 0)); this.setDimension(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT)); diff --git a/src/main/model/layout/FlexLayout.java b/src/main/model/layout/FlexLayout.java index 7b1e759..aaa5f0f 100644 --- a/src/main/model/layout/FlexLayout.java +++ b/src/main/model/layout/FlexLayout.java @@ -6,6 +6,7 @@ import model.html.Node; // https://drafts.csswg.org/css-flexbox/#layout-algorithm public class FlexLayout extends Layout { + // Constructs a new FlexLayout public FlexLayout(Node node, Layout parent) { super(node, parent); } diff --git a/src/main/model/layout/InlineLayout.java b/src/main/model/layout/InlineLayout.java index 219b863..2de69d6 100644 --- a/src/main/model/layout/InlineLayout.java +++ b/src/main/model/layout/InlineLayout.java @@ -4,15 +4,19 @@ import model.html.Node; import java.awt.*; +// Inline layout style public class InlineLayout extends Layout { private Point cursor; + // Constructs a new InlineLayout public InlineLayout(Node node, Layout parent) { super(node, parent); cursor = new Point(); } + // MODIFIES: this + // EFFECTS: recursively constructs the layout tree public void layout() { this.setLocation(this.getParent().getLocation()); this.getPreviousSibling().ifPresent( diff --git a/src/main/model/layout/Layout.java b/src/main/model/layout/Layout.java index f9ef70e..4dbedb5 100644 --- a/src/main/model/layout/Layout.java +++ b/src/main/model/layout/Layout.java @@ -6,6 +6,7 @@ import model.html.Node; import java.awt.*; import java.util.*; +// Generic Layout class public abstract class Layout { private Point location; private Dimension dimension; @@ -30,6 +31,8 @@ public abstract class Layout { // the big function public abstract void layout(); + // MODIFIES: this + // EFFECTS: recursively constructs the layout tree public Layout(Node node, Layout parent) { this.associatedNode = node; @@ -44,6 +47,8 @@ public abstract class Layout { // eh, probably the best place to put this // parent MAY BE nil: a handy call to Optional.ofNullable allows this + // MODIFIES: this + // EFFECTS: recursively constructs the layout tree public static ArrayList<Layout> constructTree(ArrayList<Node> html, Layout parent) { ArrayDeque<Layout> result = new ArrayDeque<>(); for (Node node : html) { @@ -69,6 +74,8 @@ public abstract class Layout { return new ArrayList<>(result); // haha } + // MODIFIES: this + // EFFECTS: recursively constructs the layout tree public static DocumentLayout constructTree(ArrayList<Node> html) { DocumentLayout result = new DocumentLayout(); result.setChildren(constructTree(html, result)); |