blob: c5280237bebeb1916396fee5b3b80613b9cee277 (
plain)
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
|
package org.singinst.uf.model;
import java.util.ArrayList;
import java.util.List;
import org.singinst.uf.math.InvertableFunction;
import org.singinst.uf.presenter.AxisSample;
import org.singinst.uf.presenter.CanvasString;
import org.singinst.uf.presenter.LineBounds;
import org.singinst.uf.presenter.NumericEntry;
public class IncidentBounds extends LineBounds {
private static final InvertableFunction toDisplay = new IncidentFunction();
private static final double LOWER_DISPLAY = 0.001;
private static final double UPPER_DISPLAY = 99;
public IncidentBounds() {
super(fromDisplay(LOWER_DISPLAY), fromDisplay(UPPER_DISPLAY));
}
@Override
public Iterable<AxisSample> getAxisSamples(boolean majorTick) {
return samples(0.001, 0.01, 0.1, 1, 10, 50, 99);
}
private Iterable<AxisSample> samples(double... displays) {
List<AxisSample> samples = new ArrayList<AxisSample>();
for (double display : displays) {
samples.add(new AxisSample(fromDisplay(display),
new CanvasString("" + NumericEntry.formatAsScalar(display))));
}
return samples;
}
@Override
public InvertableFunction toDisplay() {
return toDisplay;
}
@Override
public String userFormat(double value) {
return "" + NumericEntry.formatAsScalar(toDisplay.apply(value));
}
private static double fromDisplay(double display) {
return toDisplay.invert(display);
}
}
|