    001    /* ===========================================================
    002     * JFreeChart : a free chart library for the Java(tm) platform
    003     * ===========================================================
    004     *
    005     * (C) Copyright 2000-2008, 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     * PiePlotState.java
    029     * -----------------
    030     * (C) Copyright 2004-2008, by Object Refinery Limited.
    031     *
    032     * Original Author:  David Gilbert (for Object Refinery Limited);
    033     * Contributor(s):   -;
    034     *
    035     * Changes
    036     * -------
    037     * 06-Mar-2004 : Version 1 (DG);
    038     *
    039     */
    040
    041    package org.jfree.chart.plot;
    042
    043    import java.awt.geom.Rectangle2D;
    044
    045    import org.jfree.chart.renderer.RendererState;
    046
    047    /**
    048     * A renderer state.
    049     */
    050    public class PiePlotState extends RendererState {
    051
    052        /** The number of passes required by the renderer. */
    053        private int passesRequired;
    054
    055        /** The total of the values in the dataset. */
    056        private double total;
    057
    058        /** The latest angle. */
    059        private double latestAngle;
    060
    061        /** The exploded pie area. */
    062        private Rectangle2D explodedPieArea;
    063
    064        /** The pie area. */
    065        private Rectangle2D pieArea;
    066
    067        /** The center of the pie in Java 2D coordinates. */
    068        private double pieCenterX;
    069
    070        /** The center of the pie in Java 2D coordinates. */
    071        private double pieCenterY;
    072
    073        /** The vertical pie radius. */
    074        private double pieHRadius;
    075
    076        /** The horizontal pie radius. */
    077        private double pieWRadius;
    078
    079        /** The link area. */
    080        private Rectangle2D linkArea;
    081
    082        /**
    083         * Creates a new object for recording temporary state information for a
    084         * renderer.
    085         *
    086         * @param info  the plot rendering info.
    087         */
    088        public PiePlotState(PlotRenderingInfo info) {
    089            super(info);
    090            this.passesRequired = 1;
    091            this.total = 0.0;
    092        }
    093
    094        /**
    095         * Returns the number of passes required by the renderer.
    096         *
    097         * @return The number of passes.
    098         */
    099        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    }