Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/chart/DefaultHistogram.java @ 1117:dec4257ad570
Changed imports to fit new positions of XMLUtils and Config
gnv-artifacts/trunk@1478 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 15 Mar 2011 16:13:39 +0000 |
parents | f953c9a559d8 |
children |
rev | line source |
---|---|
1115
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
1 /* |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
2 * Copyright (c) 2010 by Intevation GmbH |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
3 * |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
7 */ |
f953c9a559d8
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
8 |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 package de.intevation.gnv.chart; |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
1107
86ca3c10523f
Adjust the format of axes labels in histograms corresponding the specified locale (issue316).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1055
diff
changeset
|
11 import java.util.Locale; |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
12 import java.util.Map; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
13 |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import org.apache.log4j.Logger; |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import org.jfree.chart.ChartTheme; |
623
65f09139e9b3
Fixed file handle leak when writing meta data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
617
diff
changeset
|
17 |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import org.jfree.chart.plot.XYPlot; |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 /** |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
21 * Default implementation of {@link de.intevation.gnv.chart.AbstractHistogram}. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
22 * |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
23 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 */ |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 public class DefaultHistogram |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 extends AbstractHistogram |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 { |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
28 /** |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
29 * Default bin count. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
30 * TODO find a better default value |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
31 */ |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 public static final int DEFAULT_BINS = 15; |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
33 |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
34 /** |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
35 * Constant field for limitating the number of bin in a single histogram. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
36 */ |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
37 public static final int MAXIMAL_BINS = 20; |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
38 |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
39 /** |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
40 * Default key to retrieve the number of bins from {@link |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
41 * #requestParameter}. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
42 */ |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
43 public static final String REQUEST_KEY_BIN_COUNT = "bincount"; |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
44 |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
45 /** |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
46 * Default key to retrieve the width of a single bin from {@link |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
47 * #requestParameter}. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
48 */ |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
49 public static final String REQUEST_KEY_BIN_WIDTH = "binwidth"; |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
50 |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
51 /** |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
52 * Default key to retrieve the chart width from {@link #requestParameter}. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
53 */ |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
54 public static final String REQUEST_KEY_CHART_WIDTH = "width"; |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
55 |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
56 /** |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
767
diff
changeset
|
57 * Default key to retrieve the object from {@link #requestParameter}. It |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
58 * defines which value this chart has to be used for bin calculation. You |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
59 * can either adjust the number of bins or the width of a single bin. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
60 */ |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
61 public static final String REQUEST_KEY_BIN_CHOICE = "bintype"; |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
63 /** |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
64 * Logger used for logging with log4j. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
65 */ |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 private static Logger logger = Logger.getLogger(DefaultHistogram.class); |
3d13fa281a7e
Added new ouput mode: histogram.
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:
629
diff
changeset
|
68 /** |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
69 * Object storing some further parameter used for chart settings. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
70 */ |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
71 protected Map requestParameter; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
72 |
1055
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
73 protected double[] minmax = null; |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
74 |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
76 /** |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
77 * Constructor to create DefaultHistogram objects. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
78 * |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
79 * @param labels Labels to decorate this chart. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
80 * @param data Raw data to be displayed in histogram. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
81 * @param theme Theme used to adjust the chart look. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
82 * @param requestParameter Object which serves some further settings. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
83 */ |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 public DefaultHistogram( |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
85 ChartLabels labels, Object[] data, ChartTheme theme, Map requestParameter |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 ) { |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 super(labels, data, theme); |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
88 this.requestParameter = requestParameter; |
1107
86ca3c10523f
Adjust the format of axes labels in histograms corresponding the specified locale (issue316).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1055
diff
changeset
|
89 this.locale = (Locale) requestParameter.get("locale"); |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 } |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
93 @Override |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 protected void applyDatasets() { |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 XYPlot plot = (XYPlot) chart.getPlot(); |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 // prepare data and create add them to histogram dataset |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 String name = (String) data[0]; |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 double[] values = toDouble((Double[]) data[1]); |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 |
1055
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
101 double binWidth = getBinWidth(values); |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
102 int binCount = getBinCount(); |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
103 |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
104 AdvancedHistogramDataset dataset = |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
105 new AdvancedHistogramDataset(binCount, binWidth); |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
106 dataset.addSeries(name, values); |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 plot.setDataset(0, dataset); |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 } |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
112 /** |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
113 * Method which scans the hole bunch of values and returns an array with |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
114 * contains min and max value. Min value is stored at position 0, max value |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
115 * is stored at position 1 in that array. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
116 * |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
117 * @param values Array which contains all values |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
118 * |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
119 * @return Array which contains min and max value |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
120 */ |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
121 protected double[] getMinMax(double[] values) { |
1055
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
122 if (minmax != null) |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
123 return minmax; |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
124 |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
125 double[] minmax = new double[2]; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
126 minmax[0] = Double.MAX_VALUE; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
127 minmax[1] = Double.MIN_VALUE; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
128 |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
129 int length = values.length; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
130 for (int i = 0; i < length; i++) { |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
131 minmax[0] = values[i] < minmax[0] ? values[i] : minmax[0]; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
132 minmax[1] = values[i] > minmax[1] ? values[i] : minmax[1]; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
133 } |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
134 |
1055
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
135 this.minmax = minmax; |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
136 |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
137 return minmax; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
138 } |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
139 |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
140 |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
141 /** |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
142 * Turn a Double[] into a double[]. |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
143 * |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
144 * @param array Doube[] |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
145 * |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
146 * @return double[] |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
147 */ |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 protected double[] toDouble(Double[] array) { |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 int length = array.length; |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 double[] values = new double[length]; |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 for(int i = 0; i < length; i++) { |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 values[i] = array[i].doubleValue(); |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 } |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 return values; |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 } |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
158 |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
159 |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
160 /** |
1055
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
161 * Method to retrieve the number of bins. |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
162 * |
1055
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
163 * @return the number of bins that is specified in <i>requestParameter</i> |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
164 * or -1 if the number of bins is not the dominant value to calculate the |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
165 * width of a single bin. |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
166 */ |
1055
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
167 protected int getBinCount() { |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
168 // Return -1 to trigger a calculation of the number of bins in |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
169 // AdvancedHistogramDataset if the user chose the bin width as dominant |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
170 // value. |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
171 String choice = (String) requestParameter.get(REQUEST_KEY_BIN_CHOICE); |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
172 if (choice != null && choice.equalsIgnoreCase(REQUEST_KEY_BIN_WIDTH)) { |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
173 return -1; |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
174 } |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
175 |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
176 int bins = -1; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
177 String param = (String) requestParameter.get(REQUEST_KEY_BIN_COUNT); |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
178 |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
179 try { |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
180 bins = Integer.parseInt(param); |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
181 bins = bins <= 0 ? DEFAULT_BINS : bins; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
182 bins = bins > MAXIMAL_BINS ? MAXIMAL_BINS : bins; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
183 |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
184 return bins; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
185 } |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
186 catch (NumberFormatException nfe) { |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
187 logger.warn("Invalid number of bins for histogram chart: " + param); |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
188 logger.warn("Return default bins: " + DEFAULT_BINS); |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
189 |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
190 return DEFAULT_BINS; |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
191 } |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
192 } |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
193 |
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
194 |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
195 /** |
1055
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
196 * Serves width of a single bin. |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
197 * |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
198 * @param values All values in this histogram |
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
199 * |
1055
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
200 * @return The bin width that is given in <i>requestParameter</i> or -1 if |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
201 * the bin width is not the dominant value for calculating the number of |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
202 * bins in the histogram. |
767
79401c871da4
Added and repaired javadoc in de.intevation.gnv.chart package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
629
diff
changeset
|
203 */ |
1055
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
204 protected double getBinWidth(double[] values) { |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
205 // Return -1 to trigger a calculation of the bin width in |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
206 // AdvancedHistogramDataset if the user chose the number of bins as |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
207 // dominant value. |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
208 String choice = (String) requestParameter.get(REQUEST_KEY_BIN_CHOICE); |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
209 if (choice == null || !choice.equalsIgnoreCase(REQUEST_KEY_BIN_WIDTH)) { |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
210 return -1; |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
211 } |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
212 |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
213 int bins = -1; |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
214 String param = (String) requestParameter.get(REQUEST_KEY_BIN_WIDTH); |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
215 |
1054
8430269ec73b
Removed the parsing for double/integer values specifying the bin width or the number of bins in DefaultHistogram, because these inserted values are no longer i18n strings (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
815
diff
changeset
|
216 double[] minmax = getMinMax(values); |
8430269ec73b
Removed the parsing for double/integer values specifying the bin width or the number of bins in DefaultHistogram, because these inserted values are no longer i18n strings (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
815
diff
changeset
|
217 double totalWidth = minmax[1] - minmax[0]; |
8430269ec73b
Removed the parsing for double/integer values specifying the bin width or the number of bins in DefaultHistogram, because these inserted values are no longer i18n strings (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
815
diff
changeset
|
218 double binWidth = Double.parseDouble(param); |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
219 |
1054
8430269ec73b
Removed the parsing for double/integer values specifying the bin width or the number of bins in DefaultHistogram, because these inserted values are no longer i18n strings (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
815
diff
changeset
|
220 double tmpBins = totalWidth / binWidth; |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
221 |
1054
8430269ec73b
Removed the parsing for double/integer values specifying the bin width or the number of bins in DefaultHistogram, because these inserted values are no longer i18n strings (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
815
diff
changeset
|
222 bins = (int) Math.round(tmpBins); |
8430269ec73b
Removed the parsing for double/integer values specifying the bin width or the number of bins in DefaultHistogram, because these inserted values are no longer i18n strings (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
815
diff
changeset
|
223 bins = bins <= 0 ? DEFAULT_BINS : bins; |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
224 |
1055
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
225 // the calculated number of bins with the given width exceed the maximum |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
226 // number of bins. |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
227 if (bins > MAXIMAL_BINS) { |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
228 return totalWidth / (MAXIMAL_BINS); |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
229 } |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
230 |
bb2679624c6a
Implemented a new histogram dataset that takes the width of a single bin as well as the number of bins for the histogram (issue288).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1054
diff
changeset
|
231 return binWidth; |
629
d08b9ba148c5
Implemented logic to adjust number of bins corresponding to user input.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
623
diff
changeset
|
232 } |
617
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
233 } |
3d13fa281a7e
Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
234 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |