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