[Schmitzm-commits] r656 - branches/2.0-RC2/src/skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 3 13:18:36 CET 2010


Author: alfonx
Date: 2010-02-03 13:18:35 +0100 (Wed, 03 Feb 2010)
New Revision: 656

Modified:
   branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java
Log:
Comments and cleanup in XMapPaneTool

Modified: branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java	2010-02-03 11:47:44 UTC (rev 655)
+++ branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java	2010-02-03 12:18:35 UTC (rev 656)
@@ -914,7 +914,7 @@
 		}
 
 		public MapPaneToolBarAction(int id, MapPaneToolBar toolBar, XMapPaneTool tool) {
-			this(id, toolBar, "", tool.icon, tool.toolTip);
+			this(id, toolBar, "", tool.getIcon(), tool.getToolTip());
 		}
 
 		/**

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-02-03 11:47:44 UTC (rev 655)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-02-03 12:18:35 UTC (rev 656)
@@ -547,13 +547,13 @@
 //	 * {@link #xMapPaneMouseListener} is also enabled.
 //	 **/
 //	private int state = ZOOM_IN;
+//
+//	/**
+//	 * Manuell gesetzter statischer Cursor, unabhaengig von der aktuellen
+//	 * MapPane-Funktion
+//	 */
+//	protected Cursor staticCursor = null;
 
-	/**
-	 * Manuell gesetzter statischer Cursor, unabhaengig von der aktuellen
-	 * MapPane-Funktion
-	 */
-	protected Cursor staticCursor = null;
-
 	private AffineTransform worldToScreen;
 
 	// /**
@@ -1291,18 +1291,18 @@
 //	public int getState() {
 //		return state;
 //	}
+//
+//	/**
+//	 * Liefert den statisch eingestellten Cursor, der unabhaengig von der
+//	 * eingestellten MapPane-Aktion (Zoom, Auswahl, ...) verwendet wird.
+//	 * 
+//	 * @return {@code null}, wenn kein statischer Cursor verwendet, sondern der
+//	 *         Cursor automatisch je nach MapPane-Aktion eingestellt wird.
+//	 */
+//	public Cursor getStaticCursor() {
+//		return this.staticCursor;
+//	}
 
