aboutsummaryrefslogtreecommitdiff
path: root/src/main/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/model')
-rw-r--r--src/main/model/layout/BlockLayout.java8
-rw-r--r--src/main/model/layout/DocumentLayout.java3
-rw-r--r--src/main/model/layout/InlineLayout.java18
-rw-r--r--src/main/model/layout/Layout.java3
4 files changed, 27 insertions, 5 deletions
diff --git a/src/main/model/layout/BlockLayout.java b/src/main/model/layout/BlockLayout.java
index 7f59dc6..f011847 100644
--- a/src/main/model/layout/BlockLayout.java
+++ b/src/main/model/layout/BlockLayout.java
@@ -19,13 +19,17 @@ public class BlockLayout extends 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());
+// 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());
}
}
diff --git a/src/main/model/layout/DocumentLayout.java b/src/main/model/layout/DocumentLayout.java
index 299be25..92c0b00 100644
--- a/src/main/model/layout/DocumentLayout.java
+++ b/src/main/model/layout/DocumentLayout.java
@@ -1,6 +1,7 @@
package model.layout;
import java.awt.*;
+import java.util.ArrayList;
// root document layout style
public class DocumentLayout extends Layout {
@@ -17,7 +18,7 @@ public class DocumentLayout extends Layout {
// MODIFIES: this
// EFFECTS: recursively constructs the layout tree
public void layout() {
- this.setLocation(new Point(0, 0));
+ this.setLocation(new Point(10, 20));
this.setDimension(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));
for (Layout child : this.getChildren()) {
diff --git a/src/main/model/layout/InlineLayout.java b/src/main/model/layout/InlineLayout.java
index 2de69d6..8e375d5 100644
--- a/src/main/model/layout/InlineLayout.java
+++ b/src/main/model/layout/InlineLayout.java
@@ -1,6 +1,8 @@
package model.layout;
+import model.html.ElementNode;
import model.html.Node;
+import model.html.TextNode;
import java.awt.*;
@@ -25,12 +27,26 @@ public class InlineLayout extends Layout {
this.setWidth(this.getParent().getWidth());
this.setCursor(this.getX(), this.getY());
+ Node node = this.getAssociatedNode();
+ if (node instanceof TextNode) {
+ if (node.getData().length() > 5) {
+ this.setHeight(20);
+// this.setWidth(this.getWidth() + node.getData().length());
+ }
+ } else if (node instanceof ElementNode) {
+ if (((ElementNode) node).getTag().equals("a")) {
+ this.setX(this.getX() + this.getParent().getWidth());
+ }
+ }
+
for (Layout child : this.getChildren()) {
child.layout();
+ this.setHeight(this.getHeight() + child.getHeight()); // fixme
}
// todo: recurse to calculate cursor
- this.setHeight(cursor.getY() - this.getY());
+// this.setHeight(cursor.getY() - this.getY());
+// System.out.println(this.getAssociatedNode().getData() + this.getLocation());
}
public void setCursor(Point cursor) {
diff --git a/src/main/model/layout/Layout.java b/src/main/model/layout/Layout.java
index 4dbedb5..4d9f48f 100644
--- a/src/main/model/layout/Layout.java
+++ b/src/main/model/layout/Layout.java
@@ -86,7 +86,8 @@ public abstract class Layout {
// man, fuck design patterns, this is so much goddamn code
public void setLocation(Point point) {
- this.location = point;
+ this.location.x = point.x;
+ this.location.y = point.y;
}
public void setX(double x) {