forked from liuyubobobo/Play-with-Algorithm-Visualization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlgoVisualizer.java
41 lines (28 loc) · 828 Bytes
/
AlgoVisualizer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.awt.*;
public class AlgoVisualizer {
private static int DELAY = 40;
private FractalData data;
private AlgoFrame frame;
public AlgoVisualizer(int depth){
data = new FractalData(depth);
int sceneWidth = (int)Math.pow(3, depth);
int sceneHeight = (int)Math.pow(3, depth);
EventQueue.invokeLater(() -> {
frame = new AlgoFrame("Fractal Visualizer", sceneWidth,sceneHeight);
new Thread(() -> {
run();
}).start();
});
}
private void run(){
setData();
}
private void setData(){
frame.render(data);
AlgoVisHelper.pause(DELAY);
}
public static void main(String[] args) {
int depth = 6;
AlgoVisualizer vis = new AlgoVisualizer(depth);
}
}