-	/**
-	 * Liefert den statisch eingestellten Cursor, der unabhaengig von der
-	 * eingestellten MapPane-Aktion (Zoom, Auswahl, ...) verwendet wird.
-	 * 
-	 * @return {@code null}, wenn kein statischer Cursor verwendet, sondern der
-	 *         Cursor automatisch je nach MapPane-Aktion eingestellt wird.
-	 */
-	public Cursor getStaticCursor() {
-		return this.staticCursor;
-	}
-
 	public AffineTransform getWorldToScreenTransform() {
 		if (worldToScreen == null) {
 			resetTransforms();
@@ -1986,24 +1986,24 @@
 			tool = XMapPaneTool.NO_ACTION;
 		this.tool = tool;
 		xMapPaneMouseListener.configure(tool);
-		setCursor(tool.cursor);
+		setCursor(tool.getCursor());
 	}
 
-	/**
-	 * Standardmaessig wird der Cursor automatisch je nach MapPane-Aktion (Zoom,
-	 * Auswahl, ...) gesetzt. Mit dieser Methode kann ein statischer Cursor
-	 * gesetzt werden, der unabhaengig von der aktuellen MapPanes-Aktion
-	 * beibehalten wird. Um diesen statischen Cursor wieder zu entfernen, kann
-	 * {@code null} als Parameter uebergeben werden
-	 * 
-	 * @param cursor
-	 *            Cursor
-	 */
-	public void setStaticCursor(final Cursor cursor) {
-		this.staticCursor = cursor;
-		if (cursor != null)
-			super.setCursor(cursor);
-	}
+//	/**
+//	 * Standardmaessig wird der Cursor automatisch je nach MapPane-Aktion (Zoom,
+//	 * Auswahl, ...) gesetzt. Mit dieser Methode kann ein statischer Cursor
+//	 * gesetzt werden, der unabhaengig von der aktuellen MapPanes-Aktion
+//	 * beibehalten wird. Um diesen statischen Cursor wieder zu entfernen, kann
+//	 * {@code null} als Parameter uebergeben werden
+//	 * 
+//	 * @param cursor
+//	 *            Cursor
+//	 */
+//	public void setStaticCursor(final Cursor cursor) {
+//		this.staticCursor = cursor;
+//		if (cursor != null)
+//			super.setCursor(cursor);
+//	}
 
 	/**
 	 * Starts rendering on one or two threads
@@ -2145,21 +2145,21 @@
 				repaint();
 			}
 		}
-		
-//
-		// wenn manueller Cursor gesetzt ist, dann diesen verwenden (unabhaengig
-		// von der aktuellen Aktion
-		if (this.staticCursor != null) {
-			setCursor(staticCursor);
-			return;
-		}
-		
+//		
+////
+//		// wenn manueller Cursor gesetzt ist, dann diesen verwenden (unabhaengig
+//		// von der aktuellen Aktion
+//		if (this.staticCursor != null) {
+//			setCursor(staticCursor);
+//			return;
+//		}
+//		
 		if (getCursor() == SwingUtil.PANNING_CURSOR) {
 			// This cursor will reset itself
 			return;
 		}
 		
-		setCursor(tool.cursor);
+		setCursor(tool.getCursor());
 		
 //
 //		// Set the cursor depending on what tool is in use...

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java	2010-02-03 11:47:44 UTC (rev 655)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java	2010-02-03 12:18:35 UTC (rev 656)
@@ -22,10 +22,46 @@
  */
 public class XMapPaneTool {
 
+	/** The cursor of the mouse if the tool is active **/
+	private Cursor cursor = null;
+
+	/** A tool-tip for the tool , optional **/
+	private String toolTip = null;
+
+	/** The icon for the button **/
+	private Icon icon = null;
+
+	/**
+	 * Defines which {@link XMapPaneAction} should be should be called when a
+	 * {@link MouseInputType} is triggered
+	 **/
+	Map<MouseInputType, XMapPaneAction> mouseActions = new HashMap<MouseInputType, XMapPaneAction>();
+
+	/**
+	 * Defines which {@link XMapPaneAction#performKeyboard(XMapPane, Object)}
+	 * should be called when a {@link KeyStroke} is triggered
+	 **/
+	Map<KeyStroke, XMapPaneAction> keyAction = new HashMap<KeyStroke, XMapPaneAction>();
+
+	/**
+	 * Defines which optional parameter should be passed to
+	 * {@link XMapPaneAction#performKeyboard(XMapPane, Object)} if a
+	 * {@link KeyStroke} is triggered
+	 **/
+	Map<KeyStroke, Object> keyActionParams = new HashMap<KeyStroke, Object>();
+
+	/**
+	 * @return the {@link Cursor} that shall be set as the default mouse cursor
+	 *         (when no button is clicked)
+	 */
 	public Cursor getCursor() {
 		return cursor;
 	}
 
+	/**
+	 * @return the {@link Cursor} that shall be set as the default mouse cursor
+	 *         (when no button is clicked)
+	 */
 	public void setCursor(Cursor cursor) {
 		this.cursor = cursor;
 	}
@@ -38,38 +74,70 @@
 		this.toolTip = toolTip;
 	}
 
+	/**
+	 * An icon to use if the tool is associated with a button. May be
+	 * <code>null</code>.
+	 */
 	public Icon getIcon() {
 		return icon;
 	}
 
+	/**
+	 * An icon to use if the tool is associated with a button. May be
+	 * <code>null</code>.
+	 */
 	public void setIcon(Icon icon) {
 		this.icon = icon;
 	}
 
+	/**
+	 * @return The {@link XMapPaneAction} associated with a given
+	 *         {@link MouseInputType}
+	 */
 	public XMapPaneAction getMouseAction(MouseInputType type) {
 		return mouseActions.get(type);
 	}
 
+	/**
+	 * Sets the {@link XMapPaneAction} for a given {@link MouseInputType}
+	 */
 	public void setMouseAction(MouseInputType type, XMapPaneAction mouseAction) {
-		this.mouseActions.put(type, mouseAction);;
+		this.mouseActions.put(type, mouseAction);
 	}
 
+	/**
+	 * @return The {@link XMapPaneAction} associated with a {@link KeyStroke}
+	 */
 	public XMapPaneAction getKeyAction(KeyStroke keyStroke) {
 		return keyAction.get(keyStroke);
 	}
 
+	/**
+	 * Set the {@link XMapPaneAction} for a {@link KeyStroke}
+	 */
 	public void setKeyAction(KeyStroke keyStroke, XMapPaneAction keyAction) {
-		this.keyAction.put(keyStroke,keyAction);
+		this.keyAction.put(keyStroke, keyAction);
 	}
 
+	/**
+	 * Get the optional parameter for a{@link XMapPaneAction} when triggered by
+	 * {@link KeyStroke}
+	 */
 	public Object getKeyActionParam(KeyStroke keyStroke) {
 		return keyActionParams.get(keyStroke);
 	}
 
+	/**
+	 * Set the optional parameter for a{@link XMapPaneAction} when triggered by
+	 * {@link KeyStroke}
+	 */
 	public void setKeyActionParam(KeyStroke keyStroke, Object param) {
 		this.keyActionParams.put(keyStroke, param);
 	}
 
+	/**
+	 * The default constructor sets some default keyboard settings
+	 */
 	public XMapPaneTool() {
 		addDefaultKeyboardAssignments(this);
 	}
@@ -82,42 +150,15 @@
 		return RESOURCE.getString(key, values);
 	}
 
