/[schmitzm]/trunk/src/skrueger/geotools/MapPaneToolBar.java
ViewVC logotype

Diff of /trunk/src/skrueger/geotools/MapPaneToolBar.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 140 by alfonx, Sun Jun 14 17:24:44 2009 UTC revision 151 by alfonx, Fri Jun 19 16:22:29 2009 UTC
# Line 8  import java.util.TreeMap; Line 8  import java.util.TreeMap;
8    
9  import javax.swing.AbstractAction;  import javax.swing.AbstractAction;
10  import javax.swing.AbstractButton;  import javax.swing.AbstractButton;
11    import javax.swing.Action;
12  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
13  import javax.swing.Icon;  import javax.swing.Icon;
14  import javax.swing.ImageIcon;  import javax.swing.ImageIcon;
# Line 246  public class MapPaneToolBar extends JToo Line 247  public class MapPaneToolBar extends JToo
247           * Clears the GUI of all components and adds all tool and action buttons to           * Clears the GUI of all components and adds all tool and action buttons to
248           * the tool bar.           * the tool bar.
249           */           */
250          protected void initToolBar() {          public void initToolBar() {
251                  setAlignmentY(1f);                  setAlignmentY(1f);
252                  removeAll();                  removeAll();
253                  // Separator to the left of the tool actions to start                  // Separator to the left of the tool actions to start
# Line 256  public class MapPaneToolBar extends JToo Line 257  public class MapPaneToolBar extends JToo
257                  // Tool buttons                  // Tool buttons
258                  for (JComponent b : toolAndActionButtons.values())                  for (JComponent b : toolAndActionButtons.values())
259                          add(b);                          add(b);
260    
261                    repaint();
262    
263                    if (!toolAndActionButtons.containsKey(selectedTool)) {
264                            /**
265                             * This might be a bit specific, but IF selection buttons are
266                             * available, select one of them.. if not, select the INFO tool.
267                             */
268    
269                            if (toolAndActionButtons.containsKey(TOOL_SELECTION_SET)) {
270                                    setSelectedTool(TOOL_SELECTION_SET);
271                            } else if (toolAndActionButtons.containsKey(TOOL_INFO)) {
272                                    setSelectedTool(TOOL_INFO);
273                            } else {
274                                    // TODO What to do now?!
275                                    setSelectedTool(null);
276                            }
277    
278                    }
279          }          }
280    
281          // Space between tool buttons and action buttons          // Space between tool buttons and action buttons
# Line 294  public class MapPaneToolBar extends JToo Line 314  public class MapPaneToolBar extends JToo
314                          // Set the mouse tool to "Info"                          // Set the mouse tool to "Info"
315                          mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setWindowSelectionState(JMapPane.NONE);
316                          mapPane.setState(JMapPane.SELECT_TOP); // Why not:                          mapPane.setState(JMapPane.SELECT_TOP); // Why not:
317                                                                                                          // JMapPane.SELECT_TOP_ONEONLY                          // JMapPane.SELECT_TOP_ONEONLY
318                          mapPane.setHighlight(false);// SK: Was true, but since it not works                          mapPane.setHighlight(false);// SK: Was true, but since it not works
319                                                                                  // properly removed it to save                          // properly removed it to save
320                                                                                  // performance                          // performance
321                          mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR);                          mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR);
322                          break;                          break;
323                  case TOOL_ZOOMIN:                  case TOOL_ZOOMIN:
# Line 314  public class MapPaneToolBar extends JToo Line 334  public class MapPaneToolBar extends JToo
334                          mapPane.setHighlight(false);                          mapPane.setHighlight(false);
335                          mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR);                          mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR);
336                          break;                          break;
337  //              default:                  default:
338  //                      // Set map actions to default                          // Set map actions to default
339  //                      mapPane.setWindowSelectionState(JMapPane.NONE);                          mapPane.setWindowSelectionState(JMapPane.NONE);
340  //                      mapPane.setState(JMapPane.NONE);                          mapPane.setState(JMapPane.NONE);
341  //                      mapPane.setHighlight(false);                          mapPane.setHighlight(false);
342  //                      mapPane.setNormalCursor(null);                          mapPane.setNormalCursor(null);
343  //                      break;                          break;
344                  }                  }
345                  mapPane.updateCursor();                  mapPane.updateCursor();
346          }          }
347            
348          /**          /**
349           * @param id The ID of the Component to remove           * @param id
350             *            The ID of the Component to remove. The change will not be
351             *            visible until {@link #initToolBar()} is called.
352           * @return <code>null</code> or the component that has been removed.           * @return <code>null</code> or the component that has been removed.
353           */           */
354          public JComponent removeId(int id){          public JComponent removeId(int id) {
355                  return toolAndActionButtons.remove(id);                  return toolAndActionButtons.remove(id);
356          }          }
357    
# Line 519  public class MapPaneToolBar extends JToo Line 541  public class MapPaneToolBar extends JToo
541                          return;                          return;
542                  button.setSelected(true);                  button.setSelected(true);
543                  button.getAction().actionPerformed(null);                  button.getAction().actionPerformed(null);
544    
545                    selectedTool = tool;
546          }          }
547    
548          /**          /**
# Line 701  public class MapPaneToolBar extends JToo Line 725  public class MapPaneToolBar extends JToo
725                   */                   */
726                  public MapPaneToolBarAction(int id, MapPaneToolBar toolBar,                  public MapPaneToolBarAction(int id, MapPaneToolBar toolBar,
727                                  String name, Icon icon) {                                  String name, Icon icon) {
728                            this (id, toolBar, name, icon, null);
729                    }
730                    
731                    /**
732                     * Creates a new action.
733                     *
734                     * @param id
735                     *            unique ID for the action
736                     * @param toolBar
737                     *            The {@link MapPaneToolBar} this action is made for
738                     * @param name
739                     *            description used for buttons or menus
740                     * @param icon
741                     *            icon used for buttons or menus
742                     * @param toolTip
743                     *            Tooltip to use for the button or menu
744                     */
745                    public MapPaneToolBarAction(int id, MapPaneToolBar toolBar,
746                                    String name, Icon icon, String toolTip) {
747                          super(name, icon);                          super(name, icon);
748                            
749                            if (toolTip != null && !toolTip.trim().isEmpty()){
750                                    putValue(Action.SHORT_DESCRIPTION, toolTip);
751                            }
752                            
753                          this.id = id;                          this.id = id;
754                          this.toolBar = toolBar;                          this.toolBar = toolBar;
755                  }                  }

Legend:
Removed from v.140  
changed lines
  Added in v.151

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26