001 /* ======================================================
002 * Orson : a free chart beans library based on JFreeChart
003 * ======================================================
004 *
005 * (C) Copyright 2007, by Object Refinery Limited.
006 *
007 * Project Info: not-yet-released
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 package org.jfree.beans.events;
029
030 import java.util.EventObject;
031
032 import org.jfree.beans.AbstractXYChart;
033 import org.jfree.data.xy.XYDataset;
034
035 /**
036 * An event object that carries information about a mouse click on an item
037 * in an {@link AbstractXYChart}.
038 */
039 public class XYItemClickEvent extends EventObject {
040
041 /** The dataset. */
042 private XYDataset dataset;
043
044 /** The series index. */
045 private int seriesIndex;
046
047 /** The item index. */
048 private int itemIndex;
049
050 /**
051 * Creates a new XY item click event.
052 *
053 * @param source the event source (typically the chart).
054 * @param dataset the dataset.
055 * @param seriesIndex the row key.
056 * @param itemIndex the column key.
057 */
058 public XYItemClickEvent(Object source, XYDataset dataset,
059 int seriesIndex, int itemIndex) {
060 super(source);
061 this.dataset = dataset;
062 this.seriesIndex = seriesIndex;
063 this.itemIndex = itemIndex;
064 }
065
066 /**
067 * Returns the dataset.
068 *
069 * @return The dataset.
070 */
071 public XYDataset getDataset() {
072 return this.dataset;
073 }
074
075 /**
076 * Returns the series index.
077 *
078 * @return The series index.
079 */
080 public int getSeriesIndex() {
081 return this.seriesIndex;
082 }
083
084 /**
085 * Returns the item index.
086 *
087 * @return The item index.
088 */
089 public int getItemIndex() {
090 return this.itemIndex;
091 }
092
093 /**
094 * Returns a string that represents the state of this instance (suitable
095 * for debugging purposes).
096 *
097 * @return A string.
098 */
099 public String toString() {
100 return "XYItemClickEvent: seriesIndex=" + this.seriesIndex
101 + ", itemIndex=" + this.itemIndex + ", dataset=" + this.dataset;
102 }
103
104 }