aboutsummaryrefslogtreecommitdiff
path: root/src/main/ui/BrowserCanvas.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/ui/BrowserCanvas.java')
-rw-r--r--src/main/ui/BrowserCanvas.java21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/main/ui/BrowserCanvas.java b/src/main/ui/BrowserCanvas.java
index ea20e81..cde894f 100644
--- a/src/main/ui/BrowserCanvas.java
+++ b/src/main/ui/BrowserCanvas.java
@@ -13,33 +13,26 @@ public class BrowserCanvas extends JPanel {
public BrowserCanvas(ArrayList<Node> html) {
super();
this.currentLayout = Layout.constructTree(html);
- printTree(this.currentLayout.children);
- }
-
- private void printTree(ArrayList<Layout> tree) {
- for (Layout node : tree) {
-// System.out.println(System.identityHashCode(node.location));
- printTree((node).children);
- }
+ this.setBackground(Color.BLACK);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Point location = new Point(10, 20); // we need a mutable reference
+ g.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
+ g.setColor(Color.WHITE);
+ g.drawString("X", location.x, location.y);
renderHtml(this.currentLayout.children, g, location);
}
private void renderHtml(ArrayList<Layout> tree, Graphics g, Point location) {
for (Layout layout : tree) {
-// System.out.println(layout.location);
+ g.setColor(new Color((int)(Math.random() * 0x1000000)));
g.drawRect(layout.location.x, layout.location.y, layout.dimension.width, layout.dimension.height);
+ g.setColor(Color.WHITE);
if (layout.associatedNode instanceof TextNode) {
- if (layout.associatedNode.data().length() > 5) {
-// System.out.println(location);
- g.drawString(layout.associatedNode.data(), layout.location.x, layout.location.y);
- g.drawString("X", 10, 20);
- }
+ g.drawString(layout.associatedNode.data(), layout.location.x, layout.location.y + layout.dimension.height - 5);
} else {
renderHtml(layout.children, g, location);
}