001/* ===========================================================
002 * JFreeChart : a free chart library for the Java(tm) platform
003 * ===========================================================
004 *
005 * (C) Copyright 2000-present, by David Gilbert 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 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 
025 * Other names may be trademarks of their respective owners.]
026 *
027 * -----------------
028 * PiePlotState.java
029 * -----------------
030 * (C) Copyright 2004-present, by David Gilbert.
031 *
032 * Original Author:  David Gilbert;
033 * Contributor(s):   -;
034 *
035 */
036
037package org.jfree.chart.plot;
038
039import java.awt.geom.Rectangle2D;
040
041import org.jfree.chart.renderer.RendererState;
042
043/**
044 * A renderer state.
045 */
046public class PiePlotState extends RendererState {
047
048    /** The number of passes required by the renderer. */
049    private int passesRequired;
050
051    /** The total of the values in the dataset. */
052    private double total;
053
054    /** The latest angle. */
055    private double latestAngle;
056
057    /** The exploded pie area. */
058    private Rectangle2D explodedPieArea;
059
060    /** The pie area. */
061    private Rectangle2D pieArea;
062
063    /** The center of the pie in Java 2D coordinates. */
064    private double pieCenterX;
065
066    /** The center of the pie in Java 2D coordinates. */
067    private double pieCenterY;
068
069    /** The vertical pie radius. */
070    private double pieHRadius;
071
072    /** The horizontal pie radius. */
073    private double pieWRadius;
074
075    /** The link area. */
076    private Rectangle2D linkArea;
077
078    /**
079     * Creates a new object for recording temporary state information for a
080     * renderer.
081     *
082     * @param info  the plot rendering info.
083     */
084    public PiePlotState(PlotRenderingInfo info) {
085        super(info);
086        this.passesRequired = 1;
087        this.total = 0.0;
088    }
089
090    /**
091     * Returns the number of passes required by the renderer.
092     *
093     * @return The number of passes.
094     */
095    public int getPassesRequired() {
096        return this.passesRequired;
097    }
098
099    /**
100     * Sets the number of passes required by the renderer.
101     *
102     * @param passes  the passes.
103     */
104    public void setPassesRequired(int passes) {
105        this.passesRequired = passes;
106    }
107
108    /**
109     * Returns the total of the values in the dataset.
110     *
111     * @return The total.
112     */
113    public double getTotal() {
114        return this.total;
115    }
116
117    /**
118     * Sets the total.
119     *
120     * @param total  the total.
121     */
122    public void setTotal(double total) {
123        this.total = total;
124    }
125
126    /**
127     * Returns the latest angle.
128     *
129     * @return The latest angle.
130     */
131    public double getLatestAngle() {
132        return this.latestAngle;
133    }
134
135    /**
136     * Sets the latest angle.
137     *
138     * @param angle  the angle.
139     */
140    public void setLatestAngle(double angle) {
141        this.latestAngle = angle;
142    }
143
144    /**
145     * Returns the pie area.
146     *
147     * @return The pie area.
148     */
149    public Rectangle2D getPieArea() {
150        return this.pieArea;
151    }
152
153    /**
154     * Sets the pie area.
155     *
156     * @param area  the area.
157     */
158    public void setPieArea(Rectangle2D area) {
159       this.pieArea = area;
160    }
161
162    /**
163     * Returns the exploded pie area.
164     *
165     * @return The exploded pie area.
166     */
167    public Rectangle2D getExplodedPieArea() {
168        return this.explodedPieArea;
169    }
170
171    /**
172     * Sets the exploded pie area.
173     *
174     * @param area  the area.
175     */
176    public void setExplodedPieArea(Rectangle2D area) {
177        this.explodedPieArea = area;
178    }
179
180    /**
181     * Returns the x-coordinate of the center of the pie chart.
182     *
183     * @return The x-coordinate (in Java2D space).
184     */
185    public double getPieCenterX() {
186        return this.pieCenterX;
187    }
188
189    /**
190     * Sets the x-coordinate of the center of the pie chart.
191     *
192     * @param x  the x-coordinate (in Java2D space).
193     */
194    public void setPieCenterX(double x) {
195        this.pieCenterX = x;
196    }
197
198    /**
199     * Returns the y-coordinate (in Java2D space) of the center of the pie
200     * chart.
201     *
202     * @return The y-coordinate (in Java2D space).
203     */
204    public double getPieCenterY() {
205        return this.pieCenterY;
206    }
207
208    /**
209     * Sets the y-coordinate of the center of the pie chart.  This method is
210     * used by the plot and typically is not called directly by applications.
211     *
212     * @param y  the y-coordinate (in Java2D space).
213     */
214    public void setPieCenterY(double y) {
215        this.pieCenterY = y;
216    }
217
218    /**
219     * Returns the link area.  This defines the "dog-leg" point for the label
220     * linking lines.
221     *
222     * @return The link area.
223     */
224    public Rectangle2D getLinkArea() {
225        return this.linkArea;
226    }
227
228    /**
229     * Sets the label link area.  This defines the "dog-leg" point for the
230     * label linking lines.
231     *
232     * @param area  the area.
233     */
234    public void setLinkArea(Rectangle2D area) {
235        this.linkArea = area;
236    }
237
238    /**
239     * Returns the vertical pie radius.
240     *
241     * @return The radius.
242     */
243    public double getPieHRadius() {
244        return this.pieHRadius;
245    }
246
247    /**
248     * Sets the vertical pie radius.
249     *
250     * @param radius  the radius.
251     */
252    public void setPieHRadius(double radius) {
253        this.pieHRadius = radius;
254    }
255
256    /**
257     * Returns the horizontal pie radius.
258     *
259     * @return The radius.
260     */
261    public double getPieWRadius() {
262        return this.pieWRadius;
263    }
264
265    /**
266     * Sets the horizontal pie radius.
267     *
268     * @param radius  the radius.
269     */
270    public void setPieWRadius(double radius) {
271        this.pieWRadius = radius;
272    }
273
274}