KickJava   Java API By Example, From Geeks To Geeks.

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


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  * PieSectionEntity.java
28  * ---------------------
29  * (C) Copyright 2002-2005, by Object Refinery Limited.
30  *
31  * Original Author: David Gilbert (for Object Refinery Limited);
32  * Contributor(s): Richard Atkinson;
33  * Christian W. Zuckschwerdt;
34  *
35  * $Id: PieSectionEntity.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 method to generate AREA tag for image map
42  * generation (DG);
43  * 05-Aug-2002 : Added new constructor to populate URLText
44  * Moved getImageMapAreaTag() to ChartEntity (superclass) (RA);
45  * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG);
46  * 07-Mar-2003 : Added pie index attribute, since the PiePlot class can create
47  * multiple pie plots within one chart. Also renamed 'category'
48  * --> 'sectionKey' and changed the class from Object -->
49  * Comparable (DG);
50  * 30-Jul-2003 : Added PieDataset reference (CZ);
51  * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG);
52  *
53  */

54
55 package org.jfree.chart.entity;
56
57 import java.awt.Shape JavaDoc;
58 import java.io.Serializable JavaDoc;
59
60 import org.jfree.data.general.PieDataset;
61
62 /**
63  * A chart entity that represents one section within a pie plot.
64  */

65 public class PieSectionEntity extends ChartEntity
66                               implements Serializable JavaDoc {
67
68     /** For serialization. */
69     private static final long serialVersionUID = 9199892576531984162L;
70     
71     /** The dataset. */
72     private PieDataset dataset;
73     
74     /** The pie index. */
75     private int pieIndex;
76
77     /** The section index. */
78     private int sectionIndex;
79
80     /** The section key. */
81     private Comparable JavaDoc sectionKey;
82
83     /**
84      * Creates a new pie section entity.
85      *
86      * @param area the area.
87      * @param dataset the pie dataset.
88      * @param pieIndex the pie index (zero-based).
89      * @param sectionIndex the section index (zero-based).
90      * @param sectionKey the section key.
91      * @param toolTipText the tool tip text.
92      * @param urlText the URL text for HTML image maps.
93      */

94     public PieSectionEntity(Shape JavaDoc area,
95                             PieDataset dataset,
96                             int pieIndex, int sectionIndex,
97                             Comparable JavaDoc sectionKey,
98                             String JavaDoc toolTipText, String JavaDoc urlText) {
99
100         super(area, toolTipText, urlText);
101         this.dataset = dataset;
102         this.pieIndex = pieIndex;
103         this.sectionIndex = sectionIndex;
104         this.sectionKey = sectionKey;
105
106     }
107
108     /**
109      * Returns the datset this entity refers to.
110      *
111      * @return The dataset.
112      */

113     public PieDataset getDataset() {
114         return this.dataset;
115     }
116
117     /**
118      * Sets the datset this entity refers to.
119      *
120      * @param dataset the dataset.
121      */

122     public void setDataset(PieDataset dataset) {
123         this.dataset = dataset;
124     }
125
126     /**
127      * Returns the pie index. For a regular pie chart, the section index is 0.
128      * For a pie chart containing multiple pie plots, the pie index is the row
129      * or column index from which the pie data is extracted.
130      *
131      * @return The pie index.
132      */

133     public int getPieIndex() {
134         return this.pieIndex;
135     }
136
137     /**
138      * Sets the pie index.
139      *
140      * @param index the new index value.
141      */

142     public void setPieIndex(int index) {
143         this.pieIndex = index;
144     }
145
146     /**
147      * Returns the section index.
148      *
149      * @return The section index.
150      */

151     public int getSectionIndex() {
152         return this.sectionIndex;
153     }
154
155     /**
156      * Sets the section index.
157      *
158      * @param index the section index.
159      */

160     public void setSectionIndex(int index) {
161         this.sectionIndex = index;
162     }
163
164     /**
165      * Returns the section key.
166      *
167      * @return The section key.
168      */

169     public Comparable JavaDoc getSectionKey() {
170         return this.sectionKey;
171     }
172
173     /**
174      * Sets the section key.
175      *
176      * @param key the section key.
177      */

178     public void setSectionKey(Comparable JavaDoc key) {
179         this.sectionKey = key;
180     }
181
182     /**
183      * Returns a string representing the entity.
184      *
185      * @return A string representing the entity.
186      */

187     public String JavaDoc toString() {
188         return "PieSection: " + this.pieIndex + ", " + this.sectionIndex + "("
189                               + this.sectionKey.toString() + ")";
190     }
191
192 }
193
Popular Tags