1 44 45 package org.jfree.data.statistics; 46 47 import java.io.Serializable ; 48 49 54 public class HistogramBin implements Cloneable , Serializable { 55 56 57 private static final long serialVersionUID = 7614685080015589931L; 58 59 60 private int count; 61 62 63 private double startBoundary; 64 65 66 private double endBoundary; 67 68 74 public HistogramBin(double startBoundary, double endBoundary) { 75 if (startBoundary > endBoundary) { 76 throw new IllegalArgumentException ( 77 "HistogramBin(): startBoundary > endBoundary."); 78 } 79 this.count = 0; 80 this.startBoundary = startBoundary; 81 this.endBoundary = endBoundary; 82 } 83 84 89 public int getCount() { 90 return this.count; 91 } 92 93 96 public void incrementCount() { 97 this.count++; 98 } 99 100 105 public double getStartBoundary() { 106 return this.startBoundary; 107 } 108 109 114 public double getEndBoundary() { 115 return this.endBoundary; 116 } 117 118 123 public double getBinWidth() { 124 return this.endBoundary - this.startBoundary; 125 } 126 127 134 public boolean equals(Object obj) { 135 if (obj == null) { 136 return false; 137 } 138 if (obj == this) { 139 return true; 140 } 141 if (obj instanceof HistogramBin) { 142 HistogramBin bin = (HistogramBin) obj; 143 boolean b0 = bin.startBoundary == this.startBoundary; 144 boolean b1 = bin.endBoundary == this.endBoundary; 145 boolean b2 = bin.count == this.count; 146 return b0 && b1 && b2; 147 } 148 return false; 149 } 150 151 158 public Object clone() throws CloneNotSupportedException { 159 return super.clone(); 160 } 161 162 } 163 | Popular Tags |