Frames | No Frames |
1: /* =========================================================== 2: * JFreeChart : a free chart library for the Java(tm) platform 3: * =========================================================== 4: * 5: * (C) Copyright 2000-2007, 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: * PiePlotState.java 29: * ----------------- 30: * (C) Copyright 2004, 2007, by Object Refinery Limited. 31: * 32: * Original Author: David Gilbert (for Object Refinery Limited); 33: * Contributor(s): -; 34: * 35: * Changes 36: * ------- 37: * 06-Mar-2004 : Version 1 (DG); 38: * 39: */ 40: 41: package org.jfree.chart.plot; 42: 43: import java.awt.geom.Rectangle2D; 44: 45: import org.jfree.chart.renderer.RendererState; 46: 47: /** 48: * A renderer state. 49: */ 50: public class PiePlotState extends RendererState { 51: 52: /** The number of passes required by the renderer. */ 53: private int passesRequired; 54: 55: /** The total of the values in the dataset. */ 56: private double total; 57: 58: /** The latest angle. */ 59: private double latestAngle; 60: 61: /** The exploded pie area. */ 62: private Rectangle2D explodedPieArea; 63: 64: /** The pie area. */ 65: private Rectangle2D pieArea; 66: 67: /** The center of the pie in Java 2D coordinates. */ 68: private double pieCenterX; 69: 70: /** The center of the pie in Java 2D coordinates. */ 71: private double pieCenterY; 72: 73: /** The vertical pie radius. */ 74: private double pieHRadius; 75: 76: /** The horizontal pie radius. */ 77: private double pieWRadius; 78: 79: /** The link area. */ 80: private Rectangle2D linkArea; 81: 82: /** 83: * Creates a new object for recording temporary state information for a 84: * renderer. 85: * 86: * @param info the plot rendering info. 87: */ 88: public PiePlotState(PlotRenderingInfo info) { 89: super(info); 90: this.passesRequired = 1; 91: this.total = 0.0; 92: } 93: 94: /** 95: * Returns the number of passes required by the renderer. 96: * 97: * @return The number of passes. 98: */ 99: public int getPassesRequired() { 100: return this.passesRequired; 101: } 102: 103: /** 104: * Sets the number of passes required by the renderer. 105: * 106: * @param passes the passes. 107: */ 108: public void setPassesRequired(int passes) { 109: this.passesRequired = passes; 110: } 111: 112: /** 113: * Returns the total of the values in the dataset. 114: * 115: * @return The total. 116: */ 117: public double getTotal() { 118: return this.total; 119: } 120: 121: /** 122: * Sets the total. 123: * 124: * @param total the total. 125: */ 126: public void setTotal(double total) { 127: this.total = total; 128: } 129: 130: /** 131: * Returns the latest angle. 132: * 133: * @return The latest angle. 134: */ 135: public double getLatestAngle() { 136: return this.latestAngle; 137: } 138: 139: /** 140: * Sets the latest angle. 141: * 142: * @param angle the angle. 143: */ 144: public void setLatestAngle(double angle) { 145: this.latestAngle = angle; 146: } 147: 148: /** 149: * Returns the pie area. 150: * 151: * @return The pie area. 152: */ 153: public Rectangle2D getPieArea() { 154: return this.pieArea; 155: } 156: 157: /** 158: * Sets the pie area. 159: * 160: * @param area the area. 161: */ 162: public void setPieArea(Rectangle2D area) { 163: this.pieArea = area; 164: } 165: 166: /** 167: * Returns the exploded pie area. 168: * 169: * @return The exploded pie area. 170: */ 171: public Rectangle2D getExplodedPieArea() { 172: return this.explodedPieArea; 173: } 174: 175: /** 176: * Sets the exploded pie area. 177: * 178: * @param area the area. 179: */ 180: public void setExplodedPieArea(Rectangle2D area) { 181: this.explodedPieArea = area; 182: } 183: 184: /** 185: * Returns the x-coordinate of the center of the pie chart. 186: * 187: * @return The x-coordinate (in Java2D space). 188: */ 189: public double getPieCenterX() { 190: return this.pieCenterX; 191: } 192: 193: /** 194: * Sets the x-coordinate of the center of the pie chart. 195: * 196: * @param x the x-coordinate (in Java2D space). 197: */ 198: public void setPieCenterX(double x) { 199: this.pieCenterX = x; 200: } 201: 202: /** 203: * Returns the y-coordinate (in Java2D space) of the center of the pie 204: * chart. For the {@link PiePlot3D} class, we derive this from the top of 205: * the pie. 206: * 207: * @return The y-coordinate (in Java2D space). 208: */ 209: public double getPieCenterY() { 210: return this.pieCenterY; 211: } 212: 213: /** 214: * Sets the y-coordinate of the center of the pie chart. This method is 215: * used by the plot and typically is not called directly by applications. 216: * 217: * @param y the y-coordinate (in Java2D space). 218: */ 219: public void setPieCenterY(double y) { 220: this.pieCenterY = y; 221: } 222: 223: /** 224: * Returns the link area. This defines the "dog-leg" point for the label 225: * linking lines. 226: * 227: * @return The link area. 228: */ 229: public Rectangle2D getLinkArea() { 230: return this.linkArea; 231: } 232: 233: /** 234: * Sets the label link area. This defines the "dog-leg" point for the 235: * label linking lines. 236: * 237: * @param area the area. 238: */ 239: public void setLinkArea(Rectangle2D area) { 240: this.linkArea = area; 241: } 242: 243: /** 244: * Returns the vertical pie radius. 245: * 246: * @return The radius. 247: */ 248: public double getPieHRadius() { 249: return this.pieHRadius; 250: } 251: 252: /** 253: * Sets the vertical pie radius. 254: * 255: * @param radius the radius. 256: */ 257: public void setPieHRadius(double radius) { 258: this.pieHRadius = radius; 259: } 260: 261: /** 262: * Returns the horizontal pie radius. 263: * 264: * @return The radius. 265: */ 266: public double getPieWRadius() { 267: return this.pieWRadius; 268: } 269: 270: /** 271: * Sets the horizontal pie radius. 272: * 273: * @param radius the radius. 274: */ 275: public void setPieWRadius(double radius) { 276: this.pieWRadius = radius; 277: } 278: 279: }