forked from leebyron/streamgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThemeRiverLayout.java
More file actions
33 lines (29 loc) · 784 Bytes
/
Copy pathThemeRiverLayout.java
File metadata and controls
33 lines (29 loc) · 784 Bytes
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
/**
* ThemeRiverLayout
* Layout used by the authors of the ThemeRiver paper
*
* @author Lee Byron
* @author Martin Wattenberg
*/
public class ThemeRiverLayout extends LayerLayout {
public String getName() {
return "ThemeRiver";
}
public void layout(Layer[] layers) {
// Set shape of baseline values.
int n=layers[0].size.length;
int m=layers.length;
float[] baseline = new float[n];
// ThemeRiver is perfectly symmetrical
// the baseline is 1/2 of the total height at any point
for (int i = 0; i < n; i++) {
baseline[i] = 0;
for (int j = 0; j < m; j++) {
baseline[i] += layers[j].size[i];
}
baseline[i] *= 0.5;
}
// Put layers on top of the baseline.
stackOnBaseline(layers, baseline);
}
}