-
Notifications
You must be signed in to change notification settings - Fork 0
/
SeasonEpsView.pde
139 lines (120 loc) · 3.74 KB
/
SeasonEpsView.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
class SeasonEpsView extends View {
final int maxEps = 26;
final int barGap = 8;
final int labelWidth = 20;
final int labelFontSize = 18;
int barWidth;
Season season;
Button button;
int ngramOccIdx;
String labelLong;
String labelShort;
SeasonEpsView(float x_, float y_, float w_, float h_, Season season_)
{
super(x_, y_, w_, h_);
season = season_;
barWidth = floor((w + barGap - (labelWidth + barGap)) / maxEps) - barGap; // / maxEps or / season.episodes.length ?
labelLong = "Season "+season.number;
labelShort = "S"+season.number;
button = new Button(0,0,labelWidth,h, season, labelFontSize, true, labelLong, false);
subviews.add(button);
}
void setHeight(float h_)
{
h = h_;
button.h = h;
button.myLabel = h < 80 ? labelShort : labelLong;
}
void drawEpBar(int epnum)
{
int epidx = epnum - 1;
pushMatrix();
translate(labelWidth + barGap + epidx * (barWidth + barGap), 0);
noFill();
stroke(0);
rect(0, 0, barWidth, h);
noStroke();
Episode episode = season.episodes[epidx];
if (ngramMode) {
fill(255);
rect(0,0,barWidth,h);
if (activeNgram != null) {
// strokeWeight(2);
while (ngramOccIdx < activeNgram.occurrences.length && (activeNgram.occurrences[ngramOccIdx].precedes(episode))) ngramOccIdx++;
while (ngramOccIdx < activeNgram.occurrences.length && (activeNgram.occurrences[ngramOccIdx].within(episode))) {
int lineno = activeNgram.occurrences[ngramOccIdx].lineno;
DialogLine dialog = episode.dialogs[lineno];
float liney = (float)lineno / episode.dialogs.length * h;
float piecew = (float)barWidth / dialog.who.length;
/* at this scale we can really only draw one character's lines, since they tend to overlap */
for (int i = 0; i < dialog.who.length; i++) {
Character c = dialog.who[i];
if (c.active) {
stroke(c.keyColor);
line(/*piecew*i*/0, liney, /*piecew*(i+1)*/barWidth, liney);
break;
}
}
ngramOccIdx++;
}
// strokeWeight(1);
}
} else {
Iterator i = episode.charLineCount.entrySet().iterator();
float total = episode.activeTotal.value;
float slicey = 0, sliceh;
float a = 255.0;
if (episode.activeTotal.target == 0.0) { /* none of the selected characters appear in this episode */
a = map(episode.activeTotal.value, episode.activeTotal.oldtarget, episode.activeTotal.target, 255.0, 0.0);
fill(224);
rect(0,0,barWidth,h);
}
pushClip();
clipRect(0,0,barWidth,h);
while (i.hasNext()) {
Map.Entry entry = (Map.Entry)i.next();
Character character = (Character)entry.getKey();
int count = (Integer)entry.getValue();
if (character.activeAnimator.value > 0) {
sliceh = (float)count/total*h*character.activeAnimator.value;
fill(character.keyColor, a);
rect(0,slicey,barWidth,sliceh);
slicey += sliceh;
}
}
popClip();
}
popMatrix();
}
void drawLabel()
{
fill(shipLight);
rect(0,0,labelWidth,h);
fill(shipRedDark);
textSize(18);
textAlign(LEFT, TOP);
pushMatrix();
translate(0,h);
rotate(3*HALF_PI);
text("Season " + season.number, 0, 0);
popMatrix();
}
void drawContent()
{
fill(shipDark);
rect(0,0,w,h);
// drawLabel();
ngramOccIdx = 0;
for (int n = 1; n <= season.episodes.length; n++) {
drawEpBar(n);
}
}
boolean contentPressed(float lx, float ly)
{
return true;
}
boolean contentDragged(float lx, float ly)
{
return true;
}
}