
info.monitorenter.gui.chart.IPointFinder Maven / Gradle / Ivy
Show all versions of jchart2d Show documentation
/*
* IPointFinder.java of project jchart2d, interface for finding a tracepoint of
* a chart corresponding to a mouse event.
* Copyright (C) 2002 - 2011, Achim Westermann, created on Jun 12, 2011
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* If you modify or optimize the code in a useful way please let me know.
* [email protected]
*
*
* File : $Source: /cvsroot/jchart2d/jchart2d/src/info/monitorenter/gui/chart/IPointFinder.java,v $
* Date : $Date: 2011/01/14 08:36:10 $
* Version: $Revision: 1.2 $
*/
package info.monitorenter.gui.chart;
import java.awt.event.MouseEvent;
/**
* Interface for finding a {@link ITracePoint2D}
of a
* {@link Chart2D}
corresponding to a mouse event.
*
* This is used to allow a pluggable strategy for this task which is needed by
* point highlighting and/or tool tips.
*
*
* @author Achim Westermann
*
*/
public interface IPointFinder {
/**
* Returns the nearest {@link ITracePoint2D}
to the given mouse
* event's screen coordinates.
*
*
* @param mouseEventX
* the x pixel value relative to the chart (e.g.:
* {@link MouseEvent#getY()}
).
*
* @param mouseEventY
* the y pixel value relative to the chart (e.g.:
* {@link MouseEvent#getY()}
).
*
* @param chart
* to search points within.
*
* @return the nearest {@link ITracePoint2D}
to the given mouse
* event's screen coordinates.
*
*/
public ITracePoint2D getNearestPoint(final int mouseEventX, final int mouseEventY, Chart2D chart);
/**
* Returns the nearest {@link MouseEvent}
to the given mouse
* event's screen coordinates or null
if no point was found /
* service is not implemented.
*
* Simple implementations could use Manhattan distance or Euclid distance.
*
*
* @param me
* the mouse event over the chart.
*
* @param chart
* to search points within.
*
* @return e nearest {@link MouseEvent}
to the given mouse
* event's screen coordinates or null
if no point was
* found / service is not implemented.
*/
public ITracePoint2D getNearestPoint(final MouseEvent me, final Chart2D chart);
}