001package jmri.util.swing;
002
003import java.awt.event.MouseEvent;
004
005/**
006 * Replacement for {@link java.awt.event.MouseMotionListener}.
007 * This class is used to replace {@link java.awt.event.MouseEvent} with
008 * {@link jmri.util.swing.JmriMouseEvent}.
009 *
010 * @author Daniel Bergqvist (C) 2022
011 */
012public interface JmriMouseMotionListener extends java.util.EventListener {
013
014    /**
015     * Adapt a JmriMouseMotionListener to a MouseMotionListener.
016     * @param listener the JmriMouseListener
017     * @return the MouseListener
018     */
019    public static java.awt.event.MouseMotionListener adapt(JmriMouseMotionListener listener) {
020        return new java.awt.event.MouseMotionListener() {
021            @Override
022            public void mouseDragged(MouseEvent e) {
023                listener.mouseDragged(new JmriMouseEvent(e));
024            }
025
026            @Override
027            public void mouseMoved(MouseEvent e) {
028                listener.mouseMoved(new JmriMouseEvent(e));
029            }
030        };
031    }
032
033    /**
034     * Invoked when a mouse button is pressed on a component and then
035     * dragged.  {@code MOUSE_DRAGGED} events will continue to be
036     * delivered to the component where the drag originated until the
037     * mouse button is released (regardless of whether the mouse position
038     * is within the bounds of the component).
039     * <p>
040     * Due to platform-dependent Drag&amp;Drop implementations,
041     * {@code MOUSE_DRAGGED} events may not be delivered during a native
042     * Drag&amp;Drop operation.
043     * @param e the event to be processed
044     */
045    public void mouseDragged(JmriMouseEvent e);
046
047    /**
048     * Invoked when the mouse cursor has been moved onto a component
049     * but no buttons have been pushed.
050     * @param e the event to be processed
051     */
052    public void mouseMoved(JmriMouseEvent e);
053
054}