-
Notifications
You must be signed in to change notification settings - Fork 0
/
connector.pde
91 lines (72 loc) · 2.34 KB
/
connector.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
/**
* Logic to draw connections from fields of study in one year to another.
*
* @license MIT, A Samuel Pottinger
*/
/**
* Draw all connectors from one field of study in one year to another.
*
* @param vertPositions The vertical y axis position in pixels for each area of study.
*/
void drawYearsConnectors(Map<Area, Integer> vertPositions) {
pushMatrix();
pushStyle();
translate(0, 100);
for (int year = START_YEAR; year < END_YEAR; year += 5) {
drawYearConnectors(year, vertPositions);
}
popStyle();
popMatrix();
}
/**
* Draw connections from one year to the next.
*
* @param year The year from which connections should be drawn to the next year availble.
* @param vertPositions The vertical y axis position in pixels for each area of study.
*/
void drawYearConnectors(int year, Map<Area, Integer> vertPositions) {
pushMatrix();
pushStyle();
int column = year - START_YEAR;
int midX = 100 + 50 * column + 100;
translate(midX, 0);
for (String school : SCHOOLS) {
drawYearSchoolConnectors(year, school, vertPositions);
}
popStyle();
popMatrix();
}
/**
* Draw the connections for areas of study in a single school / college for a single year.
*
* @param year The year from which connections should be drawn to the next year available.
* @param vertPositions The vertical y axis position in pixels for each area of study.
*/
void drawYearSchoolConnectors(int year, String school, Map<Area, Integer> vertPositions) {
pushMatrix();
pushStyle();
// Prep
noFill();
List<Area> areas = dataset.getForYearSchool(year, school);
// Draw
for (Area area : areas) {
color schoolColor = SCHOOL_LINE_COLORS.get(area.getSchool());
stroke(schoolColor);
strokeWeight(3);
int yStart = vertPositions.get(area) + SCHOOL_STARTS.get(school) + 30;
for (Key nextKey : area.getNextKeys()) {
Area nextArea = dataset.getByKey(nextKey);
if (nextArea == null) {
throw new RuntimeException("Could not find " + nextKey); //<>//
}
if (!vertPositions.containsKey(nextArea)) {
throw new RuntimeException("Could not connect to " + nextKey);
}
String endSchool = nextKey.getSchool();
int yEnd = vertPositions.get(nextArea) + SCHOOL_STARTS.get(endSchool) + 30;
bezier(0, yStart, 50, yStart, 250-50, yEnd, 250, yEnd);
}
}
popStyle();
popMatrix();
}