[Schmitzm-commits] r1443 - in trunk: schmitzm-core/src/test/java/de/schmitzm/testing schmitzm-gt/src/main/java/de/schmitzm/geotools/gui schmitzm-gt/src/test/java/de/schmitzm/geotools/gui schmitzm-jfree/src/test/java/de/schmitzm/jfree schmitzm-jfree/src/test/java/de/schmitzm/jfree/chart

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jan 27 14:24:10 CET 2011


Author: alfonx
Date: 2011-01-27 14:24:10 +0100 (Thu, 27 Jan 2011)
New Revision: 1443

Added:
   trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/JMapEditorToolBarTest.java
   trunk/schmitzm-jfree/src/test/java/de/schmitzm/jfree/chart/
   trunk/schmitzm-jfree/src/test/java/de/schmitzm/jfree/chart/SelectableChartPanelTest.java
Modified:
   trunk/schmitzm-core/src/test/java/de/schmitzm/testing/SwingUtilTest.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorToolBar.java
Log:


Modified: trunk/schmitzm-core/src/test/java/de/schmitzm/testing/SwingUtilTest.java
===================================================================
--- trunk/schmitzm-core/src/test/java/de/schmitzm/testing/SwingUtilTest.java	2011-01-27 13:21:45 UTC (rev 1442)
+++ trunk/schmitzm-core/src/test/java/de/schmitzm/testing/SwingUtilTest.java	2011-01-27 13:24:10 UTC (rev 1443)
@@ -1,18 +1,19 @@
 package de.schmitzm.testing;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.awt.Color;
 
 import org.junit.Test;
 
 import de.schmitzm.swing.ExceptionDialog;
+import de.schmitzm.swing.SwingUtil;
 import de.schmitzm.swing.input.FileInputOption;
 import de.schmitzm.swing.input.ManualInputOption;
+import de.schmitzm.swing.input.ManualInputOption.PasswordViewable;
 import de.schmitzm.swing.input.MultipleOptionPane;
 import de.schmitzm.swing.input.SelectionInputOption;
-import de.schmitzm.swing.input.ManualInputOption.PasswordViewable;
-import de.schmitzm.swing.SwingUtil;
 public class SwingUtilTest extends TestingClass {
 
     @Test
@@ -38,6 +39,19 @@
 		assertEquals("0000ff", SwingUtil.convertColorToHex(Color.BLUE, false,
 				false));
 	}
