-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFlowprint.pde
More file actions
170 lines (144 loc) · 3.85 KB
/
Flowprint.pde
File metadata and controls
170 lines (144 loc) · 3.85 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import processing.pdf.*;
import processing.video.*;
import org.gicentre.utils.spatial.*;
import controlP5.*;
import processing.opengl.*;
/**
* CONFIGURATION START
*/
float BUS_SPEED = 0.2;
float MAX_SPEED = 1.40;
static final int PANE_WIDTH = 1000;
static final int PANE_HEIGHT = 800;
static final int DEFAULT_NET = 0;
static final String DEFAULT_MODE = "topology";
static final String ROOT_DIR = "/casa/Flowprint"; //change this
static final String VIDEO_FILE = "flowprint-oyster1.mov";
static final String PDF_FILE = "reach-vis.pdf";
boolean debug = false;
boolean video = false;
boolean attribs = false; //whether to visualise node attributes
boolean trueAspectRatio = false;
boolean trails = false;
/**
* CONFIGURATION END
*/
int MaxY=0;
int MaxX=0;
String MaxYIndex;
String MinYIndex;
int MinY=0;
int MinX=0;
String MaxXIndex;
String MinXIndex;
int globalOffset = 1000;
int refreshRate = 100;
static int DEBUG_WARN = 2;
String[] debugLevels;
Network net;
ControlPanel cp;
ControlP5 controlP5;
MovieMaker mm;
void setup()
{
size(screen.width, screen.height);
fill(#FFFFFF);
frameRate(30);
smooth();
//noLoop();
PFont myFont = createFont("Helvetica", 10);
debugLevels = new String[3];
debugLevels[0] = "info";
debugLevels[1] = "warn";
debugLevels[DEBUG_WARN] = "error";
textFont(myFont);
controlP5 = new ControlP5(this);
//debug(combine(PGraphicsPDF.listFonts(),","));
cp = new ControlPanel(controlP5);
net = new Network();
net.init();
if(video) mm = new MovieMaker(this, 1000, 800, VIDEO_FILE,
30, MovieMaker.SORENSON, MovieMaker.HIGH);
background(#000000);
fill(#FFFFFF);
cp.draw();
}
void mouseReleased()
{
}
void mousePressed()
{
net.findNode(mouseX,mouseY);
}
void controlEvent(ControlEvent theEvent)
{
//debug("got a control event from controller with id "+theEvent.controller().id() + " and value " + theEvent.controller().value());
cp.controlEvent(theEvent);
}
void zoom()
{
print("zooming\n");
net.setZoomScale(net.getZoomScale()/2);
background(#000000);
net.run();
}
void draw()
{
if(!trails) {
background(#000000);
fill(#FFFFFF);
} else {
noStroke();
fill(#000000,5);
rect(0,0,1600,1600);
fill(#FFFFFF);
}
cp.drawBG();
net.run();
if(video) mm.addFrame(); // Add window's pixels to movie
}
void keyPressed() {
if(key==ENTER) {
debug("enter pressed");
beginRecord(PDF, PDF_FILE);
draw();
}
}
void keyReleased() {
if(key==ENTER) {
debug("enter released");
endRecord();
}
}
void saveSVG(){
saveFrame("test.svg");
}
void debug(String msg)
{
debug(msg,0);
}
void debug(int msg)
{
debug(""+msg,0);
}
void debug(String msg, int level)
{
if(debug) {
print("[" + debugLevels[level] +"] " + msg+"\n");
}
}
public String ltrim(String source)
{
return source.replaceAll("^\\s+", "");
}
String combine(String[] s, String glue)
{
int k=s.length;
if (k==0)
return null;
StringBuilder out=new StringBuilder();
out.append(s[0]);
for (int x=1;x<k;++x)
out.append(glue).append(s[x]);
return out.toString();
}