annotate flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.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
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 import org.apache.log4j.Logger;
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
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.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
6 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
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 /**
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 * @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
11 */
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 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
13
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 lower;
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 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
16
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 public DoubleBounds(double lower, 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
19 this.lower = lower;
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 this.upper = upper;
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 }
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 @Override
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 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
26 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
27 }
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 @Override
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 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
32 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
33 }
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 @Override
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 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
38 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
39 }
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 @Override
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 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
44 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
45 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
46 }
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 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
49
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 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
51 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
52
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 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
54 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
55 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
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
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 @Override
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 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
61 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
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 }
07c39470e2cb Added new model classes that should be used for axes range adaption later.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org