KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > entity > CategoryItemEntity


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  * CategoryItemEntity.java
28  * -----------------------
29  * (C) Copyright 2002-2005, by Object Refinery Limited and Contributors.
30  *
31  * Original Author: David Gilbert (for Object Refinery Limited);
32  * Contributor(s): Richard Atkinson;
33  * Christian W. Zuckschwerdt;
34  *
35  * $Id: CategoryItemEntity.java,v 1.5 2005/05/19 15:42:54 mungady Exp $
36  *
37  * Changes:
38  * --------
39  * 23-May-2002 : Version 1 (DG);
40  * 12-Jun-2002 : Added Javadoc comments (DG);
41  * 26-Jun-2002 : Added getImageMapAreaTag() method (DG);
42  * 05-Aug-2002 : Added new constructor to populate URLText
43  * Moved getImageMapAreaTag() to ChartEntity (superclass) (RA);
44  * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG);
45  * 30-Jul-2003 : Added CategoryDataset reference (CZ);
46  * 20-May-2004 : Added equals() and clone() methods, and implemented
47  * Serializable (DG);
48  * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG);
49  *
50  */

51
52 package org.jfree.chart.entity;
53
54 import java.awt.Shape JavaDoc;
55 import java.io.Serializable JavaDoc;
56
57 import org.jfree.data.category.CategoryDataset;
58 import org.jfree.util.ObjectUtilities;
59
60 /**
61  * A chart entity that represents one item within a category plot.
62  */

63 public class CategoryItemEntity extends ChartEntity
64                                 implements Cloneable JavaDoc, Serializable JavaDoc {
65
66     /** For serialization. */
67     private static final long serialVersionUID = -8657249457902337349L;
68     
69     /** The dataset. */
70     private transient CategoryDataset dataset;
71     
72     /** The series (zero-based index). */
73     private int series;
74
75     /** The category. */
76     private Object JavaDoc category;
77
78     /** The category index. */
79     private int categoryIndex;
80
81     /**
82      * Creates a new category item entity.
83      *
84      * @param area the area.
85      * @param toolTipText the tool tip text.
86      * @param urlText the URL text for HTML image maps.
87      * @param dataset the dataset.
88      * @param series the series (zero-based index).
89      * @param category the category.
90      * @param categoryIndex the category index.
91      */

92     public CategoryItemEntity(Shape JavaDoc area, String JavaDoc toolTipText, String JavaDoc urlText,
93                               CategoryDataset dataset,
94                               int series, Object JavaDoc category, int categoryIndex) {
95
96         super(area, toolTipText, urlText);
97         this.dataset = dataset;
98         this.series = series;
99         this.category = category;
100         this.categoryIndex = categoryIndex;
101
102     }
103
104     /**
105      * Returns the datset this entity refers to.
106      *
107      * @return The dataset (possibly <code>null</code>).
108      */

109     public CategoryDataset getDataset() {
110         return this.dataset;
111     }
112
113     /**
114      * Sets the datset this entity refers to.
115      *
116      * @param dataset the dataset (<code>null</code> permited).
117      */

118     public void setDataset(CategoryDataset dataset) {
119         this.dataset = dataset;
120     }
121
122     /**
123      * Returns the series index.
124      *
125      * @return The series index.
126      */

127     public int getSeries() {
128         return this.series;
129     }
130
131     /**
132      * Sets the series index.
133      *
134      * @param series the series index (zero-based).
135      */

136     public void setSeries(int series) {
137         this.series = series;
138     }
139
140     /**
141      * Returns the category.
142      *
143      * @return The category (possibly <code>null</code>).
144      */

145     public Object JavaDoc getCategory() {
146         return this.category;
147     }
148
149     /**
150      * Sets the category.
151      *
152      * @param category the category (<code>null</code> permitted).
153      */

154     public void setCategory(Object JavaDoc category) {
155         this.category = category;
156     }
157
158     /**
159      * Returns the category index.
160      *
161      * @return The index.
162      */

163     public int getCategoryIndex() {
164         return this.categoryIndex;
165     }
166
167     /**
168      * Sets the category index.
169      *
170      * @param index the category index.
171      */

172     public void setCategoryIndex(int index) {
173         this.categoryIndex = index;
174     }
175
176     /**
177      * Returns a string representing this object (useful for debugging
178      * purposes).
179      *
180      * @return A string.
181      */

182     public String JavaDoc toString() {
183         return "Category Item: series=" + this.series
184                + ", category=" + this.category.toString();
185     }
186
187     /**
188      * Tests the entity for equality with an arbitrary object.
189      *
190      * @param obj the object (<code>null</code> permitted).
191      *
192      * @return A boolean.
193      */

194     public boolean equals(Object JavaDoc obj) {
195         if (obj == this) {
196             return true;
197         }
198         if (obj instanceof CategoryItemEntity && super.equals(obj)) {
199             CategoryItemEntity cie = (CategoryItemEntity) obj;
200             if (this.categoryIndex != cie.categoryIndex) {
201                 return false;
202             }
203             if (this.series != cie.series) {
204                 return false;
205             }
206             if (!ObjectUtilities.equal(this.category, cie.category)) {
207                 return false;
208             }
209             return true;
210         }
211         return false;
212     }
213
214 }
215
Popular Tags