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.4 2005/02/09 13:56:14 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. package org.jfree.data.statistics;
  43. import java.io.Serializable;
  44. import java.util.Collections;
  45. import java.util.List;
  46. import org.jfree.util.ObjectUtilities;
  47. /**
  48. * Represents one data item within a box-and-whisker dataset. This class is
  49. * immutable.
  50. */
  51. public class BoxAndWhiskerItem implements Serializable {
  52. /** The mean. */
  53. private Number mean;
  54. /** The median. */
  55. private Number median;
  56. /** The first quarter. */
  57. private Number q1;
  58. /** The third quarter. */
  59. private Number q3;
  60. /** The minimum regular value. */
  61. private Number minRegularValue;
  62. /** The maximum regular value. */
  63. private Number maxRegularValue;
  64. /** The minimum outlier. */
  65. private Number minOutlier;
  66. /** The maximum outlier. */
  67. private Number maxOutlier;
  68. /** The outliers. */
  69. private List outliers;
  70. /**
  71. * Creates a new box-and-whisker item.
  72. *
  73. * @param mean the mean (<code>null</code> permitted).
  74. * @param median the median (<code>null</code> permitted).
  75. * @param q1 the first quartile (<code>null</code> permitted).
  76. * @param q3 the third quartile (<code>null</code> permitted).
  77. * @param minRegularValue the minimum regular value (<code>null</code>
  78. * permitted).
  79. * @param maxRegularValue the maximum regular value (<code>null</code>
  80. * permitted).
  81. * @param minOutlier the minimum outlier (<code>null</code> permitted).
  82. * @param maxOutlier the maximum outlier (<code>null</code> permitted).
  83. * @param outliers the outliers (<code>null</code> permitted).
  84. */
  85. public BoxAndWhiskerItem(Number mean,
  86. Number median,
  87. Number q1,
  88. Number q3,
  89. Number minRegularValue,
  90. Number maxRegularValue,
  91. Number minOutlier,
  92. Number maxOutlier,
  93. List outliers) {
  94. this.mean = mean;
  95. this.median = median;
  96. this.q1 = q1;
  97. this.q3 = q3;
  98. this.minRegularValue = minRegularValue;
  99. this.maxRegularValue = maxRegularValue;
  100. this.minOutlier = minOutlier;
  101. this.maxOutlier = maxOutlier;
  102. this.outliers = outliers;
  103. }
  104. /**
  105. * Returns the mean.
  106. *
  107. * @return The mean (possibly <code>null</code>).
  108. */
  109. public Number getMean() {
  110. return this.mean;
  111. }
  112. /**
  113. * Returns the median.
  114. *
  115. * @return The median (possibly <code>null</code>).
  116. */
  117. public Number getMedian() {
  118. return this.median;
  119. }
  120. /**
  121. * Returns the first quartile.
  122. *
  123. * @return The first quartile (possibly <code>null</code>).
  124. */
  125. public Number getQ1() {
  126. return this.q1;
  127. }
  128. /**
  129. * Returns the third quartile.
  130. *
  131. * @return The third quartile (possibly <code>null</code>).
  132. */
  133. public Number getQ3() {
  134. return this.q3;
  135. }
  136. /**
  137. * Returns the minimum regular value.
  138. *
  139. * @return The minimum regular value (possibly <code>null</code>).
  140. */
  141. public Number getMinRegularValue() {
  142. return this.minRegularValue;
  143. }
  144. /**
  145. * Returns the maximum regular value.
  146. *
  147. * @return The maximum regular value (possibly <code>null</code>).
  148. */
  149. public Number getMaxRegularValue() {
  150. return this.maxRegularValue;
  151. }
  152. /**
  153. * Returns the minimum outlier.
  154. *
  155. * @return The minimum outlier (possibly <code>null</code>).
  156. */
  157. public Number getMinOutlier() {
  158. return this.minOutlier;
  159. }
  160. /**
  161. * Returns the maximum outlier.
  162. *
  163. * @return The maximum outlier (possibly <code>null</code>).
  164. */
  165. public Number getMaxOutlier() {
  166. return this.maxOutlier;
  167. }
  168. /**
  169. * Returns a list of outliers.
  170. *
  171. * @return A list of outliers (possibly <code>null</code>).
  172. */
  173. public List getOutliers() {
  174. return Collections.unmodifiableList(this.outliers);
  175. }
  176. /**
  177. * Tests this object for equality with an arbitrary object.
  178. *
  179. * @param obj the object to test against (<code>null</code> permitted).
  180. *
  181. * @return A boolean.
  182. */
  183. public boolean equals(Object obj) {
  184. if (obj == this) {
  185. return true;
  186. }
  187. if (!(obj instanceof BoxAndWhiskerItem)) {
  188. return false;
  189. }
  190. BoxAndWhiskerItem that = (BoxAndWhiskerItem) obj;
  191. if (!ObjectUtilities.equal(this.mean, that.mean)) {
  192. return false;
  193. }
  194. if (!ObjectUtilities.equal(this.median, that.median)) {
  195. return false;
  196. }
  197. if (!ObjectUtilities.equal(this.q1, that.q1)) {
  198. return false;
  199. }
  200. if (!ObjectUtilities.equal(this.q3, that.q3)) {
  201. return false;
  202. }
  203. if (!ObjectUtilities.equal(
  204. this.minRegularValue, that.minRegularValue
  205. )) {
  206. return false;
  207. }
  208. if (!ObjectUtilities.equal(
  209. this.maxRegularValue, that.maxRegularValue
  210. )) {
  211. return false;
  212. }
  213. if (!ObjectUtilities.equal(this.minOutlier, that.minOutlier)) {
  214. return false;
  215. }
  216. if (!ObjectUtilities.equal(this.maxOutlier, that.maxOutlier)) {
  217. return false;
  218. }
  219. if (!ObjectUtilities.equal(this.outliers, that.outliers)) {
  220. return false;
  221. }
  222. return true;
  223. }
  224. }