Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java @ 3630:28be160b5870
Add a module service. It's now possible to configure the modules which are
available for a client. With the selected attribute it is possible to give
a hint for the client which module should be pre selected by default
flys-artifacts/trunk@5330 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 31 Aug 2012 13:17:16 +0000 |
parents | 73b15736cb80 |
children | cbe2febe30cc |
rev | line source |
---|---|
2327
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.jfree; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import org.jfree.chart.axis.ValueAxis; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.jfree.data.Range; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 /** |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 */ |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 public class DoubleBounds implements Bounds { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 protected double lower; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 protected double upper; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
2397
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
17 /** |
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
18 * Default constructor. <b>A DoubleBounds has always set lower < |
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
19 * upper!</b> |
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
20 */ |
2327
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 public DoubleBounds(double lower, double upper) { |
2397
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
22 this.lower = Math.min(lower, upper); |
c38063bf99da
Small improvements in model classes for Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2393
diff
changeset
|
23 this.upper = Math.max(lower, upper); |
2327
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 @Override |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 public Number getLower() { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 return Double.valueOf(lower); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 @Override |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 public Number getUpper() { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 return Double.valueOf(upper); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 @Override |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 public void applyBounds(ValueAxis axis) { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 axis.setRange(new Range(lower, upper)); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 @Override |
2399
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
46 public void applyBounds(ValueAxis axis, int percent) { |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
47 double space = (upper - lower) / 100 * percent; |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
48 axis.setRange(new Range(lower-space, upper+space)); |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
49 } |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
50 |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
51 |
73b15736cb80
Improved the interface and implementations of Bounds.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2397
diff
changeset
|
52 @Override |
2327
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 public Bounds combine(Bounds bounds) { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 if (bounds == null) { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 return this; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 DoubleBounds other = (DoubleBounds) bounds; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 double otherLower = other.getLower().doubleValue(); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 double otherUpper = other.getUpper().doubleValue(); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 return new DoubleBounds( |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 otherLower < lower ? otherLower : lower, |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 otherUpper > upper ? otherUpper : upper); |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 @Override |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 public String toString() { |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 return "DoubleBounds=[" + lower + " ; " + upper + "]"; |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 } |
07c39470e2cb
Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |