    001    /* ===========================================================
    002     * JFreeChart : a free chart library for the Java(tm) platform
    003     * ===========================================================
    004     *
    005     * (C) Copyright 2000-2007, 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     * ChartMouseEvent.java
    029     * --------------------
    030     * (C) Copyright 2002-2007, by Object Refinery Limited and Contributors.
    031     *
    032     * Original Author:  David Gilbert (for Object Refinery Limited);
    033     * Contributor(s):   Alex Weber;
    034     *
    035     * Changes
    036     * -------
    037     * 27-May-2002 : Version 1, incorporating code and ideas by Alex Weber (DG);
    038     * 13-Jun-2002 : Added Javadoc comments (DG);
    039     * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG);
    040     * 05-Nov-2002 : Added a reference to the source chart (DG);
    041     * 13-Jul-2004 : Now extends EventObject and implements Serializable (DG);
    042     * ------------- JFREECHART 1.0.x ---------------------------------------------
    043     * 24-May-2007 : Updated API docs (DG);
    044     *
    045     */
    046
    047    package org.jfree.chart;
    048
    049    import java.awt.event.MouseEvent;
    050    import java.io.Serializable;
    051    import java.util.EventObject;
    052
    053    import org.jfree.chart.entity.ChartEntity;
    054
    055    /**
    056     * A mouse event for a chart that is displayed in a {@link ChartPanel}.
    057     *
    058     * @see ChartMouseListener
    059     */
    060    public class ChartMouseEvent extends EventObject implements Serializable {
    061
    062        /** For serialization. */
    063        private static final long serialVersionUID = -682393837314562149L;
    064
    065        /** The chart that the mouse event relates to. */
    066        private JFreeChart chart;
    067
    068        /** The Java mouse event that triggered this event. */
    069        private MouseEvent trigger;
    070
    071        /** The chart entity (if any). */
    072        private ChartEntity entity;
    073
    074        /**
    075         * Constructs a new event.
    076         *
    077         * @param chart  the source chart (<code>null</code> not permitted).
    078         * @param trigger  the mouse event that triggered this event
    079         *                 (<code>null</code> not permitted).
    080         * @param entity  the chart entity (if any) under the mouse point
    081         *                (<code>null</code> permitted).
    082         */
    083        public ChartMouseEvent(JFreeChart chart, MouseEvent trigger,
    084                               ChartEntity entity) {
    085            super(chart);
    086            this.chart = chart;
    087            this.trigger = trigger;
    088            this.entity = entity;
    089        }
    090
    091        /**
    092         * Returns the chart that the mouse event relates to.
    093         *
    094         * @return The chart (never <code>null</code>).
    095         */
    096        public JFreeChart getChart() {
    097            return this.chart;
    098        }
    099
    100        /**
    101         * Returns the mouse event that triggered this event.
    102         *
    103         * @return The event (never <code>null</code>).
    104         */
    105        public MouseEvent getTrigger() {
    106            return this.trigger;
    107        }
    108
    109        /**
    110         * Returns the chart entity (if any) under the mouse point.
    111         *
    112         * @return The chart entity (possibly <code>null</code>).
    113         */
    114        public ChartEntity getEntity() {
    115            return this.entity;
    116        }
    117
    118    }