annotate gnv-artifacts/src/main/java/de/intevation/gnv/chart/AbstractXYLineChart.java @ 774:d0a39efbfd96

Removed race-condition when trying to access the index of the next line color used in charts (applied patch in issue211). gnv-artifacts/trunk@834 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 26 Mar 2010 10:06:36 +0000
parents 79401c871da4
children 9a828e5a2390
rev   line source
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.chart;
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.awt.Color;
327
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
4 import java.awt.geom.Ellipse2D;
315
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
5 import java.text.NumberFormat;
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import java.util.Collection;
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import java.util.Iterator;
315
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
8 import java.util.Locale;
334
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
9 import java.util.Map;
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import org.apache.log4j.Logger;
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import org.jfree.chart.JFreeChart;
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.jfree.chart.ChartFactory;
315
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
15 import org.jfree.chart.axis.Axis;
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import org.jfree.chart.axis.NumberAxis;
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import org.jfree.chart.axis.NumberTickUnit;
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import org.jfree.chart.axis.AxisLocation;
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import org.jfree.chart.plot.PlotOrientation;
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import org.jfree.chart.plot.XYPlot;
327
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
21 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
331
1c427acb6c76 Added subtitles to charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 327
diff changeset
22 import org.jfree.chart.title.TextTitle;
364
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
23 import org.jfree.data.xy.XYDataset;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
24 import org.jfree.data.Range;
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import org.jfree.data.general.Series;
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 import de.intevation.gnv.geobackend.base.Result;
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents: 334
diff changeset
28 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
333
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
30
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 /**
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
32 * This abstract class defines some methods to adjust chart settings after its
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
33 * creation.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
34 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
35 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 */
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 public abstract class AbstractXYLineChart
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 extends AbstractChart
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 {
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
40 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
41 * Constant field used to expand the area between data and chart border. Its
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
42 * value is {@value}.<br>
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
43 * A value of 0.05 equals 5 percent.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
44 */
364
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
45 public static final double LOWER_MARGIN = 0.05D;
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
46
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
47 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
48 * Constant field used to expand the area between data and chart border. Its
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
49 * value is {@value}.<br>
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
50 * A value of 0.05 equals 5 percent.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
51 */
364
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
52 public static final double UPPER_MARGIN = 0.05D;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
53
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
54 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
55 * Logger used to log with log4j.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
56 */
327
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
57 private static Logger log = Logger.getLogger(AbstractXYLineChart.class);
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
59 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
60 * Field of supported colors used for lines and data points in charts.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
61 * Colors are: {@value}.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
62 */
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 protected static Color[] COLOR = {
334
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
64 Color.black, Color.red, Color.green, Color.blue, Color.yellow,
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
65 Color.gray, Color.orange, Color.pink, Color.cyan
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 };
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
68 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
69 * Static field to remember the index of the previously used color.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
70 */
334
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
71 protected static int nextColor = 0;
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
72
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
73 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
74 * Default <code>PlotOrientation</code>. Its value is {@value}.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
75 */
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 protected PlotOrientation PLOT_ORIENTATION = PlotOrientation.VERTICAL;
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
78 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
79 * Map to store datasets for each parameter.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
80 */
334
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
81 protected Map datasets;
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
82
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
83 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
84 * Map to store max ranges of each parameter (axis.setAutoRange(true)
364
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
85 * doesn't seem to work */
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
86 protected Map ranges;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
87
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
88 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
89 * This method is called by <code>Chart</code> to bring the data into the
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
90 * right form fitting to JFreeChart objects.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
91 */
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 protected abstract void initData();
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
93
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
94 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
95 * Add a value of <code>row</code> to <code>series</code>.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
96 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
97 * @param row <code>Result</code> Object returned from database. Contains
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
98 * a value used to add to <code>series</code>
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
99 * @param series A JFreeChart Series object.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
100 */
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 protected abstract void addValue(Result row, Series series);
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
102
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
103 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
104 * Add <code>series</code> to JFreeChart's Dataset object currently which is
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
105 * processing.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
106 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
107 * @param series Series to add.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
108 * @param label Label used show in legend.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
109 * @param idx Currently not used.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
110 */
334
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
111 protected abstract void addSeries(Series series, String label, int idx);
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
112
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
113 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
114 * Abstract method which is called by <code>Chart</code> interface after
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
115 * chart creation. It turns an axis' label into a locale specific format.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
116 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
117 * @param axis Axis to adjust.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
118 * @param local java.util.Locale object used specify the format.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
119 */
315
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
120 protected abstract void localizeDomainAxis(Axis axis, Locale locale);
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
121
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
122 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
123 * Abstract method to create a label for a series of parameters.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
124 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
125 * @param breakPoint1 Identifier returned from database. These identifier
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
126 * are used to identify the results from database which are all stored in
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
127 * one big java.util.Collection.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
128 * @param breakPoint2 Identifier returned from database.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
129 * @param breakPoint3 Identifier returned from database.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
130 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
131 * @return Concatinated string of parameter name and measurement.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
132 */
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 protected abstract String createSeriesName(
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 String breakPoint1,
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 String breakPoint2,
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 String breakPoint3
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 );
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
140 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
141 * @see de.intevation.gnv.chart.Chart#generateChart()
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
142 */
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 public JFreeChart generateChart() {
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 log.debug("generate XYLineChart");
351
4ac3c1c1c060 Stabilized color of lines in charts. Exports (pdf, svg, png) will look like the chart in gui.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 344
diff changeset
145 nextColor = 0;
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 if (chart != null)
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 return chart;
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149
333
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
150 initChart();
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
151
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
152 chart.addSubtitle(new TextTitle(labels.getSubtitle()));
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
153
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
154 theme.apply(chart);
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
155 initData();
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
156
344
44adf8918155 Fade out range axis gridlines in charts if there are more than one axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 335
diff changeset
157 adjustPlot((XYPlot)chart.getPlot());
44adf8918155 Fade out range axis gridlines in charts if there are more than one axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 335
diff changeset
158
333
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
159 return chart;
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
160 }
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
161
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
162
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
163 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
164 * @see de.intevation.gnv.chart.AbstractChart#initChart()
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
165 */
333
19571fd1d0e8 Sourced ChartFactory call out to an own method, which is overriden by TimeSeriesChart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 331
diff changeset
166 protected void initChart() {
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 chart = ChartFactory.createXYLineChart(
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 labels.getTitle(),
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 labels.getDomainAxisLabel(),
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 null,
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171 null,
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 PLOT_ORIENTATION,
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 true,
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 false,
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 false
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 );
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 }
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
180 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
181 * Method used to adjust the axes after chart generation. Methods for i18n
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
182 * support ({@link #localizeDomainAxis and {@link #localizeRangeAxis) are
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
183 * called and axes of this series are expanded ({@link org.jfree.data.Range#expand(
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
184 * Range, double, double}).
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
185 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
186 * @param seriesKey Identifier of an axis which have to be adjusted.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
187 * @param idx Set the axis identified by <code>seriesKey</code> to position
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
188 * <code>idx</code>.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
189 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
190 * @see org.jfree.data.Range#expand(Range, double, double)
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
191 */
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 protected void prepareAxis(String seriesKey, int idx) {
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 log.debug("prepare axis of xychart");
315
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
194
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
195 XYPlot plot = chart.getXYPlot();
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
196 Axis xAxis = plot.getDomainAxis();
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
197 NumberAxis yAxis = new NumberAxis(seriesKey);
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
198
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
199 localizeDomainAxis(xAxis, locale);
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
200 localizeRangeAxis(yAxis, locale);
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201
364
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
202 // litte workarround to adjust the max range of axes.
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
203 // NumberAxis.setAutoRange(true) doesn't seem to work properly.
656
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 506
diff changeset
204 Range yRange = (Range) ranges.get(seriesKey);
364
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
205 yAxis.setRange(Range.expand(yRange, LOWER_MARGIN, UPPER_MARGIN));
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
206 log.debug("Max Range of dataset is: " + yRange.toString());
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
207
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 if (seriesKey.contains("richtung")) {
315
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
209 yAxis.setTickUnit(new NumberTickUnit(30.0));
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
210 yAxis.setUpperBound(360.0);
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
211 yAxis.setLowerBound(0.0);
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 }
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 else {
315
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
214 yAxis.setFixedDimension(10.0);
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
215 yAxis.setAutoRangeIncludesZero(false);
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 }
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217
364
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
218 plot.setRangeAxis(idx, yAxis);
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
219 yAxis.configure();
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
220
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 if (idx % 2 != 0)
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 plot.setRangeAxisLocation(idx, AxisLocation.BOTTOM_OR_RIGHT);
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223 else
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 plot.setRangeAxisLocation(idx, AxisLocation.BOTTOM_OR_LEFT);
506
d41c155db337 Solved issue100. Improved axes range. Scale dataset to its own axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 364
diff changeset
225
d41c155db337 Solved issue100. Improved axes range. Scale dataset to its own axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 364
diff changeset
226 plot.mapDatasetToRangeAxis(idx, idx);
327
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
227 }
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228
327
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
229
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
230 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
231 * Method to adjust the rendering of a series in a chart. Line color and
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
232 * symbols of vertices are configured here.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
233 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
234 * @param idx Position of the renderer.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
235 * @param seriesCount Maximum number of series in this chart.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
236 * @param renderLines Lines are displayed if true, otherwise they are not.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
237 * @param renderShapes Vertices are displayed if true, otherwise they are
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
238 * not.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
239 */
327
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
240 protected void adjustRenderer(
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
241 int idx,
334
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
242 int seriesCount,
327
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
243 boolean renderLines,
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
244 boolean renderShapes
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
245 ) {
334
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
246 log.debug("Adjust render of series");
327
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
247 XYLineAndShapeRenderer renderer = null;
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
248 XYPlot plot = chart.getXYPlot();
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
249
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
250 try {
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
251 renderer = (XYLineAndShapeRenderer)((XYLineAndShapeRenderer)
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
252 (plot.getRenderer())).clone();
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
253 }
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
254 catch (CloneNotSupportedException cnse) {
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
255 log.warn("Error while cloning renderer.", cnse);
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
256 renderer = new XYLineAndShapeRenderer(renderLines, renderShapes);
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
257 renderer.setBaseShape(new Ellipse2D.Double(-2,-2,4,4));
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
258 }
22a6493e8460 New options in chart template: visibility of lines and points in charts and point's size.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 315
diff changeset
259
334
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
260 for (int i = 0; i < seriesCount; i++) {
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
261 renderer.setSeriesShape(i, renderer.getSeriesShape(0));
774
d0a39efbfd96 Removed race-condition when trying to access the index of the next line color used in charts (applied patch in issue211).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 767
diff changeset
262 renderer.setSeriesPaint(i, COLOR[nextColor() % COLOR.length]);
334
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
263 renderer.setSeriesShapesVisible(i, renderShapes);
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
264 renderer.setSeriesLinesVisible(i, renderLines);
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
265 }
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
266 plot.setRenderer(idx, renderer);
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267 }
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268
774
d0a39efbfd96 Removed race-condition when trying to access the index of the next line color used in charts (applied patch in issue211).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 767
diff changeset
269 protected static synchronized int nextColor() {
d0a39efbfd96 Removed race-condition when trying to access the index of the next line color used in charts (applied patch in issue211).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 767
diff changeset
270 return nextColor++;
d0a39efbfd96 Removed race-condition when trying to access the index of the next line color used in charts (applied patch in issue211).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 767
diff changeset
271 }
d0a39efbfd96 Removed race-condition when trying to access the index of the next line color used in charts (applied patch in issue211).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 767
diff changeset
272
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
274 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
275 * Method to adjust the plot rendering. Disable horizontal grid lines if
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
276 * <code>plot</code> contains only a single y-axis.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
277 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
278 * @param plot JFreeChart Plot object to be adjusted.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
279 */
344
44adf8918155 Fade out range axis gridlines in charts if there are more than one axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 335
diff changeset
280 protected void adjustPlot(XYPlot plot) {
44adf8918155 Fade out range axis gridlines in charts if there are more than one axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 335
diff changeset
281 if (plot.getRangeAxisCount() > 1)
44adf8918155 Fade out range axis gridlines in charts if there are more than one axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 335
diff changeset
282 plot.setRangeGridlinesVisible(false);
44adf8918155 Fade out range axis gridlines in charts if there are more than one axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 335
diff changeset
283 }
44adf8918155 Fade out range axis gridlines in charts if there are more than one axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 335
diff changeset
284
44adf8918155 Fade out range axis gridlines in charts if there are more than one axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 335
diff changeset
285
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
286 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
287 * Abstract method which is called after chart creation. It turns an
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
288 * axis' label into a locale specific format.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
289 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
290 * @param axis Axis to adjust.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
291 * @param local java.util.Locale object used specify the format.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
292 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
293 * @param axis
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
294 */
315
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
295 protected void localizeRangeAxis(Axis axis, Locale locale) {
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
296 if (locale == null)
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
297 return;
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
298
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
299 log.debug(
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
300 "Set language of axis [" + axis.getLabel() + "] " +
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
301 "to " + locale.toString()
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
302 );
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
303
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
304 NumberFormat format = NumberFormat.getInstance(locale);
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
305 ((NumberAxis) axis).setNumberFormatOverride(format);
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
306 }
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
307
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
308
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
309 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
310 * Return the maximum y-range of <code>dataset</code>.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
311 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
312 * @param dataset Dataset to be scaned.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
313 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
314 * @return JFreeChart Range object containing min and max y-value.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
315 */
364
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
316 public Range getMaxRangeOfDataset(XYDataset dataset) {
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
317 int seriesCount = dataset.getSeriesCount();
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
318 double upper = Double.NEGATIVE_INFINITY;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
319 double lower = Double.POSITIVE_INFINITY;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
320
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
321 for (int i = 0; i < seriesCount; i++) {
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
322 int itemCount = dataset.getItemCount(i);
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
323
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
324 for (int j = 0; j < itemCount; j++) {
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
325 Number num = dataset.getY(i, j);
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
326
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
327 if (num != null) {
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
328 double y = num.doubleValue();
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
329 lower = y < lower ? y : lower;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
330 upper = y > upper ? y : upper;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
331 }
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
332 }
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
333 }
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
334
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
335 return new Range(lower, upper);
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
336 }
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
337
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
338
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
339 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
340 * Return the maximum y-range of <code>dataset</code> with a margin of
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
341 * <code>percent</code> percent.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
342 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
343 * @param dataset Dataset to be scaned.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
344 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
345 * @return JFreeChart Range object containing min and max y-value with a
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
346 * margin.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
347 */
364
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
348 public Range getMaxRangeOfDatasetWithMargin(
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
349 XYDataset dataset,
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
350 double percent
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
351 ) {
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
352 Range range = getMaxRangeOfDataset(dataset);
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
353 double length = range.getLength();
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
354 double upper = range.getUpperBound() + length /100 * percent;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
355 double lower = range.getLowerBound() - length /100 * percent;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
356
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
357 return new Range(lower, upper);
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
358 }
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
359
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
360
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
361 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
362 * Method to find a parameter specified by its value.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
363 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
364 * @param label Search string.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
365 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
366 * @return Value of a parameter with the given label.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
367 */
334
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
368 protected String findParameter(String label) {
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
369 Iterator iter = parameters.iterator();
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
370
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
371 while (iter.hasNext()) {
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
372 KeyValueDescibeData data = (KeyValueDescibeData) iter.next();
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
373 String key = data.getValue();
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
374
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
375 if (label.indexOf(key) > -1)
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
376 return key;
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
377 }
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
378
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
379 return label;
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
380 }
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
381
e37930705daa Changed the way of adding data to charts. Same parameters have one axis - not each parameter its own one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 333
diff changeset
382
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
383 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
384 * Method to find a description of a given collection of values.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
385 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
386 * @param values Collection to be scaned.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
387 * @param id Identifier and search string of the searched value.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
388 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
389 * @return title
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
390 */
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
391 protected String findValueTitle(Collection values, String id) {
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
392 log.debug("find description of dataset");
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
393
307
f0f106c7b906 Fixed some broken Method-Extentions.
Tim Englich <tim.englich@intevation.de>
parents: 304
diff changeset
394 if (values != null){
f0f106c7b906 Fixed some broken Method-Extentions.
Tim Englich <tim.englich@intevation.de>
parents: 304
diff changeset
395 Iterator it = values.iterator();
f0f106c7b906 Fixed some broken Method-Extentions.
Tim Englich <tim.englich@intevation.de>
parents: 304
diff changeset
396 while (it.hasNext()) {
f0f106c7b906 Fixed some broken Method-Extentions.
Tim Englich <tim.englich@intevation.de>
parents: 304
diff changeset
397 KeyValueDescibeData data = (KeyValueDescibeData) it.next();
315
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
398
307
f0f106c7b906 Fixed some broken Method-Extentions.
Tim Englich <tim.englich@intevation.de>
parents: 304
diff changeset
399 if (id.equals(data.getKey()))
f0f106c7b906 Fixed some broken Method-Extentions.
Tim Englich <tim.englich@intevation.de>
parents: 304
diff changeset
400 return data.getValue();
f0f106c7b906 Fixed some broken Method-Extentions.
Tim Englich <tim.englich@intevation.de>
parents: 304
diff changeset
401 }
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
402 }
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
403 return "";
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
404 }
364
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
405
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
406
767
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
407 /**
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
408 * Method to store the maximum range. Since we need to adjust the range of
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
409 * each range axis, we have to memorize its range - each parameter uses an
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
410 * own range axis.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
411 *
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
412 * @param ranges Map where ranges of each axis will be stored in.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
413 * @param value A given value on an axis.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
414 * @param parameter Parameter name which belongs to <code>value</code>.
79401c871da4 Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 656
diff changeset
415 */
656
b98d1adee7a6 Added an offset of five percent between values and chart border in vertical profile charts (issue186).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 506
diff changeset
416 protected void storeMaxRange(Map ranges, double value, String parameter) {
364
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
417 Range range = null;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
418
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
419 range = ranges.containsKey(parameter)
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
420 ? (Range) ranges.get(parameter)
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
421 : new Range(value, value);
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
422
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
423 double lower = range.getLowerBound();
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
424 double upper = range.getUpperBound();
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
425
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
426 lower = value < lower ? value : lower;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
427 upper = value > upper ? value : upper;
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
428
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
429 ranges.put(parameter, new Range(lower, upper));
2413273f1c13 Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 351
diff changeset
430 }
297
3f43392df3f6 Interface and abstract classes for chart creation implemented.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
431 }
315
63f8b3fb7d9a Localization of chart axis with locale which fits best to server and browser settings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 307
diff changeset
432 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org