001// License: GPL. For details, see Readme.txt file.
002package org.openstreetmap.gui.jmapviewer;
003
004import java.awt.event.MouseListener;
005import java.awt.event.MouseMotionListener;
006import java.awt.event.MouseWheelListener;
007
008/**
009 * Abstract base class for all mouse controller implementations. For
010 * implementing your own controller create a class that derives from this one
011 * and implements one or more of the following interfaces:
012 * <ul>
013 * <li>{@link MouseListener}</li>
014 * <li>{@link MouseMotionListener}</li>
015 * <li>{@link MouseWheelListener}</li>
016 * </ul>
017 *
018 * @author Jan Peter Stotz
019 */
020public abstract class JMapController {
021
022    protected JMapViewer map;
023
024    public JMapController(JMapViewer map) {
025        this.map = map;
026        if (this instanceof MouseListener)
027            map.addMouseListener((MouseListener) this);
028        if (this instanceof MouseWheelListener)
029            map.addMouseWheelListener((MouseWheelListener) this);
030        if (this instanceof MouseMotionListener)
031            map.addMouseMotionListener((MouseMotionListener) this);
032    }
033
034}