-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPieChart.pde
118 lines (102 loc) · 4.24 KB
/
PieChart.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
class PieChart extends View
{
float centerX,centerY;
float diameter;
HashMap charLineAnimators;
PieChart(float x_,float y_, float w_,float h_)
{
super(x_,y_,w_,h_);
centerX= w_/2;
centerY= h_/2;
diameter=min(w_,h_);
charLineAnimators = new HashMap();
Iterator it = characters.iterator();
while (it.hasNext()) {
Character character = (Character)it.next();
charLineAnimators.put(character, new Animator());
}
}
void updateCharAnimators()
{
HashMap selectedStats=null;
if (viewTarget == null) {
selectedStats = data.getWholeData();
} else if (seasons[0].getClass().isInstance(viewTarget)) {
Season season = (Season)viewTarget;
selectedStats = data.getSeasonData("S0"+season.number);
}
// for vivek: go through characters and do
//
Set<Character> charactersActive=charLineAnimators.keySet();
Iterator<Character> charactersActiveIterator=charactersActive.iterator();
while(charactersActiveIterator.hasNext())
{
Character thisActiveCharacter=charactersActiveIterator.next();
Animator characterAnimator=(Animator)charLineAnimators.get(thisActiveCharacter);
if(selectedStats.containsKey(thisActiveCharacter.name))
{
float dialogCount=(Integer)selectedStats.get(thisActiveCharacter.name);
characterAnimator.target(dialogCount);
}
else
{
System.out.println(thisActiveCharacter.name);
System.out.println("mismatch");
characterAnimator.target(0);
}
}
}
void drawContent()
{
float prevAngle=0;
color prevColor=#FFFFFF;
Set<Character> characterSet=charLineAnimators.keySet();
Iterator<Character> characterSetIterator=characterSet.iterator();
float total = viewTotalLines.value;
while(characterSetIterator.hasNext())
{
Character selectedCharacter=characterSetIterator.next();
Animator selectedCharacterAnimator=(Animator)charLineAnimators.get(selectedCharacter);
float currentValue=selectedCharacterAnimator.value;
float currentAngle=(currentValue/total)*360;
if(selectedCharacter!=null)
{
fill(selectedCharacter.keyColor);
prevColor=selectedCharacter.keyColor;
if(selectedCharacter.keyColor==0)
{
if(prevColor!=#FFFFFF)
{
fill(#FFFFFF);
prevColor=#FFFFFF;
}
else
{
fill(#000000);
prevColor=#000000;
}
}
// if(selectedCharacter.keyColor!=prevColor)
// {
// fill(selectedCharacter.keyColor);
// }
// else
// {
// if(prevColor!=#FFFFFF)
// {
// prevColor=#FFFFFF;
// fill(#FFFFFF);
// }
// else
// {
// prevColor=#000000;
// fill(#000000);
// }
//
// }
}
arc(centerX,centerY,diameter,diameter,radians(prevAngle),radians(prevAngle)+radians(currentAngle));
prevAngle+=currentAngle;
}
}
}