-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBigDataBarGraph.pde
More file actions
84 lines (75 loc) · 2.1 KB
/
BigDataBarGraph.pde
File metadata and controls
84 lines (75 loc) · 2.1 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
CCS ccs;
WIG wig;
PGraphics offScreenPg; // offscreen PGraphics window
boolean needToDraw = true;
boolean offScreenDrawing = false;
void setup () {
size(800, 800);
frameRate(30);
offScreenPg = createGraphics(800, 800);
ccs = new CCS("expression level", "chromosome position", offScreenPg);
wig = new WIG("L2-1_pm_mm.wig");
wig.read();
}
void draw () {
if (needToDraw == true) {
loadPixels();
thread("offScreen"); // do difficult stuff in a thread (e.g. render the pg object)
offScreenPg.loadPixels();
arrayCopy(offScreenPg.pixels, pixels);
updatePixels();
needToDraw = false;
}
if (keyPressed) { // interpret key press as a refresh command
needToDraw = true;
}
// arrayCopy(offScreenPg.pixels, pixels);
//updatePixels();
// show the current (x,y) position in the top right corner
fill(0);
rect(width-120, 0, 120, 20);
fill(255);
int xPos, yPos;
xPos = round((mouseX - ccs.xTrans) / ccs.xScale / ccs.zoomLevel);
yPos = round((mouseY - ccs.yTrans) / ccs.yScale / ccs.zoomLevel);
textAlign(RIGHT, TOP);
String position = "(" + xPos + "," + yPos + ")";
fill(255, 0, 0);
text(position, width, 0);
fill(255);
}
synchronized void offScreen() {
if (offScreenDrawing == false) {
offScreenDrawing = true;
offScreenPg.loadPixels();
offScreenPg.beginDraw();
offScreenPg.background(0);
offScreenPg.stroke(255);
offScreenPg.fill(255);
ccs.display();
for (int i=0; i < wig.size(); i++) {
WIGRecord r = wig.getRecord(i);
if (ccs.xMin > r.startPos) {
ccs.xMin = r.startPos;
}
if (ccs.xMax < r.endPos) {
ccs.xMax = r.endPos;
}
if (ccs.yMin > r.dataValue) {
ccs.yMin = round(r.dataValue);
}
if (ccs.yMax < r.dataValue) {
ccs.yMax = round(r.dataValue);
}
ccs.plotBar(r.startPos, round(r.dataValue), (r.endPos-r.startPos));
}
if (keyPressed && key == '+') {
ccs.zoomIn();
}
else if (keyPressed && key == '-') {
ccs.zoomOut();
}
offScreenPg.endDraw();
offScreenDrawing = false;
}
}