Normand Briere
2018-07-07 e416acb9b012b17d1efe49ad2199ea7132d874d1
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
package timeflow.vis;
 
import timeflow.data.time.*;
 
import java.util.*;
 
public class TimeScale
{
        private double low, high;
        private Interval interval;
 
        public TimeScale()
        {
                low = 0;
                high = 100;
                interval = new Interval(new Date(0).getTime(), new Date().getTime());
        }
 
        public Interval getInterval()
        {
                return interval;
        }
 
        public void setNumberRange(double low, double high)
        {
                this.low = low;
                this.high = high;
        }
 
        public void setDateRange(Interval t)
        {
                setDateRange(t.start, t.end);
        }
 
        public void setDateRange(long first, long last)
        {
                interval.setTo(first, last);
        }
 
        public boolean containsDate(long date)
        {
                return interval.contains(date);
        }
 
        public boolean containsNum(double x)
        {
                return x >= low && x <= high;
        }
 
        public long duration()
        {
                return interval.length();
        }
 
        public double toNum(long time)
        {
                return low + (high - low) * (time - interval.start) / (double) duration();
        }
 
        public long spaceToTime(double space)
        {
                return (long) (space * duration() / (high - low));
        }
 
        public int toInt(long time)
        {
                return (int) toNum(time);
        }
 
        public long toTime(double num)
        {
                double millis = interval.start + duration() * (num - low) / (high - low);
                return (long) millis;
        }
 
        public double getLow()
        {
                return low;
        }
 
        public void setLow(double low)
        {
                this.low = low;
        }
 
        public double getHigh()
        {
                return high;
        }
 
        public void setHigh(double high)
        {
                this.high = high;
        }
}