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