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