annotate flys-artifacts/src/main/java/de/intevation/flys/exports/ChartArea.java @ 3246:229e9b27ce15

New Distance helper module. flys-artifacts/trunk@4879 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 06 Jul 2012 09:34:51 +0000
parents 1dca41dba135
children 2aca387333d6
rev   line source
3242
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.exports;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
2
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
3 import java.awt.BasicStroke;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
4 import java.awt.Color;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
5 import java.awt.Font;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
6 import java.awt.Paint;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
7 import java.awt.Stroke;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
8
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
9 import java.text.NumberFormat;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
10
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
11 import java.util.ArrayList;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
12 import java.util.HashMap;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
13 import java.util.List;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
14 import java.util.Map;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
15
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
16 import org.w3c.dom.Document;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
17
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
18 import org.apache.log4j.Logger;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
19
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
20 import org.jfree.chart.ChartFactory;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
21 import org.jfree.chart.JFreeChart;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
22 import org.jfree.chart.LegendItem;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
23 import org.jfree.chart.LegendItemCollection;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
24 import org.jfree.chart.annotations.XYBoxAnnotation;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
25 import org.jfree.chart.annotations.XYLineAnnotation;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
26 import org.jfree.chart.annotations.XYTextAnnotation;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
27 import org.jfree.chart.axis.NumberAxis;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
28 import org.jfree.chart.axis.ValueAxis;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
29 import org.jfree.chart.plot.Marker;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
30 import org.jfree.chart.plot.PlotOrientation;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
31 import org.jfree.chart.plot.XYPlot;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
32 import org.jfree.data.Range;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
33 import org.jfree.data.general.Series;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
34 import org.jfree.data.xy.XYSeries;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
35 import org.jfree.data.xy.XYSeriesCollection;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
36 import org.jfree.data.xy.XYDataset;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
37
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
38 import org.jfree.ui.TextAnchor;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
39
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
40 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
41 import de.intevation.artifactdatabase.state.Facet;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
42
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
43 import de.intevation.flys.jfree.Bounds;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
44 import de.intevation.flys.jfree.DoubleBounds;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
45 import de.intevation.flys.jfree.FLYSAnnotation;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
46 import de.intevation.flys.jfree.StickyAxisAnnotation;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
47 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
48 import de.intevation.flys.jfree.StyledAreaSeriesCollection;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
49 import de.intevation.flys.jfree.StyledXYSeries;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
50
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
51 import de.intevation.flys.themes.ThemeAccess;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
52 import de.intevation.flys.utils.ThemeUtil;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
53
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
54 import de.intevation.flys.artifacts.model.HYKFactory;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
55
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
56 import org.json.JSONArray;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
57 import org.json.JSONException;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
58
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
59 /** Two Ranges that span a rectangular area. */
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
60 public class ChartArea {
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
61 protected Range xRange;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
62 protected Range yRange;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
63
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
64 public ChartArea(Range rangeX, Range rangeY) {
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
65 this.xRange = rangeX;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
66 this.yRange = rangeY;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
67 }
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
68
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
69 public ChartArea(ValueAxis axisX, ValueAxis axisY) {
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
70 this.xRange = axisX.getRange();
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
71 this.yRange = axisY.getRange();
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
72 }
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
73
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
74 public double ofLeft(double percent) {
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
75 return xRange.getLowerBound()
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
76 + xRange.getLength() * percent;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
77 }
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
78
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
79 public double ofRight(double percent) {
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
80 return xRange.getUpperBound()
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
81 - xRange.getLength() * percent;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
82 }
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
83
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
84 public double ofGround(double percent) {
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
85 return yRange.getLowerBound()
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
86 + yRange.getLength() * percent;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
87 }
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
88
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
89 public double atTop() {
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
90 return yRange.getUpperBound();
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
91 }
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
92
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
93 public double atGround() {
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
94 return yRange.getLowerBound();
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
95 }
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
96
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
97 public double atRight() {
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
98 return xRange.getUpperBound();
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
99 }
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
100
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
101 public double atLeft() {
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
102 return xRange.getLowerBound();
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
103 }
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
104
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
105 public double above(double percent, double base) {
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
106 return base + yRange.getLength() * percent;
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
107 }
1dca41dba135 Move annotation code to base class ChartGenerator
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
108 }

http://dive4elements.wald.intevation.org