+	
+	@Test
+	public void testIconsAndCursors(){
+		assertNotNull(SwingUtil.ZOOMIN_CURSOR);
+		assertNotNull(SwingUtil.ZOOMOUT_CURSOR);
+		assertNotNull(SwingUtil.ZOOM_CURSOR);
+		assertNotNull(SwingUtil.PAN_CURSOR);
+		assertNotNull(SwingUtil.PANNING_CURSOR);
+		assertNotNull(SwingUtil.INFO_CURSOR);
+		assertNotNull(SwingUtil.SELECTION_ADD_CURSOR);
+		assertNotNull(SwingUtil.SELECTION_REMOVE_CURSOR);
+		assertNotNull(SwingUtil.SELECTION_SET_CURSOR);
+	}
 
 	@Test
     public void testPasswortInputOption() {

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorToolBar.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorToolBar.java	2011-01-27 13:21:45 UTC (rev 1442)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorToolBar.java	2011-01-27 13:24:10 UTC (rev 1443)
@@ -30,6 +30,7 @@
 package de.schmitzm.geotools.gui;
 
 import java.awt.event.ActionEvent;
+import java.net.URL;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
@@ -55,477 +56,527 @@
 
 /**
  * A toolbar to control the operations of a {@link JMapEditorPane}.
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ * 
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ *         (University of Bonn/Germany)
  */
 public class JMapEditorToolBar extends JToolBar {
-	private static final Logger LOGGER = Logger.getLogger(JMapEditorToolBar.class.getName());
+	private static final Logger LOGGER = Logger
+			.getLogger(JMapEditorToolBar.class.getName());
 	/** Constant for the tool "New layer" (10). */
 	public static final int LAYER_NEW = 10;
-    /** Constant for the tool "Save layer" (20). */
-    public static final int LAYER_SAVE = 20;
-    /** Constant for the tool "Cancel layer" (30). */
-    public static final int LAYER_CANCEL = 30;
-    /** Constant for the tool "Undo all editor actions" (100). */
-    public static final int EDIT_CLEAR = 100;
+	/** Constant for the tool "Save layer" (20). */
+	public static final int LAYER_SAVE = 20;
+	/** Constant for the tool "Cancel layer" (30). */
+	public static final int LAYER_CANCEL = 30;
+	/** Constant for the tool "Undo all editor actions" (100). */
+	public static final int EDIT_CLEAR = 100;
 	/** Constant for the tool "Undo last editor action" (110). */
 	public static final int EDIT_UNDO = 110;
 	/** Constant for the tool "Redo last undone editor action" (120). */
 	public static final int EDIT_REDO = 120;
-    /** Constant for the tool "Finish current segment" (130). */
-    public static final int EDIT_FINISH = 130;
+	/** Constant for the tool "Finish current segment" (130). */
+	public static final int EDIT_FINISH = 130;
 
-    /** Holds the action buttons of the bar. */
-    protected SortedMap<Integer, JButton> actionButtons = null;
+	/** Icon resource **/
+	final static URL resourceIconLayerNew = JMapEditorPane.class
+			.getResource("resource/icons/layer_new.png");
+	/** Icon resource **/
+	final static URL resourceIconLayerCancel = JMapEditorPane.class
+			.getResource("resource/icons/layer_cancel.png");
+	/** Icon resource **/
+	final static URL resourceIconEditClear = JMapEditorPane.class
+			.getResource("resource/icons/edit_clear.png");
+	/** Icon resource **/
+	final static URL resourceIconEditUndo = JMapEditorPane.class
+			.getResource("resource/icons/edit_undo.png");
+	/** Icon resource **/
+	final static URL resourceIconEditRedo = JMapEditorPane.class
+			.getResource("resource/icons/edit_redo.png");
+	/** Icon resource **/
+	final static URL resourceIconEditFinish = JMapEditorPane.class
+			.getResource("resource/icons/edit_finish.png");
 
+	/** Holds the action buttons of the bar. */
+	protected SortedMap<Integer, JButton> actionButtons = null;
+
 	/** Holds the {@link JMapEditorPane} this tool bar controls. */
 	protected JMapEditorPane editorPane = null;
-	
+
 	/** Holds the listener, that reacts on editor actions. */
 	protected JMapPaneListener mapPaneListener = null;
 
-    /**
-     * Creates a new toolbar. Notice: This toolbar does nothing
-     * until {@link #setMapPane(JMapEditorPane)} is called!
-     */
-    public JMapEditorToolBar() {
-      this(null);
-    }
-    
-    /**
+	/**
+	 * Creates a new toolbar. Notice: This toolbar does nothing until
+	 * {@link #setMapPane(JMapEditorPane)} is called!
+	 */
+	public JMapEditorToolBar() {
+		this(null);
+	}
+
+	/**
 	 * Creates a new tool bar.
-	 * @param editorPane {@link JMapEditorPane} the tool bar controls
+	 * 
+	 * @param editorPane
+	 *            {@link JMapEditorPane} the tool bar controls
 	 */
 	public JMapEditorToolBar(JMapEditorPane editorPane) {
-	  super("Control the editor actions", JToolBar.HORIZONTAL);
-      this.actionButtons   = new TreeMap<Integer,JButton>();
-      // Create a Listener to sniff the zooms on the JMapPane
-      this.mapPaneListener = new JMapPaneListener() {
-          public void performMapPaneEvent(XMapPaneEvent e) {
-              if ( !(e instanceof JEditorPaneEvent) )
-                return;
+		super("Control the editor actions", JToolBar.HORIZONTAL);
+		this.actionButtons = new TreeMap<Integer, JButton>();
+		// Create a Listener to sniff the zooms on the JMapPane
+		this.mapPaneListener = new JMapPaneListener() {
+			public void performMapPaneEvent(XMapPaneEvent e) {
+				if (!(e instanceof JEditorPaneEvent))
+					return;
 
-              // At the moment the layer editing is finished, the editor mode
-              // is not yet initialized. However for the button activation the
-              // mode NULL is essential in this case.
-              EditorMode mode = ((JEditorPaneEvent)e).getEditorMode();
-              if ( e instanceof LayerEditCanceledEvent ||
-                   e instanceof LayerEditFinishedEvent )
-                mode = null;
-              updateButtonActivation(mode);
-          }
-      };    
-     
-      setMapPane(editorPane);
-	  setFloatable(false);
-	  setRollover(true);
-	  
-	  init();
+				// At the moment the layer editing is finished, the editor mode
+				// is not yet initialized. However for the button activation the
+				// mode NULL is essential in this case.
+				EditorMode mode = ((JEditorPaneEvent) e).getEditorMode();
+				if (e instanceof LayerEditCanceledEvent
+						|| e instanceof LayerEditFinishedEvent)
+					mode = null;
+				updateButtonActivation(mode);
+			}
+		};
+
+		setMapPane(editorPane);
+		setFloatable(false);
+		setRollover(true);
+
+		init();
 	}
-	
+
 	/**
 	 * Sets the {@link JMapEditorPane} controlled by this tool bar.
-	 * @param editorPane {@link JMapEditorPane} to control (if {@code null} this
-	 *                   tool bar controls NOTHING!)
+	 * 
+	 * @param editorPane
+	 *            {@link JMapEditorPane} to control (if {@code null} this tool
+	 *            bar controls NOTHING!)
 	 */
 	public void setMapPane(JMapEditorPane editorPane) {
-	  // Remove listener from old MapPane
-	  if ( this.editorPane != null )
-	    this.editorPane.removeMapPaneListener( mapPaneListener );
-      this.editorPane = editorPane;
-      if ( this.editorPane != null && mapPaneListener != null )
-        this.editorPane.addMapPaneListener( mapPaneListener );
+		// Remove listener from old MapPane
+		if (this.editorPane != null)
+			this.editorPane.removeMapPaneListener(mapPaneListener);
+		this.editorPane = editorPane;
+		if (this.editorPane != null && mapPaneListener != null)
+			this.editorPane.addMapPaneListener(mapPaneListener);
 	}
-	
+
 	/**
-	 * Calls {@link #initActions()} and then puts all action buttons
-	 * to the tool bar.
+	 * Calls {@link #initActions()} and then puts all action buttons to the tool
+	 * bar.
 	 */
 	protected void init() {
-	  initActions();
-	  initToolBar();
-	  updateButtonActivation(null);
+		initActions();
+		initToolBar();
+		updateButtonActivation(null);
 	}
 
-    /**
-     * Creates the action buttons and adds them to {@link #actionButtons}.
-     */
-    protected void initActions() {
-      // Action button to create a new layer
-      addAction( new EditorPaneToolBarAction(
-          LAYER_NEW,
-          this,
-          "button.layer.new",
-          new ImageIcon(JMapEditorPane.class.getResource("resource/icons/layer_new.png"))
-      ), false);
+	/**
+	 * Creates the action buttons and adds them to {@link #actionButtons}.
+	 */
+	protected void initActions() {
+		// Action button to create a new layer
+		addAction(new EditorPaneToolBarAction(LAYER_NEW, this,
+				"button.layer.new", new ImageIcon(resourceIconLayerNew)), false);
 
-      // Action button to finish a layer
-      addAction( new EditorPaneToolBarAction(
-          LAYER_SAVE,
-          this,
-          "button.layer.save",
-          new ImageIcon(JMapEditorPane.class.getResource("resource/icons/layer_finish.png"))
-      ), false);
+		// Action button to finish a layer
+		final URL resourceIconLayerSave = JMapEditorPane.class
+				.getResource("resource/icons/layer_finish.png");
+		addAction(new EditorPaneToolBarAction(LAYER_SAVE, this,
+				"button.layer.save", new ImageIcon(resourceIconLayerSave)),
+				false);
 
-      // Action button to cancel a layer
-      addAction( new EditorPaneToolBarAction(
-          LAYER_CANCEL,
-          this,
-          "button.layer.cancel",
-          new ImageIcon(JMapEditorPane.class.getResource("resource/icons/layer_cancel.png"))
-      ), false);
+		// Action button to cancel a layer
+		addAction(new EditorPaneToolBarAction(LAYER_CANCEL, this,
+				"button.layer.cancel", new ImageIcon(resourceIconLayerCancel)),
+				false);
 
-      // Action button to undo all editing action
-      addAction( new EditorPaneToolBarAction(
-          EDIT_CLEAR,
-          this,
-          "button.edit.clear",
-          new ImageIcon(JMapEditorPane.class.getResource("resource/icons/edit_clear.png"))
-      ), false);
+		// Action button to undo all editing action
+		addAction(new EditorPaneToolBarAction(EDIT_CLEAR, this,
+				"button.edit.clear", new ImageIcon(resourceIconEditClear)),
+				false);
 
-      // Action button to undo a editing action
-      addAction( new EditorPaneToolBarAction(
-          EDIT_UNDO,
-          this,
-          "button.edit.undo",
-          new ImageIcon(JMapEditorPane.class.getResource("resource/icons/edit_undo.png"))
-      ), false);
+		// Action button to undo a editing action
+		addAction(new EditorPaneToolBarAction(EDIT_UNDO, this,
+				"button.edit.undo", new ImageIcon(resourceIconEditUndo)), false);
 
-      // Action button to redo a undone editing action
-      addAction( new EditorPaneToolBarAction(
-          EDIT_REDO,
-          this,
-          "button.edit.redo",
-          new ImageIcon(JMapEditorPane.class.getResource("resource/icons/edit_redo.png"))
-      ), false);
+		// Action button to redo a undone editing action
+		addAction(new EditorPaneToolBarAction(EDIT_REDO, this,
+				"button.edit.redo", new ImageIcon(resourceIconEditRedo)), false);
 
-      // Action button to finish a feature
-      addAction( new EditorPaneToolBarAction(
-          EDIT_FINISH,
-          this,
-          "button.edit.finish",
-          new ImageIcon(JMapEditorPane.class.getResource("resource/icons/edit_finish.png"))
-      ), false);
-    }
-    
-    /**
-     * Clears the GUI of all components and adds all action buttons to the
-     * tool bar.
-     */
-    protected void initToolBar() {
-      setAlignmentY( 1f );
-      removeAll();
-//      // Separator to the left of the tool actions to start
-//      // the tool buttons with the map (not with the coordinate grid)
-//      Dimension dimension = new Dimension( 49,10);
-//      addSeparator(dimension);
-//      // Space between tool buttons and action buttons
-//      Dimension dimension2 = new Dimension( 10,10);
-//      this.addSeparator(dimension2);
-      // Action buttons
-      for (JButton b : actionButtons.values())
-        add(b);
-    }
-    
+		// Action button to finish a feature
+		addAction(new EditorPaneToolBarAction(EDIT_FINISH, this,
+				"button.edit.finish", new ImageIcon(resourceIconEditFinish)),
+				false);
+	}
 
-    /**
-     * Performs the action of an action button.
-     * @param tool the action
-     * @param e    the event of the button
-     */
+	/**
+	 * Clears the GUI of all components and adds all action buttons to the tool
+	 * bar.
+	 */
+	protected void initToolBar() {
+		setAlignmentY(1f);
+		removeAll();
+		// // Separator to the left of the tool actions to start
+		// // the tool buttons with the map (not with the coordinate grid)
+		// Dimension dimension = new Dimension( 49,10);
+		// addSeparator(dimension);
+		// // Space between tool buttons and action buttons
+		// Dimension dimension2 = new Dimension( 10,10);
+		// this.addSeparator(dimension2);
+		// Action buttons
+		for (JButton b : actionButtons.values())
+			add(b);
+	}
+
+	/**
+	 * Performs the action of an action button.
+	 * 
+	 * @param tool
+	 *            the action
+	 * @param e
+	 *            the event of the button
+	 */
 	protected void performActionButton(int action, ActionEvent e) {
-      if ( editorPane == null )
-        return;
-      
-      try {
-        // Perform the action "New layer"
-        if ( action == LAYER_NEW )
-          createNewLayer();
-        // Perform the action "Finish layer"
-        if ( action == LAYER_SAVE )
-          editorPane.finishEditing();
-        // Perform the action "Cancel layer"
-        if ( action == LAYER_CANCEL )
-          editorPane.cancelEditing();
-  
-        // Perform the action "Finish feature"
-        if ( action == EDIT_FINISH )
-          editorPane.finishFeature();
-        // Perform the action "Undo editing"
-        if ( action == EDIT_UNDO )
-          editorPane.undoEditing();
-        // Perform the action "Redo editing"
-        if ( action == EDIT_REDO )
-          editorPane.redoEditing();
-        // Perform the action "Clear editing"
-        if ( action == EDIT_CLEAR )
-          editorPane.undoAll();
-      } catch (Exception err) {
-        ExceptionDialog.show(err);
-      }
+		if (editorPane == null)
+			return;
+
+		try {
+			// Perform the action "New layer"
+			if (action == LAYER_NEW)
+				createNewLayer();
+			// Perform the action "Finish layer"
+			if (action == LAYER_SAVE)
+				editorPane.finishEditing();
+			// Perform the action "Cancel layer"
+			if (action == LAYER_CANCEL)
+				editorPane.cancelEditing();
+
+			// Perform the action "Finish feature"
+			if (action == EDIT_FINISH)
+				editorPane.finishFeature();
+			// Perform the action "Undo editing"
+			if (action == EDIT_UNDO)
+				editorPane.undoEditing();
+			// Perform the action "Redo editing"
+			if (action == EDIT_REDO)
+				editorPane.redoEditing();
+			// Perform the action "Clear editing"
+			if (action == EDIT_CLEAR)
+				editorPane.undoAll();
+		} catch (Exception err) {
+			ExceptionDialog.show(err);
+		}
 	}
-	
+
 	/**
-	 * Sets the enables/disables property for every toolbar button according 
-	 * to the current editor state. 
-	 * @param editorMode editor mode (because some events are fired BEFORE
-	 *                   the new mode is set)
+	 * Sets the enables/disables property for every toolbar button according to
+	 * the current editor state.
+	 * 
+	 * @param editorMode
+	 *            editor mode (because some events are fired BEFORE the new mode
+	 *            is set)
 	 */
 	protected void updateButtonActivation(EditorMode editorMode) {
-	  if ( editorPane == null ) {
-	    setAllActionsEnabled(false, false);
-	    return;
-	  }
-      getButton( LAYER_NEW ).setEnabled( editorMode == null );
-	  getButton( LAYER_SAVE ).setEnabled( editorMode != null );
-      getButton( LAYER_CANCEL ).setEnabled( editorMode != null );
-      getButton( EDIT_UNDO ).setEnabled( editorPane.isUndoPossible() );
-      getButton( EDIT_REDO ).setEnabled( editorPane.isRedoPossible() );
-      getButton( EDIT_CLEAR ).setEnabled( editorPane.isUndoPossible() );
-      getButton( EDIT_FINISH ).setEnabled( editorMode != null && editorMode != EditorMode.New_Point );
+		if (editorPane == null) {
+			setAllActionsEnabled(false, false);
+			return;
+		}
+		getButton(LAYER_NEW).setEnabled(editorMode == null);
+		getButton(LAYER_SAVE).setEnabled(editorMode != null);
+		getButton(LAYER_CANCEL).setEnabled(editorMode != null);
+		getButton(EDIT_UNDO).setEnabled(editorPane.isUndoPossible());
+		getButton(EDIT_REDO).setEnabled(editorPane.isRedoPossible());
+		getButton(EDIT_CLEAR).setEnabled(editorPane.isUndoPossible());
+		getButton(EDIT_FINISH).setEnabled(
+				editorMode != null && editorMode != EditorMode.New_Point);
 	}
-	
+
 	/**
 	 * Starts new layer.
 	 */
 	protected void createNewLayer() {
-	  // Ask layer type and name
-	  ManualInputOption.Text titleOption = new ManualInputOption.Text(
-	      getResourceString("NewLayer.layer.title"), true, getResourceString("NewLayer.layer.title.default")
-      );
-	  SelectionInputOption.Radio<JMapEditorPane.EditorMode> typeOption = new SelectionInputOption.Radio<JMapEditorPane.EditorMode>(
-          getResourceString("NewLayer.layer.type"),
-          true,
-          new JMapEditorPane.EditorMode[] { EditorMode.New_Point, EditorMode.New_Line, EditorMode.New_Polygon },
-          new String[] { getResourceString("NewLayer.layer.type.point"), getResourceString("NewLayer.layer.type.line"), getResourceString("NewLayer.layer.type.polygon") }
-	  );
-	  FeatureTypeInputOption ftOption = new FeatureTypeInputOption(
-	      getResourceString("NewLayer.ftype.title"),
-	      false
-	  ) {
-	        // Checks whether "the_geom" is used as attribute name
-	        // --> not allowed because JEditorPane uses this attribute
-	        //     for the default geometry of new layers
-    	    public boolean performIsInputValid() {
-    	      if ( super.performIsInputValid() ) {
-    	        SimpleFeatureType ft = inpTableModel.createFeatureType();
-    	        if ( ft.getDescriptor( JMapEditorPane.GEOMETRY_ATTR ) != null )
-    	          throw new UnsupportedOperationException(getResourceString("NewLayer.Err.GeomAttr",JMapEditorPane.GEOMETRY_ATTR));
-    	      }
-    	      return true;
-    	    }
-	  };
-	  Object[] value = MultipleOptionPane.showMultipleInputDialog(
-	      this,
-	      getResourceString("NewLayer.dialog.title"),
-	      titleOption,
-	      typeOption,
-	      ftOption
-	  );
-	  if ( value == null )
-	    return; // Dialog canceled
-	  editorPane.setAdditionalAttributes( ftOption.getValue() );
-	  editorPane.startEditing(
-	      (JMapEditorPane.EditorMode)value[1],
-	      (String)value[0]
-	  );
+		// Ask layer type and name
+		ManualInputOption.Text titleOption = new ManualInputOption.Text(
+				getResourceString("NewLayer.layer.title"), true,
+				getResourceString("NewLayer.layer.title.default"));
+		SelectionInputOption.Radio<JMapEditorPane.EditorMode> typeOption = new SelectionInputOption.Radio<JMapEditorPane.EditorMode>(
+				getResourceString("NewLayer.layer.type"), true,
+				new JMapEditorPane.EditorMode[] { EditorMode.New_Point,
+						EditorMode.New_Line, EditorMode.New_Polygon },
+				new String[] { getResourceString("NewLayer.layer.type.point"),
+						getResourceString("NewLayer.layer.type.line"),
+						getResourceString("NewLayer.layer.type.polygon") });
+		FeatureTypeInputOption ftOption = new FeatureTypeInputOption(
+				getResourceString("NewLayer.ftype.title"), false) {
+			// Checks whether "the_geom" is used as attribute name
+			// --> not allowed because JEditorPane uses this attribute
+			// for the default geometry of new layers
+			public boolean performIsInputValid() {
+				if (super.performIsInputValid()) {
+					SimpleFeatureType ft = inpTableModel.createFeatureType();
+					if (ft.getDescriptor(JMapEditorPane.GEOMETRY_ATTR) != null)
+						throw new UnsupportedOperationException(
+								getResourceString("NewLayer.Err.GeomAttr",
+										JMapEditorPane.GEOMETRY_ATTR));
+				}
+				return true;
+			}
+		};
+		Object[] value = MultipleOptionPane.showMultipleInputDialog(this,
+				getResourceString("NewLayer.dialog.title"), titleOption,
+				typeOption, ftOption);
+		if (value == null)
+			return; // Dialog canceled
+		editorPane.setAdditionalAttributes(ftOption.getValue());
+		editorPane.startEditing((JMapEditorPane.EditorMode) value[1],
+				(String) value[0]);
 	}
 
-    /**
-     * Adds an action to the tool bar. Does nothing if a tool or action with the
-     * specified ID already exists!
-     * @param buttonAction action for the button
-     * @param resetToolBar indicates whether the toolbar GUI is reset after adding
-     *                     the button (if adding several actions it useful only to
-     *                     reset the GUI for the last added tool) 
-     */
-    public void addAction(EditorPaneToolBarAction buttonAction, boolean resetToolBar) {
-      if ( isButtonIDUsed(buttonAction.getID()) ) {
-        LOGGER.warn("addAction(.) ignored because ID already used for tool or action: "+buttonAction.getID());
-        return;
-      }
-      JButton button = new JButton(buttonAction);
-      actionButtons.put( buttonAction.getID(), button );
-      if ( resetToolBar )
-        initToolBar();
-    }
+	/**
+	 * Adds an action to the tool bar. Does nothing if a tool or action with the
+	 * specified ID already exists!
+	 * 
+	 * @param buttonAction
+	 *            action for the button
+	 * @param resetToolBar
+	 *            indicates whether the toolbar GUI is reset after adding the
+	 *            button (if adding several actions it useful only to reset the
+	 *            GUI for the last added tool)
+	 */
+	public void addAction(EditorPaneToolBarAction buttonAction,
+			boolean resetToolBar) {
+		if (isButtonIDUsed(buttonAction.getID())) {
+			LOGGER.warn("addAction(.) ignored because ID already used for tool or action: "
+					+ buttonAction.getID());
+			return;
+		}
+		JButton button = new JButton(buttonAction);
+		actionButtons.put(buttonAction.getID(), button);
+		if (resetToolBar)
+			initToolBar();
+	}
 
-    /**
-     * Adds an action to the tool bar and resets the toolbar GUI.
-     * @param buttonAction action for the toggle button
-     */
-    public void addAction(EditorPaneToolBarAction buttonAction) {
-      addAction(buttonAction, true);
-    }
-    
-    /**
-     * Returns the button for a specific tool or action.
-     * @param id the constant for a tool
-     * @return a {@link JButton} if {@code id} specifies an {@linkplain #getActionButton(int) action button}
-     *         or {@link JToogleButton} if {@code id} specifies a {@linkplain #getToolButton(int) tool button}
-     */
-    public AbstractButton getButton(int id) {
-      AbstractButton button = actionButtons.get(id);
-      if ( button == null )
-        LOGGER.warn("Unknown action ID: "+id);
-      return button;
-    }
+	/**
+	 * Adds an action to the tool bar and resets the toolbar GUI.
+	 * 
+	 * @param buttonAction
+	 *            action for the toggle button
+	 */
+	public void addAction(EditorPaneToolBarAction buttonAction) {
+		addAction(buttonAction, true);
+	}
 
-    /**
-     * Returns the button for a specific action.
-     * @param action the constant an action 
-     */
-    public JButton getActionButton(int action) {
-      AbstractButton button = getButton(action);
-      if ( button != null && !(button instanceof JButton) ) {
-        LOGGER.warn("ID specifies no action: "+action);
-        button = null;
-      }
-      return (JButton)button; 
+	/**
+	 * Returns the button for a specific tool or action.
+	 * 
+	 * @param id
+	 *            the constant for a tool
+	 * @return a {@link JButton} if {@code id} specifies an
+	 *         {@linkplain #getActionButton(int) action button} or
+	 *         {@link JToogleButton} if {@code id} specifies a
+	 *         {@linkplain #getToolButton(int) tool button}
+	 */
+	public AbstractButton getButton(int id) {
+		AbstractButton button = actionButtons.get(id);
+		if (button == null)
+			LOGGER.warn("Unknown action ID: " + id);
+		return button;
+	}
 
-    }
+	/**
+	 * Returns the button for a specific action.
+	 * 
+	 * @param action
+	 *            the constant an action
+	 */
+	public JButton getActionButton(int action) {
+		AbstractButton button = getButton(action);
+		if (button != null && !(button instanceof JButton)) {
+			LOGGER.warn("ID specifies no action: " + action);
+			button = null;
+		}
+		return (JButton) button;
 
-    /**
-     * Sets whether an action is activated or not. The visible property
-     * of the button is not affected.
-     * @param id actionID
-     * @param enabled if {@code true} the action becomes available
-     */
-    public void setButtonEnabled(int id, boolean enabled) {
-      AbstractButton button = getButton(id);
-      if ( button == null )
-        return;
-      button.setEnabled( enabled );
-    }
+	}
 
-    /**
-     * Sets whether an action is activated or not.
-     * @param id actionID
-     * @param enabled if {@code true} the tool becomes available
-     * @param hideOnDisable if {@code true} the button is also hidden if
-     *                      {@code enabled} is {@code false}
-     */
+	/**
+	 * Sets whether an action is activated or not. The visible property of the
+	 * button is not affected.
+	 * 
+	 * @param id
+	 *            actionID
+	 * @param enabled
+	 *            if {@code true} the action becomes available
+	 */
+	public void setButtonEnabled(int id, boolean enabled) {
+		AbstractButton button = getButton(id);
+		if (button == null)
+			return;
+		button.setEnabled(enabled);
+	}
+
+	/**
+	 * Sets whether an action is activated or not.
+	 * 
+	 * @param id
+	 *            actionID
+	 * @param enabled
+	 *            if {@code true} the tool becomes available
+	 * @param hideOnDisable
+	 *            if {@code true} the button is also hidden if {@code enabled}
+	 *            is {@code false}
+	 */
 	public void setButtonEnabled(int id, boolean enabled, boolean hideOnDisable) {
-	  AbstractButton button = getButton(id);
-	  if ( button == null )
-	    return;
-	  button.setEnabled( enabled );
-	  // if button is enabled, it becomes visible anyway
-	  // if button is disabled and the "hide" option is set, it is also hidden 
-	  if ( enabled )
-	    button.setVisible( true );
-	  else
-	    button.setVisible( !hideOnDisable );
+		AbstractButton button = getButton(id);
+		if (button == null)
+			return;
+		button.setEnabled(enabled);
+		// if button is enabled, it becomes visible anyway
+		// if button is disabled and the "hide" option is set, it is also hidden
+		if (enabled)
+			button.setVisible(true);
+		else
+			button.setVisible(!hideOnDisable);
 	}
 
-    /**
-     * Checks whether a ID is already used for a tool or action.
-     * @param tool tool ID
-     */
-    public boolean isButtonIDUsed(int id) {
-      return actionButtons.get(id) != null;
-    }
+	/**
+	 * Checks whether a ID is already used for a tool or action.
+	 * 
+	 * @param tool
+	 *            tool ID
+	 */
+	public boolean isButtonIDUsed(int id) {
+		return actionButtons.get(id) != null;
+	}
 
-    /**
-     * Checks whether a tool is activated.
-     * @param tool tool ID
-     * @return {@code false} if an unknown ID is specified
-     */
-    public boolean isButtonEnabled(int id) {
-      AbstractButton button = getButton(id);
-      if ( button != null )
-        return button.isEnabled();
-      return false;
-    }
+	/**
+	 * Checks whether a tool is activated.
+	 * 
+	 * @param tool
+	 *            tool ID
+	 * @return {@code false} if an unknown ID is specified
+	 */
+	public boolean isButtonEnabled(int id) {
+		AbstractButton button = getButton(id);
+		if (button != null)
+			return button.isEnabled();
+		return false;
+	}
 
-    /**
-     * Sets the activation for all actions.
-     * @param enabled if {@code true} all actions becomes available
-     * @param hideOnDisable if {@code true} the buttons are also hidden if
-     *                      {@code enabled} is {@code false}
-     */
-    public void setAllActionsEnabled(boolean enabled, boolean hideOnDisable) {
-      for (int tool : actionButtons.keySet())
-        setButtonEnabled(tool,enabled,hideOnDisable);
-    }   
-    
-    /**
-     * Returns the maximum ID of actions. 
-     */
-    public int getMaxActionID() {
-      return actionButtons.lastKey();
-    }
+	/**
+	 * Sets the activation for all actions.
+	 * 
+	 * @param enabled
+	 *            if {@code true} all actions becomes available
+	 * @param hideOnDisable
+	 *            if {@code true} the buttons are also hidden if {@code enabled}
+	 *            is {@code false}
+	 */
+	public void setAllActionsEnabled(boolean enabled, boolean hideOnDisable) {
+		for (int tool : actionButtons.keySet())
+			setButtonEnabled(tool, enabled, hideOnDisable);
+	}
 
-    /**
-     * Returns the minimum ID of actions. 
-     */
-    public int getMinActionID() {
-      return actionButtons.firstKey();
-    }
-    
-    protected static String getResourceString(String key, Object... params) {
-      return GeotoolsGUIUtil.RESOURCE.getString("schmitzm.geotools.gui.JMapEditorToolBar."+key,params);
-    }
-    
-    /**
-     * Extends the {@link AbstractAction} with maintaining an ID and
-     * the {@link JMapEditorToolBar} the action controls.
-     * Additionally this class automatically calls
-     * {@link JMapEditorToolBar#performActionButton(int, ActionEvent)}.
-     * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
-     */
-    public static class EditorPaneToolBarAction extends AbstractAction {
-      /** The ID of the action */
-      protected int id = -1;
-      /** The tool bar, this action is made for. */
-      protected JMapEditorToolBar toolBar = null;
+	/**
+	 * Returns the maximum ID of actions.
+	 */
+	public int getMaxActionID() {
+		return actionButtons.lastKey();
+	}
 
-      /**
-       * Creates a new action with a dummy description and no icon.
-       * @param id      unique ID for the action
-       * @param toolBar toolbar this action is made for
-       */
-      public EditorPaneToolBarAction(int id, JMapEditorToolBar toolBar) {
-        this(id,toolBar,""+id);
-      }
+	/**
+	 * Returns the minimum ID of actions.
+	 */
+	public int getMinActionID() {
+		return actionButtons.firstKey();
+	}
 
-      /**
-       * Creates a new action without an icon.
-       * @param id      unique ID for the action
-       * @param toolBar toolbar this action is made for
-       * @param name    description used for buttons or menus 
-       */
-      public EditorPaneToolBarAction(int id, JMapEditorToolBar toolBar, String name) {
-        this(id,toolBar,name,null);
-      }
+	protected static String getResourceString(String key, Object... params) {
+		return GeotoolsGUIUtil.RESOURCE.getString(
+				"schmitzm.geotools.gui.JMapEditorToolBar." + key, params);
+	}
 
-      /**
-       * Creates a new action.
-       * @param id      unique ID for the action
-       * @param toolBar toolbar this action is made for
-       * @param name    description used for buttons or menus 
-       * @param icon    icon used for buttons or menus 
-       */
-      public EditorPaneToolBarAction(int id, JMapEditorToolBar toolBar, String name, Icon icon) {
-        super("",icon);
-        this.id      = id;
-        this.toolBar = toolBar;
-        this.putValue(SHORT_DESCRIPTION, getResourceString(name));
-      }
+	/**
+	 * Extends the {@link AbstractAction} with maintaining an ID and the
+	 * {@link JMapEditorToolBar} the action controls. Additionally this class
+	 * automatically calls
+	 * {@link JMapEditorToolBar#performActionButton(int, ActionEvent)}.
+	 * 
+	 * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+	 *         (University of Bonn/Germany)
+	 */
+	public static class EditorPaneToolBarAction extends AbstractAction {
+		/** The ID of the action */
+		protected int id = -1;
+		/** The tool bar, this action is made for. */
+		protected JMapEditorToolBar toolBar = null;
 
-      /**
-       * Calls {@link JMapEditorToolBar#performActionButton(int, ActionEvent)}.
-       */
-      public void actionPerformed(ActionEvent e) {
-        if ( toolBar.actionButtons.get(id) != null )
-          toolBar.performActionButton(id, e);
-      }
-      
-      /**
-       * Returns the (unique) id of this action.
-       * @return
-       */
-      public int getID() {
-        return id;
-      }
-    }
+		/**
+		 * Creates a new action with a dummy description and no icon.
+		 * 
+		 * @param id
+		 *            unique ID for the action
+		 * @param toolBar
+		 *            toolbar this action is made for
+		 */
+		public EditorPaneToolBarAction(int id, JMapEditorToolBar toolBar) {
+			this(id, toolBar, "" + id);
+		}
+
+		/**
+		 * Creates a new action without an icon.
+		 * 
+		 * @param id
+		 *            unique ID for the action
+		 * @param toolBar
+		 *            toolbar this action is made for
+		 * @param name
+		 *            description used for buttons or menus
+		 */
+		public EditorPaneToolBarAction(int id, JMapEditorToolBar toolBar,
+				String name) {
+			this(id, toolBar, name, null);
+		}
+
+		/**
+		 * Creates a new action.
+		 * 
+		 * @param id
+		 *            unique ID for the action
+		 * @param toolBar
+		 *            toolbar this action is made for
+		 * @param name
+		 *            description used for buttons or menus
+		 * @param icon
+		 *            icon used for buttons or menus
+		 */
+		public EditorPaneToolBarAction(int id, JMapEditorToolBar toolBar,
+				String name, Icon icon) {
+			super("", icon);
+			this.id = id;
+			this.toolBar = toolBar;
+			this.putValue(SHORT_DESCRIPTION, getResourceString(name));
+		}
+
+		/**
+		 * Calls {@link JMapEditorToolBar#performActionButton(int, ActionEvent)}
+		 * .
+		 */
+		public void actionPerformed(ActionEvent e) {
+			if (toolBar.actionButtons.get(id) != null)
+				toolBar.performActionButton(id, e);
+		}
+
+		/**
+		 * Returns the (unique) id of this action.
+		 * 
+		 * @return
+		 */
+		public int getID() {
+			return id;
+		}
+	}
 }

Added: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/JMapEditorToolBarTest.java
===================================================================
--- trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/JMapEditorToolBarTest.java	2011-01-27 13:21:45 UTC (rev 1442)
+++ trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/JMapEditorToolBarTest.java	2011-01-27 13:24:10 UTC (rev 1443)
@@ -0,0 +1,31 @@
+package de.schmitzm.geotools.gui;
+
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JMapEditorToolBarTest {
+
+	@Before
+	public void setUp() throws Exception {
+	}
+
+	@After
+	public void tearDown() throws Exception {
+	}
+	
+	@Test
+	public void testIcons() {
+		assertNotNull(JMapEditorToolBar.resourceIconLayerNew);
+		assertNotNull(JMapEditorToolBar.resourceIconLayerCancel);
+		assertNotNull(JMapEditorToolBar.resourceIconEditClear);
+		assertNotNull(JMapEditorToolBar.resourceIconEditUndo );
+		assertNotNull(JMapEditorToolBar.resourceIconEditRedo );
+		assertNotNull(JMapEditorToolBar.resourceIconEditFinish);
+
+	}
+
+}


Property changes on: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/JMapEditorToolBarTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native

Added: trunk/schmitzm-jfree/src/test/java/de/schmitzm/jfree/chart/SelectableChartPanelTest.java
===================================================================
--- trunk/schmitzm-jfree/src/test/java/de/schmitzm/jfree/chart/SelectableChartPanelTest.java	2011-01-27 13:21:45 UTC (rev 1442)
+++ trunk/schmitzm-jfree/src/test/java/de/schmitzm/jfree/chart/SelectableChartPanelTest.java	2011-01-27 13:24:10 UTC (rev 1443)
@@ -0,0 +1,15 @@
+package de.schmitzm.jfree.chart;
+
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+public class SelectableChartPanelTest {
+
+	@Test
+	public void testIcon() {
+		assertNotNull(SelectableChartPanel.ICON_ZOOM_TO_SELECTED); 
+	}
+
+}


Property changes on: trunk/schmitzm-jfree/src/test/java/de/schmitzm/jfree/chart/SelectableChartPanelTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native



More information about the Schmitzm-commits mailing list