-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinal_Project_Design.pde
More file actions
291 lines (247 loc) · 8.63 KB
/
Final_Project_Design.pde
File metadata and controls
291 lines (247 loc) · 8.63 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
//declare global objects
Candidate Trump;
Candidate Clinton;
Button lineChart1;
Button lineChart;
Button barChart;
Button barChart1;
//declare boolean variables that define the state the draw is in. Clicking buttons will change the display. Initial state is state 0.
boolean state0=true;
boolean state1=false;
boolean state2=false;
boolean state3=false;
boolean state4=false;
boolean state5=false;
boolean state6=false;
boolean state7=false;
boolean state8=false;
void setup() {
size(1300, 800);
background(255);
Trump=new Candidate("Trump", "TrumpTweets.txt", "polling.csv", "Sep_26_Hofstra.txt", "Oct_9_Missouri.txt", "Oct_19_LasVegas.txt", "trump_hillary_search_popularity.csv", this);
Clinton=new Candidate("Clinton", "ClintonTweets.txt", "polling.csv", "Sep_26_Hofstra.txt", "Oct_9_Missouri.txt", "Oct_19_LasVegas.txt", "trump_hillary_search_popularity.csv", this);
}
void draw()
{
//Declares the buttons for all states except state 0
lineChart=new Button(100, height-30, 175, 50, "Visualize Line Chart", this);
barChart=new Button(300, height-30, 175, 50, "Visualize Bar Chart", this);
//initial state
if (state0) {
//Declares Buttons for home page and draws them
lineChart1=new Button(300, height*2/3, 500, height/3, "Visualize Line Chart", this);
barChart1=new Button(width-300, height*2/3, 500, height/3, "Visualize Bar Chart", this);
background(255);
textAlign(CENTER, CENTER);
textSize(32);
text("Cameron Zurmuhl and Emmett O'Toole", 650, 100);
textSize(25);
text("CS 105 Final Project", 650, 150);
text("Click A Button To Begin", 650, 180);
barChart1.drawButton(this);
lineChart1.drawButton(this);
}
//If the first button is clicked draws the linechart display
if (state1) {
background(255);
lineChart.drawButton(this);
barChart.drawButton(this);
Trump.drawLineChart(width-200, height-200, width/2, height/2, this);
Clinton.drawLineChart(width-200, height-200, width/2, height/2, this);
textSize(16);
fill(0);
text("Scroll over the chart to see popularity results for that day", width-50, height-50);
}
//If the second button is clicked draws the barchart display
if (state2) {
background(255);
lineChart.drawButton(this);
barChart.drawButton(this);
Trump.drawBarChart(width-200, height-200, width/2, height/2, this);
Clinton.drawBarChart(width-200, height-200, width/2, height/2, this);
}
//if the first trump bar is clicked, state is 3 and the word cloud for his words for that debate will appear
if (state3) {
background(255);
Trump.wordCloud(this, 0);
lineChart.drawButton(this);
barChart.drawButton(this);
}
//if second trump bar is clicked, state is 4 and the word cloud for his words for that debate will appear
if (state4) {
background(255);
Trump.wordCloud(this, 1);
lineChart.drawButton(this);
barChart.drawButton(this);
}
//if third trump bar is clicked, state is 5 and the word cloud for his words for that debate will appear
if (state5) {
background(255);
Trump.wordCloud(this, 2);
lineChart.drawButton(this);
barChart.drawButton(this);
}
//if first clinton bar is clicked, state is 6 and the word cloud for her words for that debate will appear
if (state6) {
background(255);
Clinton.wordCloud(this, 0);
lineChart.drawButton(this);
barChart.drawButton(this);
}
//if second clinton bar is clicked, state is 7 and the word cloud for her words for that debate will appear
if (state7) {
background(255);
Clinton.wordCloud(this, 1);
lineChart.drawButton(this);
barChart.drawButton(this);
}
//if third clinton bar is clicked, state is 8 and the word cloud for her words for that debate will appear
if (state8) {
background(255);
Clinton.wordCloud(this, 2);
lineChart.drawButton(this);
barChart.drawButton(this);
}
}
void mouseClicked() {
//variables that will be used for states 3-8
int numofTrumpWords1=Trump.getTranscript(1).getnumofCandidateWords();
int numofClintonWords1=Clinton.getTranscript(1).getnumofCandidateWords();
int numofTrumpWords2=Trump.getTranscript(2).getnumofCandidateWords();
int numofClintonWords2=Clinton.getTranscript(2).getnumofCandidateWords();
int numofTrumpWords3=Trump.getTranscript(3).getnumofCandidateWords();
int numofClintonWords3=Clinton.getTranscript(3).getnumofCandidateWords();
int chartHeight=height-200;
int chartWidth=width-200;
int barWidth=80;
int barSeparation=120;
int bar1pos=chartWidth/4;
int bar2pos=2*bar1pos;
int bar3pos=3*bar1pos;
boolean intrumpbar1=state2&&(mouseX>100+bar1pos-barSeparation+barWidth && mouseX<100+bar1pos-barSeparation+2*barWidth && mouseY<100+chartHeight && mouseY>100+chartHeight-(numofTrumpWords1*chartHeight/5500));
boolean inclintonbar1=state2&&(mouseX>100+bar1pos-barSeparation+2*barWidth && mouseX<100+bar1pos-barSeparation+3*barWidth && mouseY<100+chartHeight && mouseY>100+chartHeight-(numofClintonWords1*chartHeight/5500));
boolean intrumpbar2=state2&&(mouseX>100+bar2pos-barSeparation+barWidth && mouseX<100+bar2pos-barSeparation+2*barWidth && mouseY<100+chartHeight && mouseY>100+chartHeight-numofTrumpWords2*chartHeight/5500);
boolean inclintonbar2=state2&&(mouseX>100+bar2pos-barSeparation+2*barWidth && mouseX<100+bar2pos-barSeparation+3*barWidth && mouseY<100+chartHeight && mouseY>100+chartHeight-(numofClintonWords2*chartHeight/5500));
boolean inclintonbar3=state2&&(mouseX>100+3*bar1pos-barSeparation+barWidth && mouseX<100+3*bar1pos-barSeparation+2*barWidth && mouseY<100+chartHeight && mouseY>100+chartHeight-(numofTrumpWords3*chartHeight/5500));
boolean intrumpbar3=state2&&(mouseX>100+3*bar1pos-barSeparation+2*barWidth && mouseX<100+3*bar1pos-barSeparation+3*barWidth && mouseY<100+chartHeight && mouseY>100+chartHeight-(numofClintonWords3*chartHeight/5500));
//if intitial lineChart1 button is pressed, change to state 1
if (lineChart1.getinButton()&& state0) {
state0=false;
state1=true;
state2=false;
state3=false;
state4=false;
state5=false;
state6=false;
state7=false;
state8=false;
}
//if initial barChart1 button is pressed, change to state 2
if (barChart1.getinButton()&& state0) {
state0=false;
state1=false;
state2=true;
state3=false;
state4=false;
state5=false;
state6=false;
state7=false;
state8=false;
}
//if the lineChart button in any state is pressed, change to state 1
if (lineChart.getinButton()) {
state0=false;
state1=true;
state2=false;
state3=false;
state4=false;
state5=false;
state6=false;
state7=false;
state8=false;
}
//if the barChart button in any state is pressed, change to state 2
if (barChart.getinButton()) {
state0=false;
state1=false;
state2=true;
state3=false;
state4=false;
state5=false;
state6=false;
state7=false;
state8=false;
}
//if the first trump bar is clicked in state2, change to state 3
if (intrumpbar1) {
state0=false;
state1=false;
state2=false;
state3=true;
state4=false;
state5=false;
state6=false;
state7=false;
state8=false;
}
//if the second trump bar is clicked in state 2, change to state 4
if (intrumpbar2) {
state0=false;
state1=false;
state2=false;
state3=false;
state4=true;
state5=false;
state6=false;
state7=false;
state8=false;
}
//if the third trump bar is clicked in state 2, change to state 5
if (intrumpbar3) {
state0=false;
state1=false;
state2=false;
state3=false;
state4=false;
state5=true;
state6=false;
state7=false;
state8=false;
}
//if the first clinton bar is clicked in state 2, change to state 6
if (inclintonbar1) {
state0=false;
state1=false;
state2=false;
state3=false;
state4=false;
state5=false;
state6=true;
state7=false;
state8=false;
}
//if the second clinton bar is clicked in state 2, change to state 7
if (inclintonbar2) {
state0=false;
state1=false;
state2=false;
state3=false;
state4=false;
state5=false;
state6=false;
state7=true;
state8=false;
}
//if the third clinton bar is clicked in state 2, change to state 8
if (inclintonbar3) {
state0=false;
state1=false;
state2=false;
state3=false;
state4=false;
state5=false;
state6=false;
state7=false;
state8=true;
}
}