diff --git a/WebCrawler.iml b/WebCrawler.iml index f47cdd6..4e4c0be 100644 --- a/WebCrawler.iml +++ b/WebCrawler.iml @@ -8,5 +8,6 @@ + \ No newline at end of file diff --git a/src/main/java/webcrawler/CrawlBranch.java b/src/main/java/webcrawler/CrawlBranch.java index 7fd33e3..f772e3d 100644 --- a/src/main/java/webcrawler/CrawlBranch.java +++ b/src/main/java/webcrawler/CrawlBranch.java @@ -65,7 +65,7 @@ public class CrawlBranch { //System.out.println("ERROR -- call crawl before searhing"); return -1; } - print(String.format("Searching for %s...\n", word)); + print(String.format("Searching for %s...", word)); String bodyText = this.htmlDocument.body().text(); return count(bodyText.toLowerCase(), word.toLowerCase()); } diff --git a/src/main/java/webcrawler/Visualiser.java b/src/main/java/webcrawler/Visualiser.java new file mode 100644 index 0000000..ba3ffe3 --- /dev/null +++ b/src/main/java/webcrawler/Visualiser.java @@ -0,0 +1,55 @@ +package main.java.webcrawler; + +import javafx.animation.AnimationTimer; +import javafx.application.Application; +import javafx.embed.swing.JFXPanel; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.canvas.Canvas; +import javafx.stage.Stage; +import org.jfree.fx.FXGraphics2D; + +public class Visualiser extends Application { + private Stage stage; + private double frameTime = 0; + + @Override + public void start(Stage primaryStage) throws Exception { + this.stage = stage; + Canvas canvas = new Canvas(1920, 1080); + FXGraphics2D g2d = new FXGraphics2D(canvas.getGraphicsContext2D()); + draw(g2d); + stage.setScene(new Scene(new Group(canvas))); + stage.setTitle("Hello Animation"); + primaryStage.show(); + + new AnimationTimer() { + long last = -1; + @Override + public void handle(long now) { + if(last == -1) + last = now; + update((now - last) / 1000000000.0); + last = now; + draw(g2d); + } + }.start(); + } + + public void draw(FXGraphics2D graphics) { + + } + + public void update(double deltaTime) { + this.frameTime += deltaTime; + + if (this.frameTime > 1d / 60d) { + updateFrame(); + this.frameTime = 0d; + } + } + + private void updateFrame() { + + } +}