Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/TimeBounds.java @ 2327:07c39470e2cb
Added new model classes that should be used for axes range adaption later.
flys-artifacts/trunk@4011 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 09 Feb 2012 18:38:03 +0000 |
parents | |
children | 594885703687 d0e7afb3696b |
comparison
equal
deleted
inserted
replaced
2326:c321b39b39ab | 2327:07c39470e2cb |
---|---|
1 package de.intevation.flys.jfree; | |
2 | |
3 import java.util.Date; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import org.jfree.chart.axis.DateAxis; | |
8 import org.jfree.chart.axis.ValueAxis; | |
9 | |
10 | |
11 /** | |
12 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
13 */ | |
14 public class TimeBounds implements Bounds { | |
15 | |
16 protected long lower; | |
17 protected long upper; | |
18 | |
19 | |
20 public TimeBounds(long lower, long upper) { | |
21 this.lower = lower; | |
22 this.upper = upper; | |
23 } | |
24 | |
25 | |
26 @Override | |
27 public Number getLower() { | |
28 return Long.valueOf(lower); | |
29 } | |
30 | |
31 | |
32 @Override | |
33 public Number getUpper() { | |
34 return Long.valueOf(upper); | |
35 } | |
36 | |
37 | |
38 @Override | |
39 public void applyBounds(ValueAxis axis) { | |
40 DateAxis dateAxis = (DateAxis) axis; | |
41 | |
42 dateAxis.setMinimumDate(new Date(lower)); | |
43 dateAxis.setMaximumDate(new Date(upper)); | |
44 } | |
45 | |
46 | |
47 @Override | |
48 public Bounds combine(Bounds bounds) { | |
49 if (bounds == null) { | |
50 return this; | |
51 } | |
52 | |
53 TimeBounds other = (TimeBounds) bounds; | |
54 | |
55 long otherLower = other.getLower().longValue(); | |
56 long otherUpper = other.getUpper().longValue(); | |
57 | |
58 return new TimeBounds( | |
59 otherLower < lower ? otherLower : lower, | |
60 otherUpper > upper ? otherUpper : upper); | |
61 } | |
62 | |
63 | |
64 @Override | |
65 public String toString() { | |
66 return "TimeBounds=[" + lower + " ; " + upper + "]"; | |
67 } | |
68 } | |
69 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |