KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > data > HistogramBin


1 /* ======================================
2  * JFreeChart : a free Java chart library
3  * ======================================
4  *
5  * Project Info: http://www.jfree.org/jfreechart/index.html
6  * Project Lead: David Gilbert (david.gilbert@object-refinery.com);
7  *
8  * (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
9  *
10  * This library is free software; you can redistribute it and/or modify it under the terms
11  * of the GNU Lesser General Public License as published by the Free Software Foundation;
12  * either version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License along with this
19  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  * -----------------
23  * HistogramBin.java
24  * -----------------
25  * (C) Copyright 2003, by Jelai Wang and Contributors.
26  *
27  * Original Author: Jelai Wang (jelaiw AT mindspring.com);
28  * Contributor(s): David Gilbert (for Object Refinery Limited);
29  *
30  * $Id: HistogramBin.java,v 1.2 2003/09/03 15:08:51 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 06-Jul-2003 : Version 1, contributed by Jelai Wang (DG);
35  * 07-Jul-2003 : Changed package and added Javadocs (DG);
36  *
37  */

38
39 package org.jfree.data;
40
41 /**
42  * A bin for the {@link HistogramDataset} class.
43  *
44  * @author Jelai Wang, jelaiw AT mindspring.com
45  */

46 class HistogramBin {
47     
48     /** The number of items in the bin. */
49     private int count = 0;
50     
51     /** The start boundary. */
52     private double startBoundary;
53     
54     /** The end boundary. */
55     private double endBoundary;
56
57     /**
58      * Creates a new bin.
59      *
60      * @param startBoundary the start boundary.
61      * @param endBoundary the end boundary.
62      */

63     HistogramBin(double startBoundary, double endBoundary) {
64         if (startBoundary > endBoundary) {
65             throw new IllegalArgumentException JavaDoc(
66                 "HistogramBin(...): startBoundary > endBoundary."
67             );
68         }
69         this.startBoundary = startBoundary;
70         this.endBoundary = endBoundary;
71     }
72
73     /**
74      * Returns the number of items in the bin.
75      *
76      * @return The item count.
77      */

78     public int getCount() {
79         return count;
80     }
81     
82     /**
83      * Increments the item count.
84      */

85     public void incrementCount() {
86         count++;
87     }
88     
89     /**
90      * Returns the start boundary.
91      *
92      * @return The start boundary.
93      */

94     public double getStartBoundary() {
95         return startBoundary;
96     }
97     
98     /**
99      * Returns the end boundary.
100      *
101      * @return The end boundary.
102      */

103     public double getEndBoundary() {
104         return endBoundary;
105     }
106     
107     /**
108      * Returns the bin width.
109      *
110      * @return The bin width.
111      */

112     public double getBinWidth() {
113         return endBoundary - startBoundary;
114     }
115     
116 }
117
Popular Tags