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 * ChartChangeEvent.java
029 * ---------------------
030 * (C) Copyright 2000-present, by David Gilbert.
031 *
032 * Original Author:  David Gilbert;
033 * Contributor(s):   -;
034 *
035 */
036
037package org.jfree.chart.event;
038
039import java.util.EventObject;
040
041import org.jfree.chart.JFreeChart;
042
043/**
044 * A change event that encapsulates information about a change to a chart.
045 */
046public class ChartChangeEvent extends EventObject {
047
048    /** The type of event. */
049    private ChartChangeEventType type;
050
051    /** The chart that generated the event. */
052    private JFreeChart chart;
053
054    /**
055     * Creates a new chart change event.
056     *
057     * @param source  the source of the event (could be the chart, a title,
058     *                an axis etc.)
059     */
060    public ChartChangeEvent(Object source) {
061        this(source, null, ChartChangeEventType.GENERAL);
062    }
063
064    /**
065     * Creates a new chart change event.
066     *
067     * @param source  the source of the event (could be the chart, a title, an
068     *                axis etc.)
069     * @param chart  the chart that generated the event.
070     */
071    public ChartChangeEvent(Object source, JFreeChart chart) {
072        this(source, chart, ChartChangeEventType.GENERAL);
073    }
074
075    /**
076     * Creates a new chart change event.
077     *
078     * @param source  the source of the event (could be the chart, a title, an
079                      axis etc.)
080     * @param chart  the chart that generated the event.
081     * @param type  the type of event.
082     */
083    public ChartChangeEvent(Object source, JFreeChart chart,
084                            ChartChangeEventType type) {
085        super(source);
086        this.chart = chart;
087        this.type = type;
088    }
089
090    /**
091     * Returns the chart that generated the change event.
092     *
093     * @return The chart that generated the change event.
094     */
095    public JFreeChart getChart() {
096        return this.chart;
097    }
098
099    /**
100     * Sets the chart that generated the change event.
101     *
102     * @param chart  the chart that generated the event.
103     */
104    public void setChart(JFreeChart chart) {
105        this.chart = chart;
106    }
107
108    /**
109     * Returns the event type.
110     *
111     * @return The event type.
112     */
113    public ChartChangeEventType getType() {
114        return this.type;
115    }
116
117    /**
118     * Sets the event type.
119     *
120     * @param type  the event type.
121     */
122    public void setType(ChartChangeEventType type) {
123        this.type = type;
124    }
125
126}