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 | |
parent | a164c6c77d67c4622cb393c3a92b19acf371a58e (diff) |
Add class and function comments
-rw-r--r-- | src/main/model/BrowserState.java | 9 | ||||
-rw-r--r-- | src/main/model/html/HtmlParser.java | 2 | ||||
-rw-r--r-- | src/main/model/html/Node.java | 1 | ||||
-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 | ||||
-rw-r--r-- | src/main/ui/BrowserBar.java | 1 | ||||
-rw-r--r-- | src/main/ui/BrowserCanvas.java | 1 |
10 files changed, 34 insertions, 0 deletions
diff --git a/src/main/model/BrowserState.java b/src/main/model/BrowserState.java index 6c1da07..bb15abf 100644 --- a/src/main/model/BrowserState.java +++ b/src/main/model/BrowserState.java @@ -5,10 +5,13 @@ import model.util.EventLog; import java.util.ArrayDeque; +// This BrowserState function collects the stateful portions of the browser into one modelable class. public class BrowserState { private ArrayDeque<String> tabs; private String currentTab; + // EFFECTS: constructs a new BrowserState + // MODIFIES: this public BrowserState(ArrayDeque<String> tabs, String currentTab) { this.tabs = tabs; this.currentTab = currentTab; @@ -22,10 +25,14 @@ public class BrowserState { return this.currentTab; } + // MODIFIES: this + // EFFECTS: Sets the current tab public void setCurrentTab(String tab) { this.currentTab = tab; } + // MODIFIES: this + // EFFECTS: add a new tab public void addTab(String added) { if (!this.tabs.contains(added)) { this.tabs.add(added); @@ -33,6 +40,8 @@ public class BrowserState { EventLog.getInstance().logEvent(new Event("Added tab " + added + " to tablist")); } + // MODIFIES: this + // EFFECTS: removes a tab from the tablist public void removeTab(String removed) { this.tabs.remove(removed); EventLog.getInstance().logEvent(new Event("Removed tab " + removed + " from tablist")); diff --git a/src/main/model/html/HtmlParser.java b/src/main/model/html/HtmlParser.java index e1ebaa1..5170205 100644 --- a/src/main/model/html/HtmlParser.java +++ b/src/main/model/html/HtmlParser.java @@ -45,6 +45,8 @@ public class HtmlParser implements JsonAble { private ParserState state; + // EFFECTS: constructs a new HTML parser. + // MODIFIES: this public HtmlParser() { result = new ArrayList<>(); unfinished = new ArrayDeque<>(); diff --git a/src/main/model/html/Node.java b/src/main/model/html/Node.java index 3284b3c..5c3ea41 100644 --- a/src/main/model/html/Node.java +++ b/src/main/model/html/Node.java @@ -10,5 +10,6 @@ public interface Node { // Return a representation of the Node. Useful for debugging. public String getData(); + // EFFECTS: returns a serialized form of the data public JSONObject serialize(); } 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)); diff --git a/src/main/ui/BrowserBar.java b/src/main/ui/BrowserBar.java index ed9e314..e9db3c3 100644 --- a/src/main/ui/BrowserBar.java +++ b/src/main/ui/BrowserBar.java @@ -6,6 +6,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.*; +// BrowserBar public class BrowserBar extends JToolBar { private BrowserWindow parent; diff --git a/src/main/ui/BrowserCanvas.java b/src/main/ui/BrowserCanvas.java index 6fea735..1502c3d 100644 --- a/src/main/ui/BrowserCanvas.java +++ b/src/main/ui/BrowserCanvas.java @@ -18,6 +18,7 @@ public class BrowserCanvas extends JPanel { this.html = html; } + // EFFECTS: paints a component onto a canvas @Override public void paintComponent(Graphics g) { super.paintComponent(g); |