-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshadeProvince.pde
120 lines (117 loc) · 4.91 KB
/
shadeProvince.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
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
void chinaMapUpdate () {
if (bt.text == text_1) {
// Load GDP data
dataEntriesMap = loadGDPFromCSV("perGDPdata.csv");
shadeProvinces_1();
} else if (bt.text == text_2) {
// Load GDP data
dataEntriesMap = loadGDPFromCSV("regionGDPdata.csv");
shadeProvinces_2();
}
}
void shadeProvinces_1() {
for (Marker marker : chinaMarkers) {
// Find data for province of the current marker
String provinceId = marker.getId();
DataEntry dataEntry = dataEntriesMap.get(provinceId);
if(hs.spos == hs.xpos) {
if (dataEntry != null && dataEntry.value_2000 != null) {
// Encode value as brightness (values range: 27643-118198)
float transparency = map(dataEntry.value_2000, 0, 120000, 0, 240);
marker.setColor(color(255, 255-transparency, 255-transparency));
} else {
// No value available
marker.setColor(color(100, 120));
}
} else if (hs.spos == hs.xpos+hs.swidth/5) {
if (dataEntry != null && dataEntry.value_2004 != null) {
// Encode value as brightness (values range: 27643-118198)
float transparency = map(dataEntry.value_2004, 0, 120000, 0, 240);
marker.setColor(color(255, 255-transparency, 255-transparency));
} else {
// No value available
marker.setColor(color(100, 120));
}
} else if (hs.spos == hs.xpos+hs.swidth*2/5) {
if (dataEntry != null && dataEntry.value_2008 != null) {
// Encode value as brightness (values range: 27643-118198)
float transparency = map(dataEntry.value_2008, 0, 120000, 0, 240);
marker.setColor(color(255, 255-transparency, 255-transparency));
} else {
// No value available
marker.setColor(color(100, 120));
}
} else if (hs.spos == hs.xpos+hs.swidth*3/5) {
if (dataEntry != null && dataEntry.value_2012 != null) {
// Encode value as brightness (values range: 27643-118198)
float transparency = map(dataEntry.value_2012, 0, 120000, 0, 240);
marker.setColor(color(255, 255-transparency, 255-transparency));
} else {
// No value available
marker.setColor(color(100, 120));
}
} else {
if (dataEntry != null && dataEntry.value_2016 != null) {
// Encode value as brightness (values range: 27643-118198)
float transparency = map(dataEntry.value_2016, 0, 120000, 0, 240);
marker.setColor(color(255, 255-transparency, 255-transparency));
} else {
// No value available
marker.setColor(color(100, 120));
}
}
}
}
void shadeProvinces_2() {
for (Marker marker : chinaMarkers) {
// Find data for province of the current marker
String provinceId = marker.getId();
DataEntry dataEntry = dataEntriesMap.get(provinceId);
if(hs.spos == hs.xpos) {
if (dataEntry != null && dataEntry.value_2000 != null) {
// Encode value as brightness (values range: 100-81000)
float transparency = map(dataEntry.value_2000, 0, 81000, 0, 240);
marker.setColor(color(255, 255-transparency, 255-transparency));
} else {
// No value available
marker.setColor(color(100, 120));
}
} else if (hs.spos == hs.xpos+hs.swidth/5) {
if (dataEntry != null && dataEntry.value_2004 != null) {
// Encode value as brightness (values range: 100-81000)
float transparency = map(dataEntry.value_2004, 0, 81000, 0, 240);
marker.setColor(color(255, 255-transparency, 255-transparency));
} else {
// No value available
marker.setColor(color(100, 120));
}
} else if (hs.spos == hs.xpos+hs.swidth*2/5) {
if (dataEntry != null && dataEntry.value_2008 != null) {
// Encode value as brightness (values range: 100-81000)
float transparency = map(dataEntry.value_2008, 0, 81000, 0, 240);
marker.setColor(color(255, 255-transparency, 255-transparency));
} else {
// No value available
marker.setColor(color(100, 120));
}
} else if (hs.spos == hs.xpos+hs.swidth*3/5) {
if (dataEntry != null && dataEntry.value_2012 != null) {
// Encode value as brightness (values range: 100-81000)
float transparency = map(dataEntry.value_2012, 0, 81000, 0, 240);
marker.setColor(color(255, 255-transparency, 255-transparency));
} else {
// No value available
marker.setColor(color(100, 120));
}
} else {
if (dataEntry != null && dataEntry.value_2016 != null) {
// Encode value as brightness (values range: 100-81000)
float transparency = map(dataEntry.value_2016, 0, 81000, 0, 240);
marker.setColor(color(255, 255-transparency, 255-transparency));
} else {
// No value available
marker.setColor(color(100, 120));
}
}
}
}