-
Notifications
You must be signed in to change notification settings - Fork 39
/
LayerLayout.java
33 lines (29 loc) · 1002 Bytes
/
LayerLayout.java
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
/**
* LayerLayout
* Abstract Class for new stacked graph layout algorithms
*
* Note: you do not need to worry about scaling to screen dimensions.
* The display applet will do that automatically for you.
*
* @author Lee Byron
* @author Martin Wattenberg
*/
public abstract class LayerLayout {
abstract void layout(Layer[] layers);
abstract String getName();
/**
* We define our stacked graphs by layers atop a baseline.
* This method does the work of assigning the positions of each layer in an
* ordered array of layers based on an initial baseline.
*/
protected void stackOnBaseline(Layer[] layers, float[] baseline) {
// Put layers on top of the baseline.
for (int i = 0; i < layers.length; i++) {
System.arraycopy(baseline, 0, layers[i].yBottom, 0, baseline.length);
for (int j = 0; j < baseline.length; j++) {
baseline[j] -= layers[i].size[j];
}
System.arraycopy(baseline, 0, layers[i].yTop, 0, baseline.length);
}
}
}