KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > data > statistics > BoxAndWhiskerItem


1 /* ===========================================================
2  * JFreeChart : a free chart library for the Java(tm) platform
3  * ===========================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jfreechart/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
24  * in the United States and other countries.]
25  *
26  * ----------------------
27  * BoxAndWhiskerItem.java
28  * ----------------------
29  * (C) Copyright 2003-2005, by Object Refinery Limited and Contributors.
30  *
31  * Original Author: David Gilbert (for Object Refinery Limited);
32  * Contributor(s): -;
33  *
34  * $Id: BoxAndWhiskerItem.java,v 1.5 2005/05/19 10:35:26 mungady Exp $
35  *
36  * Changes
37  * -------
38  * 27-Aug-2003 : Version 1 (DG);
39  * 01-Mar-2004 : Added equals() method and implemented Serializable (DG);
40  *
41  */

42
43 package org.jfree.data.statistics;
44
45 import java.io.Serializable JavaDoc;
46 import java.util.Collections JavaDoc;
47 import java.util.List JavaDoc;
48
49 import org.jfree.util.ObjectUtilities;
50
51 /**
52  * Represents one data item within a box-and-whisker dataset. This class is
53  * immutable.
54  */

55 public class BoxAndWhiskerItem implements Serializable JavaDoc {
56     
57     /** For serialization. */
58     private static final long serialVersionUID = 7329649623148167423L;
59     
60     /** The mean. */
61     private Number JavaDoc mean;
62     
63     /** The median. */
64     private Number JavaDoc median;
65     
66     /** The first quarter. */
67     private Number JavaDoc q1;
68     
69     /** The third quarter. */
70     private Number JavaDoc q3;
71     
72     /** The minimum regular value. */
73     private Number JavaDoc minRegularValue;
74     
75     /** The maximum regular value. */
76     private Number JavaDoc maxRegularValue;
77     
78     /** The minimum outlier. */
79     private Number JavaDoc minOutlier;
80     
81     /** The maximum outlier. */
82     private Number JavaDoc maxOutlier;
83     
84     /** The outliers. */
85     private List JavaDoc outliers;
86     
87     /**
88      * Creates a new box-and-whisker item.
89      *
90      * @param mean the mean (<code>null</code> permitted).
91      * @param median the median (<code>null</code> permitted).
92      * @param q1 the first quartile (<code>null</code> permitted).
93      * @param q3 the third quartile (<code>null</code> permitted).
94      * @param minRegularValue the minimum regular value (<code>null</code>
95      * permitted).
96      * @param maxRegularValue the maximum regular value (<code>null</code>
97      * permitted).
98      * @param minOutlier the minimum outlier (<code>null</code> permitted).
99      * @param maxOutlier the maximum outlier (<code>null</code> permitted).
100      * @param outliers the outliers (<code>null</code> permitted).
101      */

102     public BoxAndWhiskerItem(Number JavaDoc mean,
103                              Number JavaDoc median,
104                              Number JavaDoc q1,
105                              Number JavaDoc q3,
106                              Number JavaDoc minRegularValue,
107                              Number JavaDoc maxRegularValue,
108                              Number JavaDoc minOutlier,
109                              Number JavaDoc maxOutlier,
110                              List JavaDoc outliers) {
111                                  
112         this.mean = mean;
113         this.median = median;
114         this.q1 = q1;
115         this.q3 = q3;
116         this.minRegularValue = minRegularValue;
117         this.maxRegularValue = maxRegularValue;
118         this.minOutlier = minOutlier;
119         this.maxOutlier = maxOutlier;
120         this.outliers = outliers;
121         
122     }
123
124     /**
125      * Returns the mean.
126      *
127      * @return The mean (possibly <code>null</code>).
128      */

129     public Number JavaDoc getMean() {
130         return this.mean;
131     }
132     
133     /**
134      * Returns the median.
135      *
136      * @return The median (possibly <code>null</code>).
137      */

138     public Number JavaDoc getMedian() {
139         return this.median;
140     }
141     
142     /**
143      * Returns the first quartile.
144      *
145      * @return The first quartile (possibly <code>null</code>).
146      */

147     public Number JavaDoc getQ1() {
148         return this.q1;
149     }
150     
151     /**
152      * Returns the third quartile.
153      *
154      * @return The third quartile (possibly <code>null</code>).
155      */

156     public Number JavaDoc getQ3() {
157         return this.q3;
158     }
159     
160     /**
161      * Returns the minimum regular value.
162      *
163      * @return The minimum regular value (possibly <code>null</code>).
164      */

165     public Number JavaDoc getMinRegularValue() {
166         return this.minRegularValue;
167     }
168     
169     /**
170      * Returns the maximum regular value.
171      *
172      * @return The maximum regular value (possibly <code>null</code>).
173      */

174     public Number JavaDoc getMaxRegularValue() {
175         return this.maxRegularValue;
176     }
177     
178     /**
179      * Returns the minimum outlier.
180      *
181      * @return The minimum outlier (possibly <code>null</code>).
182      */

183     public Number JavaDoc getMinOutlier() {
184         return this.minOutlier;
185     }
186     
187     /**
188      * Returns the maximum outlier.
189      *
190      * @return The maximum outlier (possibly <code>null</code>).
191      */

192     public Number JavaDoc getMaxOutlier() {
193         return this.maxOutlier;
194     }
195     
196     /**
197      * Returns a list of outliers.
198      *
199      * @return A list of outliers (possibly <code>null</code>).
200      */

201     public List JavaDoc getOutliers() {
202         return Collections.unmodifiableList(this.outliers);
203     }
204     
205     /**
206      * Tests this object for equality with an arbitrary object.
207      *
208      * @param obj the object to test against (<code>null</code> permitted).
209      *
210      * @return A boolean.
211      */

212     public boolean equals(Object JavaDoc obj) {
213         
214         if (obj == this) {
215             return true;
216         }
217         if (!(obj instanceof BoxAndWhiskerItem)) {
218             return false;
219         }
220         BoxAndWhiskerItem that = (BoxAndWhiskerItem) obj;
221         if (!ObjectUtilities.equal(this.mean, that.mean)) {
222             return false;
223         }
224         if (!ObjectUtilities.equal(this.median, that.median)) {
225             return false;
226         }
227         if (!ObjectUtilities.equal(this.q1, that.q1)) {
228             return false;
229         }
230         if (!ObjectUtilities.equal(this.q3, that.q3)) {
231             return false;
232         }
233         if (!ObjectUtilities.equal(
234             this.minRegularValue, that.minRegularValue
235         )) {
236             return false;
237         }
238         if (!ObjectUtilities.equal(
239             this.maxRegularValue, that.maxRegularValue
240         )) {
241             return false;
242         }
243         if (!ObjectUtilities.equal(this.minOutlier, that.minOutlier)) {
244             return false;
245         }
246         if (!ObjectUtilities.equal(this.maxOutlier, that.maxOutlier)) {
247             return false;
248         }
249         if (!ObjectUtilities.equal(this.outliers, that.outliers)) {
250             return false;
251         }
252         return true;
253     }
254     
255 }
256
Popular Tags