Frames | No Frames |
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 20: * License along with this library; if not, write to the Free Software 21: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 22: * USA. 23: * 24: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 25: * in the United States and other countries.] 26: * 27: * --------------------- 28: * PieSectionEntity.java 29: * --------------------- 30: * (C) Copyright 2002-2005, by Object Refinery Limited. 31: * 32: * Original Author: David Gilbert (for Object Refinery Limited); 33: * Contributor(s): Richard Atkinson; 34: * Christian W. Zuckschwerdt; 35: * 36: * $Id: PieSectionEntity.java,v 1.5.2.1 2005/10/25 20:41:59 mungady Exp $ 37: * 38: * Changes: 39: * -------- 40: * 23-May-2002 : Version 1 (DG); 41: * 12-Jun-2002 : Added Javadoc comments (DG); 42: * 26-Jun-2002 : Added method to generate AREA tag for image map 43: * generation (DG); 44: * 05-Aug-2002 : Added new constructor to populate URLText 45: * Moved getImageMapAreaTag() to ChartEntity (superclass) (RA); 46: * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); 47: * 07-Mar-2003 : Added pie index attribute, since the PiePlot class can create 48: * multiple pie plots within one chart. Also renamed 'category' 49: * --> 'sectionKey' and changed the class from Object --> 50: * Comparable (DG); 51: * 30-Jul-2003 : Added PieDataset reference (CZ); 52: * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); 53: * 54: */ 55: 56: package org.jfree.chart.entity; 57: 58: import java.awt.Shape; 59: import java.io.Serializable; 60: 61: import org.jfree.data.general.PieDataset; 62: 63: /** 64: * A chart entity that represents one section within a pie plot. 65: */ 66: public class PieSectionEntity extends ChartEntity 67: implements Serializable { 68: 69: /** For serialization. */ 70: private static final long serialVersionUID = 9199892576531984162L; 71: 72: /** The dataset. */ 73: private PieDataset dataset; 74: 75: /** The pie index. */ 76: private int pieIndex; 77: 78: /** The section index. */ 79: private int sectionIndex; 80: 81: /** The section key. */ 82: private Comparable sectionKey; 83: 84: /** 85: * Creates a new pie section entity. 86: * 87: * @param area the area. 88: * @param dataset the pie dataset. 89: * @param pieIndex the pie index (zero-based). 90: * @param sectionIndex the section index (zero-based). 91: * @param sectionKey the section key. 92: * @param toolTipText the tool tip text. 93: * @param urlText the URL text for HTML image maps. 94: */ 95: public PieSectionEntity(Shape area, 96: PieDataset dataset, 97: int pieIndex, int sectionIndex, 98: Comparable sectionKey, 99: String toolTipText, String urlText) { 100: 101: super(area, toolTipText, urlText); 102: this.dataset = dataset; 103: this.pieIndex = pieIndex; 104: this.sectionIndex = sectionIndex; 105: this.sectionKey = sectionKey; 106: 107: } 108: 109: /** 110: * Returns the datset this entity refers to. 111: * 112: * @return The dataset. 113: */ 114: public PieDataset getDataset() { 115: return this.dataset; 116: } 117: 118: /** 119: * Sets the datset this entity refers to. 120: * 121: * @param dataset the dataset. 122: */ 123: public void setDataset(PieDataset dataset) { 124: this.dataset = dataset; 125: } 126: 127: /** 128: * Returns the pie index. For a regular pie chart, the section index is 0. 129: * For a pie chart containing multiple pie plots, the pie index is the row 130: * or column index from which the pie data is extracted. 131: * 132: * @return The pie index. 133: */ 134: public int getPieIndex() { 135: return this.pieIndex; 136: } 137: 138: /** 139: * Sets the pie index. 140: * 141: * @param index the new index value. 142: */ 143: public void setPieIndex(int index) { 144: this.pieIndex = index; 145: } 146: 147: /** 148: * Returns the section index. 149: * 150: * @return The section index. 151: */ 152: public int getSectionIndex() { 153: return this.sectionIndex; 154: } 155: 156: /** 157: * Sets the section index. 158: * 159: * @param index the section index. 160: */ 161: public void setSectionIndex(int index) { 162: this.sectionIndex = index; 163: } 164: 165: /** 166: * Returns the section key. 167: * 168: * @return The section key. 169: */ 170: public Comparable getSectionKey() { 171: return this.sectionKey; 172: } 173: 174: /** 175: * Sets the section key. 176: * 177: * @param key the section key. 178: */ 179: public void setSectionKey(Comparable key) { 180: this.sectionKey = key; 181: } 182: 183: /** 184: * Returns a string representing the entity. 185: * 186: * @return A string representing the entity. 187: */ 188: public String toString() { 189: return "PieSection: " + this.pieIndex + ", " + this.sectionIndex + "(" 190: + this.sectionKey.toString() + ")"; 191: } 192: 193: }