001: /*
002: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003: * for visualizing and manipulating spatial features with geometry and attributes.
004: *
005: * Copyright (C) 2003 Vivid Solutions
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: *
021: * For more information, contact:
022: *
023: * Vivid Solutions
024: * Suite #1A
025: * 2328 Government Street
026: * Victoria BC V8T 5G5
027: * Canada
028: *
029: * (250)385-6040
030: * www.vividsolutions.com
031: */
032:
033: package com.vividsolutions.jump.workbench.ui.cursortool;
034:
035: import java.awt.Cursor;
036: import java.awt.event.MouseEvent;
037:
038: import javax.swing.Icon;
039: import javax.swing.SwingUtilities;
040:
041: import com.vividsolutions.jump.workbench.ui.LayerViewPanel;
042:
043: /**
044: * Filters out middle- and right-clicks.
045: */
046: public class LeftClickFilter implements CursorTool {
047: private CursorTool wrappee;
048:
049: public LeftClickFilter(CursorTool wrappee) {
050: this .wrappee = wrappee;
051: }
052:
053: public CursorTool getWrappee() {
054: return wrappee;
055: }
056:
057: public Icon getIcon() {
058: return wrappee.getIcon();
059: }
060:
061: public String getName() {
062: return wrappee.getName();
063: }
064:
065: public Cursor getCursor() {
066: return wrappee.getCursor();
067: }
068:
069: public void activate(LayerViewPanel panel) {
070: wrappee.activate(panel);
071: }
072:
073: public void deactivate() {
074: wrappee.deactivate();
075: }
076:
077: public void mouseClicked(MouseEvent e) {
078: if (isOnlyLeftMouseButton(e)) {
079: wrappee.mouseClicked(e);
080: }
081: }
082:
083: public void mousePressed(MouseEvent e) {
084: if (isOnlyLeftMouseButton(e)) {
085: wrappee.mousePressed(e);
086: }
087: }
088:
089: public void mouseReleased(MouseEvent e) {
090: if (isOnlyLeftMouseButton(e)) {
091: wrappee.mouseReleased(e);
092: }
093: }
094:
095: public void mouseEntered(MouseEvent e) {
096: wrappee.mouseEntered(e);
097: }
098:
099: public void mouseExited(MouseEvent e) {
100: wrappee.mouseExited(e);
101: }
102:
103: public void mouseDragged(MouseEvent e) {
104: if (isOnlyLeftMouseButton(e)) {
105: wrappee.mouseDragged(e);
106: }
107: }
108:
109: public void mouseMoved(MouseEvent e) {
110: wrappee.mouseMoved(e);
111: }
112:
113: public boolean isRightMouseButtonUsed() {
114: return false;
115: }
116:
117: public boolean isGestureInProgress() {
118: return wrappee.isGestureInProgress();
119: }
120:
121: public void cancelGesture() {
122: wrappee.cancelGesture();
123: }
124:
125: private boolean isOnlyLeftMouseButton(MouseEvent e) {
126: //A future CursorTool may check whether *both* buttons are pressed (to
127: //indicate that the interaction should be cancelled). [Jon Aquino]
128: return SwingUtilities.isLeftMouseButton(e)
129: && !SwingUtilities.isRightMouseButton(e);
130: }
131: }
|