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