25 |
* |
* |
26 |
* Contributors: |
* Contributors: |
27 |
* Martin O. J. Schmitz - initial API and implementation |
* Martin O. J. Schmitz - initial API and implementation |
28 |
* Stefan A. Krüger - additional utility classes |
* Stefan A. Tzeggai - additional utility classes |
29 |
******************************************************************************/ |
******************************************************************************/ |
30 |
package skrueger.geotools; |
package skrueger.geotools; |
31 |
|
|
35 |
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
36 |
import java.util.ArrayList; |
import java.util.ArrayList; |
37 |
import java.util.HashSet; |
import java.util.HashSet; |
|
import java.util.Locale; |
|
38 |
import java.util.Set; |
import java.util.Set; |
39 |
import java.util.SortedMap; |
import java.util.SortedMap; |
40 |
import java.util.TreeMap; |
import java.util.TreeMap; |
51 |
|
|
52 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
53 |
|
|
54 |
|
import schmitzm.geotools.gui.GeotoolsGUIUtil; |
55 |
import schmitzm.geotools.gui.SelectableXMapPane; |
import schmitzm.geotools.gui.SelectableXMapPane; |
56 |
|
import schmitzm.geotools.gui.XMapPaneEvent; |
57 |
|
import schmitzm.geotools.gui.XMapPaneTool; |
58 |
import schmitzm.geotools.map.event.JMapPaneListener; |
import schmitzm.geotools.map.event.JMapPaneListener; |
59 |
import schmitzm.geotools.map.event.MapAreaChangedEvent; |
import schmitzm.geotools.map.event.MapAreaChangedEvent; |
|
import schmitzm.geotools.map.event.MapPaneEvent; |
|
|
import schmitzm.lang.LangUtil; |
|
|
import schmitzm.lang.ResourceProvider; |
|
60 |
import schmitzm.swing.ButtonGroup; |
import schmitzm.swing.ButtonGroup; |
|
import schmitzm.swing.SwingUtil; |
|
61 |
import skrueger.swing.SmallButton; |
import skrueger.swing.SmallButton; |
62 |
import skrueger.swing.SmallToggleButton; |
import skrueger.swing.SmallToggleButton; |
63 |
|
|
72 |
* |
* |
73 |
* @author <a href="mailto:[email protected]">Martin Schmitz</a> |
* @author <a href="mailto:[email protected]">Martin Schmitz</a> |
74 |
* (University of Bonn/Germany) |
* (University of Bonn/Germany) |
75 |
* @version 1.2 Stefan Krüger |
* @version 1.2 Stefan Tzeggai |
76 |
*/ |
*/ |
77 |
public class MapPaneToolBar extends JToolBar { |
public class MapPaneToolBar extends JToolBar { |
78 |
private static final Logger LOGGER = Logger.getLogger(MapPaneToolBar.class |
private static final Logger LOGGER = Logger.getLogger(MapPaneToolBar.class |
79 |
.getName()); |
.getName()); |
80 |
|
|
|
public static ResourceProvider RESOURCE = new ResourceProvider(LangUtil |
|
|
.extendPackagePath(MapPaneToolBar.class, |
|
|
"resource.locales.mapPaneToolbar"), Locale.ENGLISH); |
|
|
|
|
81 |
public static String R(String key, Object... values) { |
public static String R(String key, Object... values) { |
82 |
return RESOURCE.getString(key, values); |
return GeotoolsGUIUtil.R(key, values); |
83 |
} |
} |
84 |
|
|
85 |
/** Constant for the tool "Panning" (10). */ |
/** Constant for the tool "Panning" (10). */ |
203 |
|
|
204 |
// Create a Listener to listen to the zooms on the JMapPane |
// Create a Listener to listen to the zooms on the JMapPane |
205 |
this.mapPaneListener = new JMapPaneListener() { |
this.mapPaneListener = new JMapPaneListener() { |
206 |
public void performMapPaneEvent(MapPaneEvent e) { |
public void performMapPaneEvent(XMapPaneEvent e) { |
207 |
if (!(e instanceof MapAreaChangedEvent)) |
if (!(e instanceof MapAreaChangedEvent)) |
208 |
return; |
return; |
209 |
|
|
301 |
* super.initTools()}. |
* super.initTools()}. |
302 |
*/ |
*/ |
303 |
protected void initToolsAndActions() { |
protected void initToolsAndActions() { |
304 |
// Panning |
// Pan |
|
// addTool(new MapPaneToolBarAction(TOOL_PAN, this, "", new ImageIcon( |
|
|
// MapView.class.getResource("resource/icons/pan.png")), |
|
|
// R("MapPaneButtons.Pan.TT")), false); |
|
|
|
|
305 |
addTool(new MapPaneToolBarAction(TOOL_PAN, this, XMapPaneTool.PAN), false); |
addTool(new MapPaneToolBarAction(TOOL_PAN, this, XMapPaneTool.PAN), false); |
306 |
|
|
307 |
// Info |
// Info |
|
// addTool(new MapPaneToolBarAction(TOOL_INFO, this, "", new ImageIcon( |
|
|
// MapView.class.getResource("resource/icons/info.png")), |
|
|
// R("MapPaneButtons.Info.TT")), false); |
|
308 |
addTool(new MapPaneToolBarAction(TOOL_INFO, this, XMapPaneTool.INFO), false); |
addTool(new MapPaneToolBarAction(TOOL_INFO, this, XMapPaneTool.INFO), false); |
309 |
|
|
310 |
// Zoom in |
// Zoom in |
313 |
// Zoom out |
// Zoom out |
314 |
addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, XMapPaneTool.ZOOM_OUT), false); |
addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, XMapPaneTool.ZOOM_OUT), false); |
315 |
|
|
|
|
|
|
// // Zoom in |
|
|
// addTool(new MapPaneToolBarAction(TOOL_ZOOMIN, this, "", new ImageIcon( |
|
|
// MapView.class.getResource("resource/icons/zoom_in.png")), |
|
|
// R("MapPaneButtons.ZoomIn.TT")), false); |
|
|
// |
|
|
// // Zoom out |
|
|
// addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, "", new ImageIcon( |
|
|
// MapView.class.getResource("resource/icons/zoom_out.png")), |
|
|
// R("MapPaneButtons.ZoomOut.TT")), false); |
|
|
|
|
|
|
|
|
|
|
316 |
// Action button to revert the last zoom |
// Action button to revert the last zoom |
317 |
addAction(new MapPaneToolBarAction(ACTION_ZOOM_BACK, this, "", |
addAction(new MapPaneToolBarAction(ACTION_ZOOM_BACK, this, "", |
318 |
new ImageIcon(MapView.class |
new ImageIcon(MapView.class |
342 |
* the tool bar. |
* the tool bar. |
343 |
*/ |
*/ |
344 |
public void initToolBar() { |
public void initToolBar() { |
|
// setOpaque(true); |
|
|
// |
|
|
// setAlignmentY(1f); |
|
|
// setAlignmentX(0.5f); |
|
345 |
removeAll(); |
removeAll(); |
346 |
|
|
347 |
// // Separator to the left of the tool actions to start |
// // Separator to the left of the tool actions to start |
384 |
repaint(); |
repaint(); |
385 |
} |
} |
386 |
|
|
|
// Space between tool buttons and action buttons |
|
|
// SK: Seperators are now als manages like actions and tools |
|
|
// Dimension dimension2 = new Dimension( 10,10); |
|
|
// this.addSeparator(dimension2); |
|
|
|
|
|
// // Action buttons |
|
|
// for (JButton b : actionButtons.values()) |
|
|
// add(b); |
|
|
// } |
|
|
|
|
387 |
/** |
/** |
388 |
* Performs the activation of a tool. |
* Performs the activation of a tool. |
389 |
* |
* |
400 |
|
|
401 |
switch (tool) { |
switch (tool) { |
402 |
case TOOL_PAN: |
case TOOL_PAN: |
|
// Set the mouse tool to "Panning" |
|
|
// mapPane.setState(SelectableXMapPane.PAN); |
|
403 |
mapPane.setTool(XMapPaneTool.PAN); |
mapPane.setTool(XMapPaneTool.PAN); |
|
// mapPane.setNormalCursor(SwingUtil.PAN_CURSOR); |
|
404 |
break; |
break; |
405 |
case TOOL_INFO: |
case TOOL_INFO: |
|
// Set the mouse tool to "Info" |
|
406 |
mapPane.setTool(XMapPaneTool.INFO); |
mapPane.setTool(XMapPaneTool.INFO); |
|
// mapPane.setState(SelectableXMapPane.SELECT_ONE_FROM_TOP); |
|
|
// mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR); |
|
407 |
break; |
break; |
408 |
case TOOL_ZOOMIN: |
case TOOL_ZOOMIN: |
|
// Set the mouse tool to "Zoom in" |
|
409 |
mapPane.setTool(XMapPaneTool.ZOOM_IN); |
mapPane.setTool(XMapPaneTool.ZOOM_IN); |
|
// mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR); |
|
410 |
break; |
break; |
411 |
case TOOL_ZOOMOUT: |
case TOOL_ZOOMOUT: |
|
// Set the mouse tool to "Zoom out" |
|
412 |
mapPane.setTool(XMapPaneTool.ZOOM_OUT); |
mapPane.setTool(XMapPaneTool.ZOOM_OUT); |
|
// mapPane.setState(SelectableXMapPane.ZOOM_OUT); |
|
|
// mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR); |
|
413 |
break; |
break; |
|
// default: |
|
|
// Set map actions to default |
|
|
// mapPane.setState(SelectableXMapPane.NONE); |
|
|
// mapPane.setNormalCursor(null); |
|
|
// break; |
|
414 |
} |
} |
|
// mapPane.updateCursorAndRepaintTimer(); |
|
415 |
} |
} |
416 |
|
|
417 |
/** |
/** |
485 |
} |
} |
486 |
JToggleButton button = new SmallToggleButton(buttonAction); |
JToggleButton button = new SmallToggleButton(buttonAction); |
487 |
|
|
|
// button.setBorder(BorderFactory.createRaisedBevelBorder()); |
|
488 |
toolButtonGroup.add(button); |
toolButtonGroup.add(button); |
489 |
toolAndActionButtons.put(buttonAction.getID(), button); |
toolAndActionButtons.put(buttonAction.getID(), button); |
490 |
if (resetToolBar) |
if (resetToolBar) |
521 |
return; |
return; |
522 |
} |
} |
523 |
JButton button = new SmallButton(buttonAction); |
JButton button = new SmallButton(buttonAction); |
|
// button.setBorder(BorderFactory.createRaisedBevelBorder()); |
|
524 |
toolAndActionButtons.put(buttonAction.getID(), button); |
toolAndActionButtons.put(buttonAction.getID(), button); |
525 |
if (resetToolBar) |
if (resetToolBar) |
526 |
initToolBar(); |
initToolBar(); |
888 |
* wird) wird. Dann werden wird der Hintergrund auf WEISS gesetzt. |
* wird) wird. Dann werden wird der Hintergrund auf WEISS gesetzt. |
889 |
* |
* |
890 |
* @author <a href="mailto:[email protected]">Stefan Alfons |
* @author <a href="mailto:[email protected]">Stefan Alfons |
891 |
* Krüger</a> |
* Tzeggai</a> |
892 |
*/ |
*/ |
893 |
@Override |
@Override |
894 |
public void print(Graphics g) { |
public void print(Graphics g) { |