-	/** The cursor of the mouse if the tool is active **/
-	Cursor cursor = null;
-
-	/** A tool-tip for the tool , optional **/
-	String toolTip = null;
-
-	/** The icon for the button **/
-	Icon icon = null;
-
-	/**
-	 * Defines which {@link XMapPaneAction} should be should be called when a
-	 * {@link MouseInputType} is triggered
-	 **/
-	Map<MouseInputType, XMapPaneAction> mouseActions = new HashMap<MouseInputType, XMapPaneAction>();
-
-	/**
-	 * Defines which {@link XMapPaneAction#performKeyboard(XMapPane, Object)}
-	 * should be called when a {@link KeyStroke} is triggered
-	 **/
-	Map<KeyStroke, XMapPaneAction> keyAction = new HashMap<KeyStroke, XMapPaneAction>();
-
-	/**
-	 * Defines which optional parameter should be passed to
-	 * {@link XMapPaneAction#performKeyboard(XMapPane, Object)} if a
-	 * {@link KeyStroke} is triggered
-	 **/
-	Map<KeyStroke, Object> keyActionParams = new HashMap<KeyStroke, Object>();
-	
 	/** This {@link XMapPaneTool} does nothing **/
-	public static XMapPaneTool NO_ACTION = new XMapPaneTool() ;
+	public static XMapPaneTool NO_ACTION = new XMapPaneTool();
 	static {
-		// Remove the keyboard mapping that are defined by the default constructor
+		// Remove the keyboard mapping that are defined by the default
+		// constructor
 		NO_ACTION.keyAction.clear();
 		NO_ACTION.keyActionParams.clear();
 	}
-	
+
 	/** The configuration of the default ZOOM IN {@link XMapPaneTool} **/
 	public static XMapPaneTool ZOOM_IN = new XMapPaneTool();
 	static {
@@ -127,21 +168,16 @@
 		ZOOM_IN.cursor = SwingUtil.ZOOMIN_CURSOR;
 
 		// Left mouse click & drag zoom in
-		ZOOM_IN.mouseActions.put(MouseInputType.LClick,
-				XMapPaneAction_Zoom.ZOOM_IN);
-		ZOOM_IN.mouseActions.put(MouseInputType.LDrag,
-				XMapPaneAction_Zoom.ZOOM_IN);
+		ZOOM_IN.mouseActions.put(MouseInputType.LClick, XMapPaneAction.ZOOM_IN);
+		ZOOM_IN.mouseActions.put(MouseInputType.LDrag, XMapPaneAction.ZOOM_IN);
 
 		// Right mouse click & drag zoom out
-		ZOOM_IN.mouseActions.put(MouseInputType.RClick,
-				XMapPaneAction_Zoom.ZOOM_OUT);
-		ZOOM_IN.mouseActions.put(MouseInputType.RDrag,
-				XMapPaneAction_Zoom.ZOOM_OUT);
+		ZOOM_IN.mouseActions
+				.put(MouseInputType.RClick, XMapPaneAction.ZOOM_OUT);
+		ZOOM_IN.mouseActions.put(MouseInputType.RDrag, XMapPaneAction.ZOOM_OUT);
 
 		// Mousewheel can zoom too
-		ZOOM_IN.mouseActions.put(MouseInputType.Wheel,
-				XMapPaneAction_Zoom.ZOOM_IN);
-
+		ZOOM_IN.mouseActions.put(MouseInputType.Wheel, XMapPaneAction.ZOOM_IN);
 	}
 
 	/** The configuration of the default ZOOM IN {@link XMapPaneTool} **/
