001: /* ===========================================================
002: * JFreeChart : a free chart library for the Java(tm) platform
003: * ===========================================================
004: *
005: * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
006: *
007: * Project Info: http://www.jfree.org/jfreechart/index.html
008: *
009: * This library is free software; you can redistribute it and/or modify it
010: * under the terms of the GNU Lesser General Public License as published by
011: * the Free Software Foundation; either version 2.1 of the License, or
012: * (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but
015: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017: * License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022: * USA.
023: *
024: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025: * in the United States and other countries.]
026: *
027: * ---------------------
028: * PieSectionEntity.java
029: * ---------------------
030: * (C) Copyright 2002-2007, by Object Refinery Limited.
031: *
032: * Original Author: David Gilbert (for Object Refinery Limited);
033: * Contributor(s): Richard Atkinson;
034: * Christian W. Zuckschwerdt;
035: *
036: * $Id: PieSectionEntity.java,v 1.5.2.2 2007/05/17 09:26:24 mungady Exp $
037: *
038: * Changes:
039: * --------
040: * 23-May-2002 : Version 1 (DG);
041: * 12-Jun-2002 : Added Javadoc comments (DG);
042: * 26-Jun-2002 : Added method to generate AREA tag for image map
043: * generation (DG);
044: * 05-Aug-2002 : Added new constructor to populate URLText
045: * Moved getImageMapAreaTag() to ChartEntity (superclass) (RA);
046: * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG);
047: * 07-Mar-2003 : Added pie index attribute, since the PiePlot class can create
048: * multiple pie plots within one chart. Also renamed 'category'
049: * --> 'sectionKey' and changed the class from Object -->
050: * Comparable (DG);
051: * 30-Jul-2003 : Added PieDataset reference (CZ);
052: * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG);
053: *
054: */
055:
056: package org.jfree.chart.entity;
057:
058: import java.awt.Shape;
059: import java.io.Serializable;
060:
061: import org.jfree.data.general.PieDataset;
062:
063: /**
064: * A chart entity that represents one section within a pie plot.
065: */
066: public class PieSectionEntity extends ChartEntity implements
067: Serializable {
068:
069: /** For serialization. */
070: private static final long serialVersionUID = 9199892576531984162L;
071:
072: /** The dataset. */
073: private PieDataset dataset;
074:
075: /** The pie index. */
076: private int pieIndex;
077:
078: /** The section index. */
079: private int sectionIndex;
080:
081: /** The section key. */
082: private Comparable sectionKey;
083:
084: /**
085: * Creates a new pie section entity.
086: *
087: * @param area the area.
088: * @param dataset the pie dataset.
089: * @param pieIndex the pie index (zero-based).
090: * @param sectionIndex the section index (zero-based).
091: * @param sectionKey the section key.
092: * @param toolTipText the tool tip text.
093: * @param urlText the URL text for HTML image maps.
094: */
095: public PieSectionEntity(Shape area, PieDataset dataset,
096: int pieIndex, int sectionIndex, Comparable sectionKey,
097: String toolTipText, String urlText) {
098:
099: super (area, toolTipText, urlText);
100: this .dataset = dataset;
101: this .pieIndex = pieIndex;
102: this .sectionIndex = sectionIndex;
103: this .sectionKey = sectionKey;
104:
105: }
106:
107: /**
108: * Returns the dataset this entity refers to.
109: *
110: * @return The dataset.
111: */
112: public PieDataset getDataset() {
113: return this .dataset;
114: }
115:
116: /**
117: * Sets the dataset this entity refers to.
118: *
119: * @param dataset the dataset.
120: */
121: public void setDataset(PieDataset dataset) {
122: this .dataset = dataset;
123: }
124:
125: /**
126: * Returns the pie index. For a regular pie chart, the section index is 0.
127: * For a pie chart containing multiple pie plots, the pie index is the row
128: * or column index from which the pie data is extracted.
129: *
130: * @return The pie index.
131: */
132: public int getPieIndex() {
133: return this .pieIndex;
134: }
135:
136: /**
137: * Sets the pie index.
138: *
139: * @param index the new index value.
140: */
141: public void setPieIndex(int index) {
142: this .pieIndex = index;
143: }
144:
145: /**
146: * Returns the section index.
147: *
148: * @return The section index.
149: */
150: public int getSectionIndex() {
151: return this .sectionIndex;
152: }
153:
154: /**
155: * Sets the section index.
156: *
157: * @param index the section index.
158: */
159: public void setSectionIndex(int index) {
160: this .sectionIndex = index;
161: }
162:
163: /**
164: * Returns the section key.
165: *
166: * @return The section key.
167: */
168: public Comparable getSectionKey() {
169: return this .sectionKey;
170: }
171:
172: /**
173: * Sets the section key.
174: *
175: * @param key the section key.
176: */
177: public void setSectionKey(Comparable key) {
178: this .sectionKey = key;
179: }
180:
181: /**
182: * Returns a string representing the entity.
183: *
184: * @return A string representing the entity.
185: */
186: public String toString() {
187: return "PieSection: " + this .pieIndex + ", "
188: + this .sectionIndex + "(" + this .sectionKey.toString()
189: + ")";
190: }
191:
192: }
|