added java2d class

This commit is contained in:
Sem van der Hoeven
2020-03-04 20:25:37 +01:00
parent 5f79fb06f7
commit 73672d8ae8
3 changed files with 57 additions and 1 deletions

View File

@@ -8,5 +8,6 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="jsoup-1.12.1" level="project" />
<orderEntry type="library" name="fxgraphics2d-1.10" level="project" />
</component>
</module>

View File

@@ -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());
}

View File

@@ -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() {
}
}