annotate gnv-artifacts/src/main/java/de/intevation/gnv/chart/AdvancedHistogramDataset.java @ 1113:e7efbded1367

Summarized changes for RELEASE 1.1 gnv-artifacts/trunk@1251 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 30 Jun 2010 12:26:04 +0000
parents bb2679624c6a
children 7e085bfb107b
rev   line source
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:
diff changeset
1 package de.intevation.gnv.chart;
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:
diff changeset
2
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:
diff changeset
3 import java.io.Serializable;
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:
diff changeset
4 import java.util.ArrayList;
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:
diff changeset
5 import java.util.HashMap;
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:
diff changeset
6 import java.util.List;
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:
diff changeset
7 import java.util.Map;
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:
diff changeset
8
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:
diff changeset
9 import org.apache.log4j.Logger;
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:
diff changeset
10
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:
diff changeset
11 import org.jfree.data.general.DatasetChangeEvent;
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:
diff changeset
12 import org.jfree.data.xy.AbstractIntervalXYDataset;
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:
diff changeset
13 import org.jfree.data.xy.IntervalXYDataset;
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:
diff changeset
14
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:
diff changeset
15 import org.jfree.data.statistics.HistogramType;
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:
diff changeset
16 import org.jfree.data.statistics.HistogramBin;
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:
diff changeset
17
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:
diff changeset
18 import org.jfree.util.ObjectUtilities;
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:
diff changeset
19 import org.jfree.util.PublicCloneable;
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:
diff changeset
20
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:
diff changeset
21 /**
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:
diff changeset
22 * This class extends the functionality of the internal JFreeChart class
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:
diff changeset
23 * <code>HistogramDataset</code>. <code>AdvancedHistogramDataset</code> takes
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:
diff changeset
24 * the number of bins OR a bin width. It is mainly a copy of this class. 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:
diff changeset
25 * reason why there is no inheritance from JFreeChart's internal class is,
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:
diff changeset
26 * that basic attributes have private access there.
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:
diff changeset
27 *
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:
diff changeset
28 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
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:
diff changeset
29 */
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:
diff changeset
30 public class AdvancedHistogramDataset
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:
diff changeset
31 extends AbstractIntervalXYDataset
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:
diff changeset
32 implements IntervalXYDataset, Cloneable, PublicCloneable, Serializable
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:
diff changeset
33 {
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:
diff changeset
34 /** A list of maps. */
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:
diff changeset
35 protected List list;
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:
diff changeset
36
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:
diff changeset
37 /** The histogram type. */
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:
diff changeset
38 protected HistogramType type;
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:
diff changeset
39
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:
diff changeset
40 /** The width of a single bin. */
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:
diff changeset
41 protected double binWidth = -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:
diff changeset
42
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:
diff changeset
43 /** The 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:
diff changeset
44 protected 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:
diff changeset
45
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:
diff changeset
46 /** The logger */
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:
diff changeset
47 private static Logger logger =
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:
diff changeset
48 Logger.getLogger(AdvancedHistogramDataset.class);
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:
diff changeset
49
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:
diff changeset
50
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:
diff changeset
51 /**
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:
diff changeset
52 * Creates a new (empty) dataset with a default type 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:
diff changeset
53 * {@link HistogramType}.FREQUENCY.
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:
diff changeset
54 */
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:
diff changeset
55 public AdvancedHistogramDataset() {
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:
diff changeset
56 this.list = new ArrayList();
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:
diff changeset
57 this.type = HistogramType.FREQUENCY;
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:
diff changeset
58 }
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:
diff changeset
59
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:
diff changeset
60 /**
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:
diff changeset
61 * Creates a new (empty) dataset with a default type 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:
diff changeset
62 * {@link HistogramType}.FREQUENCY.
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:
diff changeset
63 */
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:
diff changeset
64 public AdvancedHistogramDataset(int bins, double 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:
diff changeset
65 this.list = new ArrayList();
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:
diff changeset
66 this.type = HistogramType.FREQUENCY;
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:
diff changeset
67 this.bins = 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:
diff changeset
68 this.binWidth = 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:
diff changeset
69 }
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:
diff changeset
70
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:
diff changeset
71 /**
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:
diff changeset
72 * Returns the histogram type.
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:
diff changeset
73 *
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:
diff changeset
74 * @return The type (never <code>null</code>).
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:
diff changeset
75 */
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:
diff changeset
76 public HistogramType getType() {
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:
diff changeset
77 return this.type;
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:
diff changeset
78 }
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:
diff changeset
79
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:
diff changeset
80 /**
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:
diff changeset
81 * Sets the histogram type and sends a {@link DatasetChangeEvent} to all
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:
diff changeset
82 * registered listeners.
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:
diff changeset
83 *
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:
diff changeset
84 * @param type the type (<code>null</code> not permitted).
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:
diff changeset
85 */
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:
diff changeset
86 public void setType(HistogramType type) {
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:
diff changeset
87 if (type == 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:
diff changeset
88 throw new IllegalArgumentException("Null 'type' argument");
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:
diff changeset
89 }
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:
diff changeset
90 this.type = type;
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:
diff changeset
91 notifyListeners(new DatasetChangeEvent(this, this));
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:
diff changeset
92 }
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:
diff changeset
93
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:
diff changeset
94 /**
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:
diff changeset
95 * Adds a series to the dataset, using the specified 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:
diff changeset
96 *
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:
diff changeset
97 * @param key the series key (<code>null</code> not permitted).
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:
diff changeset
98 * @param values the values (<code>null</code> not permitted).
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:
diff changeset
99 */
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:
diff changeset
100 public void addSeries(Comparable key, 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:
diff changeset
101 double minimum = getMinimum(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:
diff changeset
102 double maximum = getMaximum(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:
diff changeset
103 addSeries(key, values, minimum, 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:
diff changeset
104 }
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:
diff changeset
105
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:
diff changeset
106 /**
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:
diff changeset
107 * Adds a series to the dataset. Any data value less than minimum will be
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:
diff changeset
108 * assigned to the first bin, and any data value greater than maximum will
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:
diff changeset
109 * be assigned to the last bin. Values falling on the boundary 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:
diff changeset
110 * adjacent bins will be assigned to the higher indexed bin.
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:
diff changeset
111 *
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:
diff changeset
112 * @param key the series key (<code>null</code> not permitted).
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:
diff changeset
113 * @param values the raw observations.
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:
diff changeset
114 * @param bins the number of bins (must be at least 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:
diff changeset
115 * @param minimum the lower bound of the bin range.
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:
diff changeset
116 * @param maximum the upper bound of the bin range.
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:
diff changeset
117 */
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:
diff changeset
118 public void addSeries(Comparable key,
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:
diff changeset
119 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:
diff changeset
120 double minimum,
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:
diff changeset
121 double 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:
diff changeset
122
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:
diff changeset
123 if (key == 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:
diff changeset
124 throw new IllegalArgumentException("Null 'key' argument.");
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:
diff changeset
125 }
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:
diff changeset
126 if (values == 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:
diff changeset
127 throw new IllegalArgumentException("Null 'values' argument.");
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:
diff changeset
128 }
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:
diff changeset
129 if (bins <= 0 && binWidth <= 0) {
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:
diff changeset
130 throw new IllegalArgumentException(
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:
diff changeset
131 "We need at least a bin width or the 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:
diff changeset
132 }
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:
diff changeset
133
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:
diff changeset
134 // There is a binWidth given to calculate the number of bins in this
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:
diff changeset
135 // case
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:
diff changeset
136 if (bins <= 0) {
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:
diff changeset
137 double tmp = (maximum - minimum) / 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:
diff changeset
138 bins = (int) tmp;
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:
diff changeset
139 bins = tmp % 1 > 0 ? bins + 1 : 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:
diff changeset
140
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:
diff changeset
141 double overlap = minimum + bins * binWidth - 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:
diff changeset
142 tmp = minimum;
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:
diff changeset
143 minimum -= overlap / 2;
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:
diff changeset
144
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:
diff changeset
145 logger.debug("There is an overlap of " + overlap);
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:
diff changeset
146 logger.info("The lower bound is moved left from "
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:
diff changeset
147 + tmp + " to " + minimum);
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:
diff changeset
148
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:
diff changeset
149 tmp = 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:
diff changeset
150 maximum += overlap / 2;
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:
diff changeset
151 logger.info("The upper bound is moved right from "
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:
diff changeset
152 + tmp + " to " + 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:
diff changeset
153 }
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:
diff changeset
154
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:
diff changeset
155 if (bins <= 0) {
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:
diff changeset
156 throw new IllegalArgumentException(
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:
diff changeset
157 "The 'bins' value must be at least 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:
diff changeset
158 }
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:
diff changeset
159
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:
diff changeset
160 // in this case, there is a number of bins given, so we need to
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:
diff changeset
161 // calculate the width of a single bin
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:
diff changeset
162 if (binWidth <= 0)
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:
diff changeset
163 binWidth = (maximum - minimum) / 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:
diff changeset
164
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:
diff changeset
165 logger.info("bin width: " + 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:
diff changeset
166 logger.info("number of bins: " + 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:
diff changeset
167
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:
diff changeset
168 double lower = minimum;
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:
diff changeset
169 double upper;
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:
diff changeset
170 List binList = new ArrayList(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:
diff changeset
171 for (int i = 0; i < bins; 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:
diff changeset
172 HistogramBin bin;
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:
diff changeset
173 // make sure bins[bins.length]'s upper boundary ends at 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:
diff changeset
174 // to avoid the rounding issue. the bins[0] lower boundary is
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:
diff changeset
175 // guaranteed start from min
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:
diff changeset
176 if (i == 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:
diff changeset
177 bin = new HistogramBin(lower, 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:
diff changeset
178 }
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:
diff changeset
179 else {
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:
diff changeset
180 upper = minimum + (i + 1) * 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:
diff changeset
181 bin = new HistogramBin(lower, upper);
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:
diff changeset
182 lower = upper;
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:
diff changeset
183 }
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:
diff changeset
184 binList.add(bin);
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:
diff changeset
185 }
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:
diff changeset
186 // fill the 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:
diff changeset
187 for (int i = 0; i < values.length; 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:
diff changeset
188 int binIndex = 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:
diff changeset
189 if (values[i] < 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:
diff changeset
190 double fraction = (values[i] - minimum) / (maximum - minimum);
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:
diff changeset
191 if (fraction < 0.0) {
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:
diff changeset
192 fraction = 0.0;
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:
diff changeset
193 }
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:
diff changeset
194 binIndex = (int) (fraction * 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:
diff changeset
195 // rounding could result in binIndex being equal to 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:
diff changeset
196 // which will cause an IndexOutOfBoundsException - see bug
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:
diff changeset
197 // report 1553088
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:
diff changeset
198 if (binIndex >= 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:
diff changeset
199 binIndex = 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:
diff changeset
200 }
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:
diff changeset
201 }
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:
diff changeset
202 HistogramBin bin = (HistogramBin) binList.get(binIndex);
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:
diff changeset
203 bin.incrementCount();
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:
diff changeset
204 }
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:
diff changeset
205 // generic map for each series
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:
diff changeset
206 Map map = new HashMap();
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:
diff changeset
207 map.put("key", key);
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:
diff changeset
208 map.put("bins", binList);
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:
diff changeset
209 map.put("values.length", new Integer(values.length));
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:
diff changeset
210 map.put("bin width", new Double(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:
diff changeset
211 this.list.add(map);
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:
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:
diff changeset
213
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:
diff changeset
214 /**
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:
diff changeset
215 * Returns the minimum value in an array of 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:
diff changeset
216 *
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:
diff changeset
217 * @param values the values (<code>null</code> not permitted and
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:
diff changeset
218 * zero-length array not permitted).
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:
diff changeset
219 *
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:
diff changeset
220 * @return The minimum 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:
diff changeset
221 */
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:
diff changeset
222 private double getMinimum(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:
diff changeset
223 if (values == null || values.length < 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:
diff changeset
224 throw new IllegalArgumentException(
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:
diff changeset
225 "Null or zero length 'values' argument.");
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:
diff changeset
226 }
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:
diff changeset
227 double min = Double.MAX_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:
diff changeset
228 for (int i = 0; i < values.length; 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:
diff changeset
229 if (values[i] < min) {
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:
diff changeset
230 min = values[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:
diff changeset
231 }
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:
diff changeset
232 }
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:
diff changeset
233 return min;
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:
diff changeset
234 }
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:
diff changeset
235
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:
diff changeset
236 /**
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:
diff changeset
237 * Returns the maximum value in an array of 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:
diff changeset
238 *
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:
diff changeset
239 * @param values the values (<code>null</code> not permitted and
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:
diff changeset
240 * zero-length array not permitted).
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:
diff changeset
241 *
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:
diff changeset
242 * @return The maximum 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:
diff changeset
243 */
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:
diff changeset
244 private double getMaximum(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:
diff changeset
245 if (values == null || values.length < 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:
diff changeset
246 throw new IllegalArgumentException(
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:
diff changeset
247 "Null or zero length 'values' argument.");
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:
diff changeset
248 }
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:
diff changeset
249 double max = -Double.MAX_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:
diff changeset
250 for (int i = 0; i < values.length; 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:
diff changeset
251 if (values[i] > max) {
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:
diff changeset
252 max = values[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:
diff changeset
253 }
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:
diff changeset
254 }
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:
diff changeset
255 return max;
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:
diff changeset
256 }
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:
diff changeset
257
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:
diff changeset
258 /**
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:
diff changeset
259 * Returns the bins for a series.
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:
diff changeset
260 *
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:
diff changeset
261 * @param series the series index (in the range <code>0</code> to
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:
diff changeset
262 * <code>getSeriesCount() - 1</code>).
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:
diff changeset
263 *
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:
diff changeset
264 * @return A list 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:
diff changeset
265 *
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:
diff changeset
266 * @throws IndexOutOfBoundsException if <code>series</code> is outside 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:
diff changeset
267 * specified range.
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:
diff changeset
268 */
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:
diff changeset
269 List getBins(int series) {
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:
diff changeset
270 Map map = (Map) this.list.get(series);
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:
diff changeset
271 return (List) map.get("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:
diff changeset
272 }
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:
diff changeset
273
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:
diff changeset
274 /**
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:
diff changeset
275 * Returns the total number of observations for a series.
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:
diff changeset
276 *
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:
diff changeset
277 * @param series the series index.
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:
diff changeset
278 *
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:
diff changeset
279 * @return The total.
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:
diff changeset
280 */
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:
diff changeset
281 private int getTotal(int series) {
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:
diff changeset
282 Map map = (Map) this.list.get(series);
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:
diff changeset
283 return ((Integer) map.get("values.length")).intValue();
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:
diff changeset
284 }
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:
diff changeset
285
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:
diff changeset
286 /**
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:
diff changeset
287 * Returns the bin width for a series.
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:
diff changeset
288 *
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:
diff changeset
289 * @param series the series index (zero based).
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:
diff changeset
290 *
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:
diff changeset
291 * @return The 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:
diff changeset
292 */
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:
diff changeset
293 private double getBinWidth(int series) {
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:
diff changeset
294 if (binWidth > 0)
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:
diff changeset
295 return 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:
diff changeset
296
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:
diff changeset
297 Map map = (Map) this.list.get(series);
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:
diff changeset
298 return ((Double) map.get("bin width")).doubleValue();
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:
diff changeset
299 }
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:
diff changeset
300
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:
diff changeset
301 /**
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:
diff changeset
302 * Returns the number of series in the 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:
diff changeset
303 *
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:
diff changeset
304 * @return The series count.
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:
diff changeset
305 */
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:
diff changeset
306 public int getSeriesCount() {
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:
diff changeset
307 return this.list.size();
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:
diff changeset
308 }
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:
diff changeset
309
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:
diff changeset
310 /**
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:
diff changeset
311 * Returns the key for a series.
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:
diff changeset
312 *
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:
diff changeset
313 * @param series the series index (in the range <code>0</code> to
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:
diff changeset
314 * <code>getSeriesCount() - 1</code>).
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:
diff changeset
315 *
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:
diff changeset
316 * @return The series key.
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:
diff changeset
317 *
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:
diff changeset
318 * @throws IndexOutOfBoundsException if <code>series</code> is outside 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:
diff changeset
319 * specified range.
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:
diff changeset
320 */
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:
diff changeset
321 public Comparable getSeriesKey(int series) {
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:
diff changeset
322 Map map = (Map) this.list.get(series);
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:
diff changeset
323 return (Comparable) map.get("key");
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:
diff changeset
324 }
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:
diff changeset
325
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:
diff changeset
326 /**
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:
diff changeset
327 * Returns the number of data items for a series.
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:
diff changeset
328 *
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:
diff changeset
329 * @param series the series index (in the range <code>0</code> to
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:
diff changeset
330 * <code>getSeriesCount() - 1</code>).
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:
diff changeset
331 *
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:
diff changeset
332 * @return The item count.
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:
diff changeset
333 *
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:
diff changeset
334 * @throws IndexOutOfBoundsException if <code>series</code> is outside 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:
diff changeset
335 * specified range.
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:
diff changeset
336 */
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:
diff changeset
337 public int getItemCount(int series) {
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:
diff changeset
338 return getBins(series).size();
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:
diff changeset
339 }
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:
diff changeset
340
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:
diff changeset
341 /**
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:
diff changeset
342 * Returns the X value for a bin. This value won't be used for plotting
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:
diff changeset
343 * histograms, since the renderer will ignore it. But other renderers can
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:
diff changeset
344 * use it (for example, you could use the dataset to create a line
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:
diff changeset
345 * chart).
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:
diff changeset
346 *
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:
diff changeset
347 * @param series the series index (in the range <code>0</code> to
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:
diff changeset
348 * <code>getSeriesCount() - 1</code>).
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:
diff changeset
349 * @param item the item index (zero based).
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:
diff changeset
350 *
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:
diff changeset
351 * @return The start 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:
diff changeset
352 *
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:
diff changeset
353 * @throws IndexOutOfBoundsException if <code>series</code> is outside 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:
diff changeset
354 * specified range.
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:
diff changeset
355 */
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:
diff changeset
356 public Number getX(int series, int item) {
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:
diff changeset
357 List bins = getBins(series);
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:
diff changeset
358 HistogramBin bin = (HistogramBin) bins.get(item);
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:
diff changeset
359 double x = (bin.getStartBoundary() + bin.getEndBoundary()) / 2.;
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:
diff changeset
360 return new Double(x);
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:
diff changeset
361 }
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:
diff changeset
362
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:
diff changeset
363 /**
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:
diff changeset
364 * Returns the y-value for a bin (calculated to take into account 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:
diff changeset
365 * histogram type).
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:
diff changeset
366 *
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:
diff changeset
367 * @param series the series index (in the range <code>0</code> to
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:
diff changeset
368 * <code>getSeriesCount() - 1</code>).
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:
diff changeset
369 * @param item the item index (zero based).
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:
diff changeset
370 *
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:
diff changeset
371 * @return The y-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:
diff changeset
372 *
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:
diff changeset
373 * @throws IndexOutOfBoundsException if <code>series</code> is outside 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:
diff changeset
374 * specified range.
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:
diff changeset
375 */
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:
diff changeset
376 public Number getY(int series, int item) {
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:
diff changeset
377 List bins = getBins(series);
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:
diff changeset
378 HistogramBin bin = (HistogramBin) bins.get(item);
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:
diff changeset
379 double total = getTotal(series);
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:
diff changeset
380 double binWidth = getBinWidth(series);
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:
diff changeset
381
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:
diff changeset
382 if (this.type == HistogramType.FREQUENCY) {
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:
diff changeset
383 return new Double(bin.getCount());
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:
diff changeset
384 }
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:
diff changeset
385 else if (this.type == HistogramType.RELATIVE_FREQUENCY) {
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:
diff changeset
386 return new Double(bin.getCount() / total);
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:
diff changeset
387 }
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:
diff changeset
388 else if (this.type == HistogramType.SCALE_AREA_TO_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:
diff changeset
389 return new Double(bin.getCount() / (binWidth * total));
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:
diff changeset
390 }
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:
diff changeset
391 else { // pretty sure this shouldn't ever happen
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:
diff changeset
392 throw new IllegalStateException();
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:
diff changeset
393 }
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:
diff changeset
394 }
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:
diff changeset
395
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:
diff changeset
396 /**
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:
diff changeset
397 * Returns the start value for a bin.
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:
diff changeset
398 *
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:
diff changeset
399 * @param series the series index (in the range <code>0</code> to
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:
diff changeset
400 * <code>getSeriesCount() - 1</code>).
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:
diff changeset
401 * @param item the item index (zero based).
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:
diff changeset
402 *
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:
diff changeset
403 * @return The start 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:
diff changeset
404 *
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:
diff changeset
405 * @throws IndexOutOfBoundsException if <code>series</code> is outside 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:
diff changeset
406 * specified range.
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:
diff changeset
407 */
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:
diff changeset
408 public Number getStartX(int series, int item) {
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:
diff changeset
409 List bins = getBins(series);
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:
diff changeset
410 HistogramBin bin = (HistogramBin) bins.get(item);
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:
diff changeset
411 return new Double(bin.getStartBoundary());
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:
diff changeset
412 }
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:
diff changeset
413
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:
diff changeset
414 /**
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:
diff changeset
415 * Returns the end value for a bin.
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:
diff changeset
416 *
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:
diff changeset
417 * @param series the series index (in the range <code>0</code> to
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:
diff changeset
418 * <code>getSeriesCount() - 1</code>).
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:
diff changeset
419 * @param item the item index (zero based).
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:
diff changeset
420 *
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:
diff changeset
421 * @return The end 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:
diff changeset
422 *
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:
diff changeset
423 * @throws IndexOutOfBoundsException if <code>series</code> is outside 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:
diff changeset
424 * specified range.
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:
diff changeset
425 */
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:
diff changeset
426 public Number getEndX(int series, int item) {
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:
diff changeset
427 List bins = getBins(series);
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:
diff changeset
428 HistogramBin bin = (HistogramBin) bins.get(item);
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:
diff changeset
429 return new Double(bin.getEndBoundary());
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:
diff changeset
430 }
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:
diff changeset
431
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:
diff changeset
432 /**
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:
diff changeset
433 * Returns the start y-value for a bin (which is the same as the y-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:
diff changeset
434 * this method exists only to support the general form of 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:
diff changeset
435 * {@link IntervalXYDataset} interface).
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:
diff changeset
436 *
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:
diff changeset
437 * @param series the series index (in the range <code>0</code> to
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:
diff changeset
438 * <code>getSeriesCount() - 1</code>).
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:
diff changeset
439 * @param item the item index (zero based).
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:
diff changeset
440 *
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:
diff changeset
441 * @return The y-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:
diff changeset
442 *
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:
diff changeset
443 * @throws IndexOutOfBoundsException if <code>series</code> is outside 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:
diff changeset
444 * specified range.
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:
diff changeset
445 */
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:
diff changeset
446 public Number getStartY(int series, int item) {
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:
diff changeset
447 return getY(series, item);
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:
diff changeset
448 }
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:
diff changeset
449
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:
diff changeset
450 /**
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:
diff changeset
451 * Returns the end y-value for a bin (which is the same as the y-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:
diff changeset
452 * this method exists only to support the general form of 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:
diff changeset
453 * {@link IntervalXYDataset} interface).
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:
diff changeset
454 *
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:
diff changeset
455 * @param series the series index (in the range <code>0</code> to
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:
diff changeset
456 * <code>getSeriesCount() - 1</code>).
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:
diff changeset
457 * @param item the item index (zero based).
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:
diff changeset
458 *
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:
diff changeset
459 * @return The Y 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:
diff changeset
460 *
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:
diff changeset
461 * @throws IndexOutOfBoundsException if <code>series</code> is outside 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:
diff changeset
462 * specified range.
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:
diff changeset
463 */
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:
diff changeset
464 public Number getEndY(int series, int item) {
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:
diff changeset
465 return getY(series, item);
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:
diff changeset
466 }
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:
diff changeset
467
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:
diff changeset
468 /**
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:
diff changeset
469 * Tests this dataset for equality with an arbitrary object.
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:
diff changeset
470 *
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:
diff changeset
471 * @param obj the object to test against (<code>null</code> permitted).
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:
diff changeset
472 *
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:
diff changeset
473 * @return A boolean.
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:
diff changeset
474 */
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:
diff changeset
475 public boolean equals(Object obj) {
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:
diff changeset
476 if (obj == this) {
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:
diff changeset
477 return true;
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:
diff changeset
478 }
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:
diff changeset
479 if (!(obj instanceof AdvancedHistogramDataset)) {
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:
diff changeset
480 return false;
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:
diff changeset
481 }
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:
diff changeset
482 AdvancedHistogramDataset that = (AdvancedHistogramDataset) obj;
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:
diff changeset
483 if (!ObjectUtilities.equal(this.type, that.type)) {
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:
diff changeset
484 return false;
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:
diff changeset
485 }
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:
diff changeset
486 if (!ObjectUtilities.equal(this.list, that.list)) {
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:
diff changeset
487 return false;
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:
diff changeset
488 }
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:
diff changeset
489 return true;
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:
diff changeset
490 }
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:
diff changeset
491
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:
diff changeset
492 /**
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:
diff changeset
493 * Returns a clone of the 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:
diff changeset
494 *
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:
diff changeset
495 * @return A clone of the 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:
diff changeset
496 *
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:
diff changeset
497 * @throws CloneNotSupportedException if the object cannot be cloned.
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:
diff changeset
498 */
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:
diff changeset
499 public Object clone() throws CloneNotSupportedException {
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:
diff changeset
500 AdvancedHistogramDataset clone = (AdvancedHistogramDataset) super.clone();
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:
diff changeset
501 int seriesCount = getSeriesCount();
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:
diff changeset
502 clone.list = new java.util.ArrayList(seriesCount);
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:
diff changeset
503 for (int i = 0; i < seriesCount; 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:
diff changeset
504 clone.list.add(new HashMap((Map) this.list.get(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:
diff changeset
505 }
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:
diff changeset
506 return clone;
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:
diff changeset
507 }
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:
diff changeset
508 }
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:
diff changeset
509 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org