diff options
Diffstat (limited to 'src/main/ui')
-rw-r--r-- | src/main/ui/BrowserApp.java | 4 | ||||
-rw-r--r-- | src/main/ui/BrowserBar.java | 1 | ||||
-rw-r--r-- | src/main/ui/BrowserCanvas.java | 20 | ||||
-rw-r--r-- | src/main/ui/BrowserWindow.java | 6 |
4 files changed, 15 insertions, 16 deletions
diff --git a/src/main/ui/BrowserApp.java b/src/main/ui/BrowserApp.java index 36f2005..6f871c5 100644 --- a/src/main/ui/BrowserApp.java +++ b/src/main/ui/BrowserApp.java @@ -45,10 +45,10 @@ public class BrowserApp { for (Node node: html) { switch (node) { case ElementNode e -> { - renderHtml(e.getChildren()); + renderHtml(e.children); } default -> { - println(node.getData()); + println(node.data()); } } } diff --git a/src/main/ui/BrowserBar.java b/src/main/ui/BrowserBar.java index 131fe19..8026e49 100644 --- a/src/main/ui/BrowserBar.java +++ b/src/main/ui/BrowserBar.java @@ -29,7 +29,6 @@ public class BrowserBar extends JToolBar { openUriButton = new JButton("Go"); openUriButton.addActionListener(openTab()); add(openUriButton); - } private ActionListener openTab() { diff --git a/src/main/ui/BrowserCanvas.java b/src/main/ui/BrowserCanvas.java index 43481ef..ea20e81 100644 --- a/src/main/ui/BrowserCanvas.java +++ b/src/main/ui/BrowserCanvas.java @@ -13,13 +13,13 @@ public class BrowserCanvas extends JPanel { public BrowserCanvas(ArrayList<Node> html) { super(); this.currentLayout = Layout.constructTree(html); - printTree(this.currentLayout.getChildren()); + printTree(this.currentLayout.children); } private void printTree(ArrayList<Layout> tree) { for (Layout node : tree) { - System.out.println(System.identityHashCode(node.getLocation())); - printTree((node).getChildren()); +// System.out.println(System.identityHashCode(node.location)); + printTree((node).children); } } @@ -27,21 +27,21 @@ public class BrowserCanvas extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); Point location = new Point(10, 20); // we need a mutable reference - renderHtml(this.currentLayout.getChildren(), g, location); + renderHtml(this.currentLayout.children, g, location); } private void renderHtml(ArrayList<Layout> tree, Graphics g, Point location) { for (Layout layout : tree) { -// System.out.println(layout.getLocation()); - g.drawRect(layout.getLocation().x, layout.getLocation().y, layout.getDimension().width, layout.getDimension().height); - if (layout.getAssociatedNode() instanceof TextNode) { - if (layout.getAssociatedNode().getData().length() > 5) { +// System.out.println(layout.location); + g.drawRect(layout.location.x, layout.location.y, layout.dimension.width, layout.dimension.height); + if (layout.associatedNode instanceof TextNode) { + if (layout.associatedNode.data().length() > 5) { // System.out.println(location); - g.drawString(layout.getAssociatedNode().getData(), layout.getLocation().x, layout.getLocation().y); + g.drawString(layout.associatedNode.data(), layout.location.x, layout.location.y); g.drawString("X", 10, 20); } } else { - renderHtml(layout.getChildren(), g, location); + renderHtml(layout.children, g, location); } } } diff --git a/src/main/ui/BrowserWindow.java b/src/main/ui/BrowserWindow.java index 94bd2d8..abf164f 100644 --- a/src/main/ui/BrowserWindow.java +++ b/src/main/ui/BrowserWindow.java @@ -32,11 +32,11 @@ public class BrowserWindow extends JFrame { } public void render(String uri) { - state.setCurrentTab(uri); + state.currentTab = uri; remove(canvas); -// System.out.println(state.getCurrentTab()); +// System.out.println(state.currentTab); try { - String file = Files.readString(Path.of(state.getCurrentTab())); + String file = Files.readString(Path.of(state.currentTab)); HtmlParser parser = new HtmlParser(); canvas = new BrowserCanvas(parser.parseHtml(file)); } catch (Exception e) { |