-
Notifications
You must be signed in to change notification settings - Fork 0
/
gaNeza.pde
56 lines (49 loc) · 1.48 KB
/
gaNeza.pde
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//This software is released under the MIT License.
//Copyright(c) 2014 Yui Arco Kita
//http://bluedog.herokuapp.com/ganeza
import java.util.Map;
Ganeza network;
void setup() {
size(800, 800);
frame.setResizable(true);
network = new Ganeza("north_america_name.json");
network.visualizer.c = color(0, 0, 0, 50);
network.visualizer.method = "FORCE_DIRECTED";
network.view.scale = 0.5;
discription();
}
void draw() {
background(255);
network.show();
}
void mousePressed() {
network.mousePressed();
}
void mouseDragged() {
network.mouseDragged();
}
void mouseWheel(MouseEvent event){
network.mouseWheel(event);
}
void keyPressed() {
if (key == 'c') {
network.visualizer.method = "CIRCLE";
}else if (key == 'f') {
network.visualizer.method = "FORCE_DIRECTED";
}else if (key == 'l') {
network.visualizer.method = "LINEUP";
}else if (key == 'S') {
save(""+year()+"_"+month()+"_"+day()+"_"+hour()+"_"+minute()+"_"+second()+".png");
}else if (key == 's') {
Node start_node = network.nodes.get((int)random(network.nodes.size()-1));
Node goal_node = network.nodes.get((int)random(network.nodes.size()-1));
println(start_node.name);
println(goal_node.name);
ArrayList<Node> path = network.analyzer.shortest_distance(start_node, goal_node);
network.create_subnetwork(path, "path", color(0, 200, 200, 255));
}else if (key == 'n') {
}
}
void discription() {
println("PRESS\nc->CIRCLE\nf->FORCE_DIRECTED\nS->save image at "+sketchPath(""));
}