    001    /* ===========================================================
    002     * JFreeChart : a free chart library for the Java(tm) platform
    003     * ===========================================================
    004     *
    005     * (C) Copyright 2000-2005, 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     * ChartChangeEvent.java
    029     * ---------------------
    030     * (C) Copyright 2000-2005, by Object Refinery Limited.
    031     *
    032     * Original Author:  David Gilbert (for Object Refinery Limited);
    033     * Contributor(s):   -;
    034     *
    035     * $Id: ChartChangeEvent.java,v 1.3.2.1 2005/10/25 20:42:25 mungady Exp $
    036     *
    037     * Changes (from 24-Aug-2001)
    038     * --------------------------
    039     * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG);
    040     * 07-Nov-2001 : Updated header (DG);
    041     *               Change event type names (DG);
    042     * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG);
    043     * 18-Feb-2005 : Changed the type from int to ChartChangeEventType (DG);
    044     *
    045     */
    046
    047    package org.jfree.chart.event;
    048
    049    import java.util.EventObject;
    050
    051    import org.jfree.chart.JFreeChart;
    052
    053    /**
    054     * A change event that encapsulates information about a change to a chart.
    055     */
    056    public class ChartChangeEvent extends EventObject {
    057
    058        /** The type of event. */
    059        private ChartChangeEventType type;
    060
    061        /** The chart that generated the event. */
    062        private JFreeChart chart;
    063
    064        /**
    065         * Creates a new chart change event.
    066         *
    067         * @param source  the source of the event (could be the chart, a title,
    068         *                an axis etc.)
    069         */
    070        public ChartChangeEvent(Object source) {
    071            this(source, null, ChartChangeEventType.GENERAL);
    072        }
    073
    074        /**
    075         * Creates a new chart change event.
    076         *
    077         * @param source  the source of the event (could be the chart, a title, an
    078         *                axis etc.)
    079         * @param chart  the chart that generated the event.
    080         */
    081        public ChartChangeEvent(Object source, JFreeChart chart) {
    082            this(source, chart, ChartChangeEventType.GENERAL);
    083        }
    084
    085        /**
    086         * Creates a new chart change event.
    087         *
    088         * @param source  the source of the event (could be the chart, a title, an
    089                          axis etc.)
    090         * @param chart  the chart that generated the event.
    091         * @param type  the type of event.
    092         */
    093        public ChartChangeEvent(Object source, JFreeChart chart,
    094                                ChartChangeEventType type) {
    095            super(source);
    096            this.chart = chart;
    097            this.type = type;
    098        }
    099
    100        /**
    101         * Returns the chart that generated the change event.
    102         *
    103         * @return The chart that generated the change event.
    104         */
    105        public JFreeChart getChart() {
    106            return this.chart;
    107        }
    108
    109        /**
    110         * Sets the chart that generated the change event.
    111         *
    112         * @param chart  the chart that generated the event.
    113         */
    114        public void setChart(JFreeChart chart) {
    115            this.chart = chart;
    116        }
    117
    118        /**
    119         * Returns the event type.
    120         *
    121         * @return The event type.
    122         */
    123        public ChartChangeEventType getType() {
    124            return this.type;
    125        }
    126
    127        /**
    128         * Sets the event type.
    129         *
    130         * @param type  the event type.
    131         */
    132        public void setType(ChartChangeEventType type) {
    133            this.type = type;
    134        }
    135
    136    }