001/* ================================================
002 * JFreeChart-FX : JavaFX extensions for JFreeChart
003 * ================================================
004 *
005 * (C) Copyright 2017, by Object Refinery Limited and Contributors.
006 *
007 * Project Info:  https://github.com/jfree/jfreechart-fx
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 * ChartMouseEventFX.java
029 * ----------------------
030 * (C) Copyright 2014, 2017 by Object Refinery Limited and Contributors.
031 *
032 * Original Author:  David Gilbert (for Object Refinery Limited);
033 * Contributor(s):   -;
034 *
035 */
036
037package org.jfree.chart.fx.interaction;
038
039import java.io.Serializable;
040import java.util.EventObject;
041import javafx.scene.input.MouseEvent;
042import org.jfree.chart.JFreeChart;
043import org.jfree.chart.entity.ChartEntity;
044import org.jfree.chart.fx.ChartViewer;
045
046/**
047 * A mouse event for a chart that is displayed in a (JavaFX) 
048 * {@link ChartViewer}.
049 *
050 * @see ChartMouseListenerFX
051 */
052public class ChartMouseEventFX extends EventObject implements Serializable {
053
054    /** For serialization. */
055    private static final long serialVersionUID = -682393837314562149L;
056
057    /** The chart that the mouse event relates to. */
058    private JFreeChart chart;
059
060    /** The Java mouse event that triggered this event. */
061    private MouseEvent trigger;
062
063    /** The chart entity (if any). */
064    private ChartEntity entity;
065
066    /**
067     * Constructs a new event.
068     *
069     * @param chart  the source chart ({@code null} not permitted).
070     * @param trigger  the mouse event that triggered this event
071     *                 ({@code null} not permitted).
072     * @param entity  the chart entity (if any) under the mouse point
073     *                ({@code null} permitted).
074     */
075    public ChartMouseEventFX(JFreeChart chart, MouseEvent trigger,
076                           ChartEntity entity) {
077        super(chart);
078        this.chart = chart;
079        this.trigger = trigger;
080        this.entity = entity;
081    }
082
083    /**
084     * Returns the chart that the mouse event relates to.
085     *
086     * @return The chart (never {@code null}).
087     */
088    public JFreeChart getChart() {
089        return this.chart;
090    }
091
092    /**
093     * Returns the mouse event that triggered this event.
094     *
095     * @return The event (never {@code null}).
096     */
097    public MouseEvent getTrigger() {
098        return this.trigger;
099    }
100
101    /**
102     * Returns the chart entity (if any) under the mouse point.
103     *
104     * @return The chart entity (possibly {@code null}).
105     */
106    public ChartEntity getEntity() {
107        return this.entity;
108    }
109
110}
111