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. * MeanAndStandardDeviation.java
  28. * -----------------------------
  29. * (C) Copyright 2003-2005, by Object Refinery Limited.
  30. *
  31. * Original Author: David Gilbert (for Object Refinery Limited);
  32. * Contributor(s): -;
  33. *
  34. * $Id: MeanAndStandardDeviation.java,v 1.2 2005/02/09 13:55:01 mungady Exp $
  35. *
  36. * Changes:
  37. * --------
  38. * 05-Feb-2002 : Version 1 (DG);
  39. * 05-Feb-2005 : Added equals() method and implemented Serializable (DG);
  40. *
  41. */
  42. package org.jfree.data.statistics;
  43. import java.io.Serializable;
  44. import org.jfree.util.ObjectUtilities;
  45. /**
  46. * A simple data structure that holds a mean value and a standard deviation
  47. * value. This is used in the
  48. * {@link org.jfree.data.statistics.DefaultStatisticalCategoryDataset} class.
  49. */
  50. public class MeanAndStandardDeviation implements Serializable {
  51. /** The mean. */
  52. private Number mean;
  53. /** The standard deviation. */
  54. private Number standardDeviation;
  55. /**
  56. * Creates a new mean and standard deviation record.
  57. *
  58. * @param mean the mean.
  59. * @param standardDeviation the standard deviation.
  60. */
  61. public MeanAndStandardDeviation(double mean, double standardDeviation) {
  62. this(new Double(mean), new Double(standardDeviation));
  63. }
  64. /**
  65. * Creates a new mean and standard deviation record.
  66. *
  67. * @param mean the mean (<code>null</code> permitted).
  68. * @param standardDeviation the standard deviation (<code>null</code>
  69. * permitted.
  70. */
  71. public MeanAndStandardDeviation(Number mean, Number standardDeviation) {
  72. this.mean = mean;
  73. this.standardDeviation = standardDeviation;
  74. }
  75. /**
  76. * Returns the mean.
  77. *
  78. * @return The mean.
  79. */
  80. public Number getMean() {
  81. return this.mean;
  82. }
  83. /**
  84. * Returns the standard deviation.
  85. *
  86. * @return The standard deviation.
  87. */
  88. public Number getStandardDeviation() {
  89. return this.standardDeviation;
  90. }
  91. /**
  92. * Tests this instance for equality with an arbitrary object.
  93. *
  94. * @param obj the object (<code>null</code> permitted).
  95. *
  96. * @return A boolean.
  97. */
  98. public boolean equals(Object obj) {
  99. if (obj == this) {
  100. return true;
  101. }
  102. if (!(obj instanceof MeanAndStandardDeviation)) {
  103. return false;
  104. }
  105. MeanAndStandardDeviation that = (MeanAndStandardDeviation) obj;
  106. if (!ObjectUtilities.equal(this.mean, that.mean)) {
  107. return false;
  108. }
  109. if (!ObjectUtilities.equal(
  110. this.standardDeviation, that.standardDeviation)
  111. ) {
  112. return false;
  113. }
  114. return true;
  115. }
  116. }