[Schmitzm-commits] r1513 - trunk/schmitzm-core/src/main/java/de/schmitzm/swing/event
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Mar 15 18:44:22 CET 2011
Author: mojays
Date: 2011-03-15 18:44:21 +0100 (Tue, 15 Mar 2011)
New Revision: 1513
Added:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/event/PipedMouseListener.java
Log:
new PipedMouseListener
Added: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/event/PipedMouseListener.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/event/PipedMouseListener.java 2011-03-15 16:35:53 UTC (rev 1512)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/event/PipedMouseListener.java 2011-03-15 17:44:21 UTC (rev 1513)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ *
+ * This file is part of the SCHMITZM library - a collection of utility
+ * classes based on Java 1.6, focusing (not only) on Java Swing
+ * and the Geotools library.
+ *
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ *
+ * This program 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 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ *
+ * Contributors:
+ * Martin O. J. Schmitz - initial API and implementation
+ * Stefan A. Tzeggai - additional utility classes
+ ******************************************************************************/
+package de.schmitzm.swing.event;
+
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+
+/**
+ * This class simple pipes the actions of an existing {@link MouseListener}, but allows
+ * to overwrite the particular methods to catch some exceptions for example.
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ * @version 1.0
+ */
+public class PipedMouseListener implements MouseListener {
+
+ /** Listener the events are piped to. */
+ protected MouseListener listener = null;
+
+ /**
+ * Creates a new Listener.
+ * @param l the listener the events are piped to
+ */
+ public PipedMouseListener(MouseListener l) {
+ this.listener = l;
+ }
+
+ /**
+ * Simply calls {@link #listener#mouseClicked(MouseEvent)} if
+ * {@link #listener} is not <code>null</code>.
+ */
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if ( listener != null )
+ listener.mouseClicked(e);
+ }
+
+ /**
+ * Simply calls {@link #listener#mousePressed(MouseEvent)} if
+ * {@link #listener} is not <code>null</code>.
+ */
+ @Override
+ public void mousePressed(MouseEvent e) {
+ if ( listener != null )
+ listener.mousePressed(e);
+ }
+
+ /**
+ * Simply calls {@link #listener#mouseReleased(MouseEvent)} if
+ * {@link #listener} is not <code>null</code>.
+ */
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ if ( listener != null )
+ listener.mouseReleased(e);
+ }
+
+ /**
+ * Simply calls {@link #listener#mouseEntered(MouseEvent)} if
+ * {@link #listener} is not <code>null</code>.
+ */
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ if ( listener != null )
+ listener.mouseEntered(e);
+ }
+
+ /**
+ * Simply calls {@link #listener#mouseExited(MouseEvent)} if
+ * {@link #listener} is not <code>null</code>.
+ */
+ @Override
+ public void mouseExited(MouseEvent e) {
+ if ( listener != null )
+ listener.mouseExited(e);
+ }
+
+}
More information about the Schmitzm-commits
mailing list