-
Notifications
You must be signed in to change notification settings - Fork 0
/
Agency.pde
107 lines (97 loc) · 2.97 KB
/
Agency.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
public class Agency {
// public class Agency extends UN {
String unAgencyAbbrev;
String agencyName;
int year;
float expenditure;
ArrayList<Transaction> agencyTransactions; // List of all the agency transactions
ArrayList<Country> agencyCountries; // countries the agency is active in
PVector currLoc, targLoc; // getter/setter?
color agMarkerClr, agTextClr;
float agAlpha;
boolean hover, highlight;
public Agency (int _year, String _unAgencyAbbrev, String _agencyName, float _expenditure) {
year = _year;
unAgencyAbbrev = _unAgencyAbbrev;
agencyName = _agencyName;
expenditure = _expenditure;
currLoc = new PVector();
targLoc = new PVector();
agMarkerClr = color(0);
agTextClr = color(0);
hover = false;
highlight = false;
agAlpha = 255;
}
public Agency() {
}
void resetHoverHighlight() {
hover = false;
highlight = false;
}
void checkHover() {
if ( (abs(mouseX - currLoc.x) < 16) && (mouseY > (currLoc.y - 175)) && (mouseY < height) ) {
// if (currLoc.dist(new PVector(mouseX, mouseY)) < 18) {
hover = true;
univHover = true;
// set related Agency and Country objects to highlight = true;
for (Transaction agTran : agencyTransactions) {
agTran.highlight = true;
agTran.country.highlight = true;
}
} else {
hover = false;
}
}
void setHover() {
hover = true;
univHover = true;
// set related Agency and Country objects to highlight = true;
for (Transaction agTran : agencyTransactions) {
agTran.highlight = true;
agTran.country.highlight = true;
}
}
void updateStyle() {
if (hover) {
textFont(agHoverLabelF);
} else {
textFont(axesLabelF);
}
if (univHover) { // if true, then set this object to either highlighted or faded style
if (hover || highlight) { // true, highlighted style
textFont(agHoverLabelF);
agTextClr = unBlueClr;
agMarkerClr = unBlueClr;
} else { // false, fade style
agAlpha = 76;
agTextClr = color(0, agAlpha);
agMarkerClr = color(0, agAlpha);
}
} else { // false, default style
agTextClr = color(0);
agMarkerClr = color(0);
}
}
void update() {
// update the position
// get the ordinal rank of this agency from the table
// int agencyRank = agencyExpenditureTotalTbl.findRowIndex(unAgencyAbbrev, "Agency");
int agencyRank = agencyExpenditureTotalTbl.findRowIndex(agencyName, "Agency description");
currLoc.x = map(agencyRank, 0, agencyExpenditureTotalTbl.getRowCount()-1, agencyAxis1.x, agencyAxis2.x);
currLoc.y = agencyAxis1.y;
}
void render() {
float textX = currLoc.x;
float textY = currLoc.y+20;
pushMatrix();
translate(textX, textY);
rotate(HALF_PI/2);
fill(agTextClr);
text(unAgencyAbbrev, 0, 0);
popMatrix();
}
void setAgencyTransactionList() {
agencyTransactions = transactionCollectionByAgency(unAgencyAbbrev);
}
}