@@ -154,19 +190,17 @@
 
 		// Left mouse click & drag zoom in
 		ZOOM_OUT.mouseActions.put(MouseInputType.LClick,
-				XMapPaneAction_Zoom.ZOOM_OUT);
-		ZOOM_OUT.mouseActions.put(MouseInputType.LDrag,
-				XMapPaneAction_Zoom.ZOOM_OUT);
+				XMapPaneAction.ZOOM_OUT);
+		ZOOM_OUT.mouseActions
+				.put(MouseInputType.LDrag, XMapPaneAction.ZOOM_OUT);
 
 		// Right mouse click & drag zoom out
-		ZOOM_OUT.mouseActions.put(MouseInputType.RClick,
-				XMapPaneAction_Zoom.ZOOM_IN);
-		ZOOM_OUT.mouseActions.put(MouseInputType.RDrag,
-				XMapPaneAction_Zoom.ZOOM_IN);
+		ZOOM_OUT.mouseActions
+				.put(MouseInputType.RClick, XMapPaneAction.ZOOM_IN);
+		ZOOM_OUT.mouseActions.put(MouseInputType.RDrag, XMapPaneAction.ZOOM_IN);
 
 		// Mousewheel can zoom
-		ZOOM_OUT.mouseActions.put(MouseInputType.Wheel,
-				XMapPaneAction_Zoom.ZOOM_IN);
+		ZOOM_OUT.mouseActions.put(MouseInputType.Wheel, XMapPaneAction.ZOOM_IN);
 
 	}
 
@@ -187,21 +221,15 @@
 		PAN.mouseActions.put(MouseInputType.RDrag, XMapPaneAction.PAN);
 
 		// Mousewheel can zoom
-		PAN.mouseActions.put(MouseInputType.Wheel, XMapPaneAction_Zoom.ZOOM_IN);
+		PAN.mouseActions.put(MouseInputType.Wheel, XMapPaneAction.ZOOM_IN);
 
 	}
-	
-	
 
 	/** A tool that will do a select_top action on the left mouse button **/
 	public static final XMapPaneTool SELECTION_TOP_LAYER = new XMapPaneTool();
 	static {
-//		SELECTION_TOP_LAYER.icon = new ImageIcon(MapView.class
-//				.getResource("resource/icons/selection_add.png"));
-//		SELECTION_TOP_LAYER.toolTip = R("MapPaneButtons.Selection.AddSelection.TT"); // TODO
-		// move
-		// to
-		// schmitzm
+		SELECTION_TOP_LAYER.icon = new ImageIcon(MapView.class
+				.getResource("resource/icons/selection_set.png"));
 
 		SELECTION_TOP_LAYER.cursor = SwingUtil.SELECTION_SET_CURSOR;
 
@@ -211,26 +239,21 @@
 		SELECTION_TOP_LAYER.mouseActions.put(MouseInputType.LDrag,
 				XMapPaneAction.SELECT_TOP);
 
-		SELECTION_TOP_LAYER.mouseActions
-				.put(MouseInputType.RDrag, XMapPaneAction.PAN);
+		SELECTION_TOP_LAYER.mouseActions.put(MouseInputType.RDrag,
+				XMapPaneAction.PAN);
 
 		// Mousewheel can zoom
 		SELECTION_TOP_LAYER.mouseActions.put(MouseInputType.Wheel,
-				XMapPaneAction_Zoom.ZOOM_IN);
+				XMapPaneAction.ZOOM_IN);
 
 		// TODO Strg-A shoud select all
 	}
-	
 
 	/** A tool that will do a select_top action on the left mouse button **/
 	public static final XMapPaneTool SELECTION_ONE_FROM_TOP_LAYER = new XMapPaneTool();
 	static {
-//		SELECTION_ONE_FROM_TOP.icon = new ImageIcon(MapView.class
-//				.getResource("resource/icons/selection_add.png"));
-//		SELECTION_ONE_FROM_TOP.toolTip = R("MapPaneButtons.Selection.AddSelection.TT"); // TODO
-		// move
-		// to
-		// schmitzm
+		SELECTION_ONE_FROM_TOP_LAYER.icon = new ImageIcon(MapView.class
+				.getResource("resource/icons/selection_set.png"));
 
 		SELECTION_ONE_FROM_TOP_LAYER.cursor = SwingUtil.SELECTION_SET_CURSOR;
 
@@ -240,27 +263,21 @@
 		SELECTION_ONE_FROM_TOP_LAYER.mouseActions.put(MouseInputType.LDrag,
 				XMapPaneAction.SELECT_ONE_FROM_TOP);
 
-		SELECTION_ONE_FROM_TOP_LAYER.mouseActions
-				.put(MouseInputType.RDrag, XMapPaneAction.PAN);
+		SELECTION_ONE_FROM_TOP_LAYER.mouseActions.put(MouseInputType.RDrag,
+				XMapPaneAction.PAN);
 
 		// Mousewheel can zoom
 		SELECTION_ONE_FROM_TOP_LAYER.mouseActions.put(MouseInputType.Wheel,
-				XMapPaneAction_Zoom.ZOOM_IN);
+				XMapPaneAction.ZOOM_IN);
 
 		// TODO Strg-A shoud select all
 	}
 
