    001/* ===========================================================
    002 * JFreeChart : a free chart library for the Java(tm) platform
    003 * ===========================================================
    004 *
    005 * (C) Copyright 2000-2011, 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 * [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 * ChartProgressEvent.java
    029 * -----------------------
    030 * (C) Copyright 2003-2010, by Object Refinery Limited.
    031 *
    032 * Original Author:  David Gilbert (for Object Refinery Limited);
    033 * Contributor(s):   -;
    034 *
    035 * Changes
    036 * -------
    037 * 14-Jan-2003 : Version 1 (DG);
    038 * 20-Jan-2010 : Fixed bug in constructor (DG);
    039 *
    040 */
    041
    042package org.jfree.chart.event;
    043
    044import org.jfree.chart.JFreeChart;
    045
    046/**
    047 * An event that contains information about the drawing progress of a chart.
    048 */
    049public class ChartProgressEvent extends java.util.EventObject {
    050
    051    /** Indicates drawing has started. */
    052    public static final int DRAWING_STARTED = 1;
    053
    054    /** Indicates drawing has finished. */
    055    public static final int DRAWING_FINISHED = 2;
    056
    057    /** The type of event. */
    058    private int type;
    059
    060    /** The percentage of completion. */
    061    private int percent;
    062
    063    /** The chart that generated the event. */
    064    private JFreeChart chart;
    065
    066    /**
    067     * Creates a new chart change event.
    068     *
    069     * @param source  the source of the event (could be the chart, a title, an
    070     *                axis etc.)
    071     * @param chart  the chart that generated the event.
    072     * @param type  the type of event.
    073     * @param percent  the percentage of completion.
    074     */
    075    public ChartProgressEvent(Object source, JFreeChart chart, int type,
    076                              int percent) {
    077        super(source);
    078        this.chart = chart;
    079        this.type = type;
    080        this.percent = percent;
    081    }
    082
    083    /**
    084     * Returns the chart that generated the change event.
    085     *
    086     * @return The chart that generated the change event.
    087     */
    088    public JFreeChart getChart() {
    089        return this.chart;
    090    }
    091
    092    /**
    093     * Sets the chart that generated the change event.
    094     *
    095     * @param chart  the chart that generated the event.
    096     */
    097    public void setChart(JFreeChart chart) {
    098        this.chart = chart;
    099    }
    100
    101    /**
    102     * Returns the event type.
    103     *
    104     * @return The event type.
    105     */
    106    public int getType() {
    107        return this.type;
    108    }
    109
    110    /**
    111     * Sets the event type.
    112     *
    113     * @param type  the event type.
    114     */
    115    public void setType(int type) {
    116        this.type = type;
    117    }
    118
    119    /**
    120     * Returns the percentage complete.
    121     *
    122     * @return The percentage complete.
    123     */
    124    public int getPercent() {
    125        return this.percent;
    126    }
    127
    128    /**
    129     * Sets the percentage complete.
    130     *
    131     * @param percent  the percentage.
    132     */
    133    public void setPercent(int percent) {
    134        this.percent = percent;
    135    }
    136
    137}