-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNation.pde
More file actions
196 lines (166 loc) · 5.77 KB
/
Nation.pde
File metadata and controls
196 lines (166 loc) · 5.77 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
// Maxwell Sherman & Vincent Lombardi
// Final Project: Censored Games
// CPSC 313-01 Data Visualization
// 2020-05-04
public class Nation {
private String countryName;
private ArrayList<Game> games;
public Nation(String countryName) {
this.countryName = countryName;
games = new ArrayList<Game>();
}
public String getCountry() {
return this.countryName;
}
public void addGame(Game game) {
games.add(game);
}
public float getGameCount(){
return games.size();
}
public String sortGameByGenre(String target) {
String output = "";
for (Game g : games) {
if (g.getGenre().equals(target)) {
if (output.equals("")) {
output += g.getTitle();
} else {
output += "," + g.getTitle();
}
}
}
return output;
}
}
// older code that we are not using but I saved in case we wanted a jumping off point for additional features.
/*
void drawGenre() {
float barWidth = map(1, 0, genres.size(), 0, width - (padding * 2));
float position = padding; // current postion
float barHeight = map(1, 0, maxGenre, 0, height - (padding * 10));
float gameCount;
for (String genre : genres) {
gameCount = 0;
for (Game g : games) {
if (g.isGenre(genre)) {
gameCount++;
}
}
fill(52, 158, 206);
float temp = gameCount * barHeight;
rect(position, height - temp - padding, barWidth, temp); // draw upper bar
position += barWidth;
}
drawLines(barHeight, int(maxGenre) + 1);
}
void drawLines(float barHeight, int maxVal) {
stroke(0);
for (int i = 0; i < maxVal; i++) {
line(padding, height - (barHeight * i) - padding, width - padding, height - (barHeight * i) - padding);
}
}
void drawNations() {
float barWidth = map(1, 0, nations.size(), 0, width - (padding * 2));
float position = padding; // current postion
float barHeight = map(1, 0, maxN, 0, height - (padding * 10));
for (Nation n : nations) {
fill(222, 36, 36);
float temp = n.getGameCount() * barHeight;
rect(position, height - temp - padding, barWidth, temp); // draw upper bar
position += barWidth;
}
drawLines(barHeight, int(maxN) + 1);
}
void drawGames() {
float barWidth = map(1, 0, games.size(), 0, width - (padding * 2));
float position = padding; // current postion
float barHeight = map(1, 0, maxG, 0, height - (padding * 10));
for (Game g : games) {
fill(52, 158, 206);
float temp = g.getBannedCount() * barHeight;
rect(position, height - temp - padding, barWidth, temp); // draw upper bar
position += barWidth;
}
drawLines(barHeight, int(maxG) + 1);
}
*/
/*
void setup() {
// Processing basic setup
size(1024, 768); // creates output window size
textSize(16);
textAlign(CENTER);
selected = 2;
maxG = 0;
maxN = 0;
Table data = loadTable("Games.csv", "header");
places = new ArrayList<String>();
ArrayList<String> names = new ArrayList<String>();
myX = 0;
myY = 0;
geoMap = new GeoMap(0, 0, width, height/2, this);
geoMap.readFile("world"); // Reads shapefile.
games = new ArrayList<Game>();
nations = new ArrayList<Nation>();
genres = new ArrayList<String>();
categories = new ArrayList<String>();
statusTypes = new ArrayList<String>();
mapNations = new ArrayList<String>();
for (TableRow r : data.rows()) {
for (String s : r.getString("Genre").split("\\|") ) {
if (!genres.contains(s)) { // adds genre to the list
genres.add(s);
}
}
if (!categories.contains(r.getString("Ban Category"))) { // adds category to list
categories.add(r.getString("Ban Category"));
}
if (!statusTypes.contains(r.getString("Ban Status"))) { // adds status type to list
statusTypes.add(r.getString("Ban Status"));
}
if (!places.contains(r.getString("Country"))) { // adds country name to list
places.add(r.getString("Country"));
nations.add(new Nation(r.getString("Country")));
}
if (!names.contains(r.getString("Game"))) { // creates game
names.add(r.getString("Game"));
Game g = new Game(r.getString("Game"), r.getString("Series"), r.getString("Country"), r.getString("Ban Category"), r.getString("Ban Status"), r.getString("Developer"), r.getString("Publisher"), r.getString("Genre"));
int x = places.indexOf(r.getString("Country"));
nations.get(x).addGame(g);
games.add(g);
} else { // adds info to game object
int i = names.indexOf(r.getString("Game"));
games.get(i).addInstance(r.getString("Country"), r.getString("Ban Category"), r.getString("Ban Status"));
int x = places.indexOf(r.getString("Country"));
nations.get(x).addGame(games.get(i));
}
}
for (int id : geoMap.getFeatures().keySet()) {
mapNations.add(geoMap.getAttributeTable().findRow(str(id), 0).getString("NAME"));
}
for (Game g : games) {
if (maxG < g.getBannedCount()) {
maxG = g.getBannedCount();
}
}
for (Nation n : nations) {
if (maxN < n.getGameCount()) {
maxN = n.getGameCount();
}
}
float gameCount;
maxGenre = 0;
;
for (String genre : genres) {
gameCount = 0;
for (Game g : games) {
if (g.isGenre(genre)) {
gameCount++;
}
}
if (maxGenre < gameCount) {
maxGenre = gameCount;
}
}
}
*/