-	
-
 	/** A tool that will do a select_top action on the left mouse button **/
 	public static final XMapPaneTool SELECTION_ALL_LAYERS = new XMapPaneTool();
 	static {
-//		SELECTION_ALL_LAYERS.icon = new ImageIcon(MapView.class
-//				.getResource("resource/icons/selection_add.png"));
-//		SELECTION_ALL_LAYERS.toolTip = R("MapPaneButtons.Selection.AddSelection.TT"); // TODO
-		// move
-		// to
-		// schmitzm
+		SELECTION_ALL_LAYERS.icon = new ImageIcon(MapView.class
+				.getResource("resource/icons/selection_set.png"));
 
 		SELECTION_ALL_LAYERS.cursor = SwingUtil.SELECTION_SET_CURSOR;
 
@@ -270,17 +287,16 @@
 		SELECTION_ALL_LAYERS.mouseActions.put(MouseInputType.LDrag,
 				XMapPaneAction.SELECT_ALL);
 
-		SELECTION_ALL_LAYERS.mouseActions
-				.put(MouseInputType.RDrag, XMapPaneAction.PAN);
+		SELECTION_ALL_LAYERS.mouseActions.put(MouseInputType.RDrag,
+				XMapPaneAction.PAN);
 
 		// Mousewheel can zoom
 		SELECTION_ALL_LAYERS.mouseActions.put(MouseInputType.Wheel,
-				XMapPaneAction_Zoom.ZOOM_IN);
+				XMapPaneAction.ZOOM_IN);
 
 		// TODO Strg-A shoud select all
 	}
 
-
 	/** The configuration of the INFO {@link XMapPaneTool} **/
 	public static final XMapPaneTool INFO = new XMapPaneTool();
 
@@ -299,8 +315,7 @@
 		INFO.mouseActions.put(MouseInputType.RDrag, XMapPaneAction.PAN);
 
 		// Mousewheel can zoom
-		INFO.mouseActions
-				.put(MouseInputType.Wheel, XMapPaneAction_Zoom.ZOOM_IN);
+		INFO.mouseActions.put(MouseInputType.Wheel, XMapPaneAction.ZOOM_IN);
 
 	}
 
@@ -326,7 +341,7 @@
 
 		// Mousewheel can zoom
 		SELECTION_ADD.mouseActions.put(MouseInputType.Wheel,
-				XMapPaneAction_Zoom.ZOOM_IN);
+				XMapPaneAction.ZOOM_IN);
 
 		// TODO Strg-A shoud select all
 	}
@@ -353,7 +368,7 @@
 
 		// Mousewheel can zoom
 		SELECTION_REMOVE.mouseActions.put(MouseInputType.Wheel,
-				XMapPaneAction_Zoom.ZOOM_IN);
+				XMapPaneAction.ZOOM_IN);
 
 		// TODO Strg-A shoud select all
 	}
@@ -380,7 +395,7 @@
 
 		// Mousewheel can zoom
 		SELECTION_SET.mouseActions.put(MouseInputType.Wheel,
-				XMapPaneAction_Zoom.ZOOM_IN);
+				XMapPaneAction.ZOOM_IN);
 
 		// TODO Strg-A shoud select all
 	}
@@ -392,9 +407,9 @@
 
 		// + and - keys zoom
 		tool.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0),
-				XMapPaneAction_Zoom.ZOOM_IN);
+				XMapPaneAction.ZOOM_IN);
 		tool.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0),
-				XMapPaneAction_Zoom.ZOOM_OUT);
+				XMapPaneAction.ZOOM_OUT);
 
 		KeyStroke keyStroke;
 



More information about the Schmitzm-commits mailing list