diff options
author | j-james | 2022-12-22 01:36:49 +0000 |
---|---|---|
committer | j-james | 2022-12-22 01:36:49 +0000 |
commit | 0e693fd4814572712a4192cb4f176e71f7a344f7 (patch) | |
tree | 9fb7daba882a025d368775aed9d518f565a40db2 /src/main/model/layout/InlineLayout.java | |
parent | 35741efd699e67382367411fcb991e2366a6774f (diff) |
Implement the basics of a recursive layout renderer
Diffstat (limited to 'src/main/model/layout/InlineLayout.java')
-rw-r--r-- | src/main/model/layout/InlineLayout.java | 18 |
1 files changed, 17 insertions, 1 deletions
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) { |