52 |
|
|
53 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
54 |
|
|
55 |
import schmitzm.geotools.gui.JMapPane; |
import schmitzm.geotools.gui.SelectableXMapPane; |
|
import schmitzm.geotools.map.event.JMapPaneEvent; |
|
56 |
import schmitzm.geotools.map.event.JMapPaneListener; |
import schmitzm.geotools.map.event.JMapPaneListener; |
57 |
import schmitzm.geotools.map.event.MapAreaChangedEvent; |
import schmitzm.geotools.map.event.MapAreaChangedEvent; |
58 |
|
import schmitzm.geotools.map.event.MapPaneEvent; |
59 |
import schmitzm.lang.LangUtil; |
import schmitzm.lang.LangUtil; |
60 |
import schmitzm.lang.ResourceProvider; |
import schmitzm.lang.ResourceProvider; |
61 |
import schmitzm.swing.ButtonGroup; |
import schmitzm.swing.ButtonGroup; |
|
import schmitzm.swing.SwingUtil; |
|
62 |
import skrueger.swing.SmallButton; |
import skrueger.swing.SmallButton; |
63 |
import skrueger.swing.SmallToggleButton; |
import skrueger.swing.SmallToggleButton; |
64 |
|
|
65 |
import com.vividsolutions.jts.geom.Envelope; |
import com.vividsolutions.jts.geom.Envelope; |
66 |
|
|
67 |
/** |
/** |
68 |
* A toolbar to control an {@link JMapPane} (Atlas visualization). This contains |
* A toolbar to control an {@link SelectableXMapPane} (Atlas visualization). This contains |
69 |
* two types of buttons. A group of <i>tools</i> for the mouse actions on the |
* two types of buttons. A group of <i>tools</i> for the mouse actions on the |
70 |
* map represented by {@link JToggleButton JToggleButtons}, where only one tool |
* map represented by {@link JToggleButton JToggleButtons}, where only one tool |
71 |
* can be activated every time. And some (general) <i>actions</i>, represented |
* can be activated every time. And some (general) <i>actions</i>, represented |
139 |
// /** Holds the action buttons of the bar. */ |
// /** Holds the action buttons of the bar. */ |
140 |
// protected SortedMap<Integer, JButton> actionButtons = null; |
// protected SortedMap<Integer, JButton> actionButtons = null; |
141 |
|
|
142 |
/** Holds the {@link JMapPane} this tool bar controls. */ |
/** Holds the {@link SelectableXMapPane} this tool bar controls. */ |
143 |
protected JMapPane mapPane = null; |
protected SelectableXMapPane mapPane = null; |
144 |
|
|
145 |
/** |
/** |
146 |
* A List to remember the last Envelopes that have been watched. Used for |
* A List to remember the last Envelopes that have been watched. Used for |
175 |
|
|
176 |
/** |
/** |
177 |
* Creates a new toolbar. Notice: This toolbar does nothing until |
* Creates a new toolbar. Notice: This toolbar does nothing until |
178 |
* {@link #setMapPane(JMapPane)} is called! |
* {@link #setMapPane(SelectableXMapPane)} is called! |
179 |
*/ |
*/ |
180 |
public MapPaneToolBar() { |
public MapPaneToolBar() { |
181 |
this(null); |
this(null); |
194 |
* Creates a new tool bar. |
* Creates a new tool bar. |
195 |
* |
* |
196 |
* @param mapPane |
* @param mapPane |
197 |
* {@link JMapPane} the tool bar controls |
* {@link SelectableXMapPane} the tool bar controls |
198 |
*/ |
*/ |
199 |
public MapPaneToolBar(JMapPane mapPane) { |
public MapPaneToolBar(SelectableXMapPane mapPane) { |
200 |
super("Control the map", JToolBar.HORIZONTAL); |
super("Control the map", JToolBar.HORIZONTAL); |
201 |
|
|
202 |
// I want to see nothing on the background |
// I want to see nothing on the background |
207 |
|
|
208 |
// Create a Listener to listen to the zooms on the JMapPane |
// Create a Listener to listen to the zooms on the JMapPane |
209 |
this.mapPaneListener = new JMapPaneListener() { |
this.mapPaneListener = new JMapPaneListener() { |
210 |
public void performMapPaneEvent(JMapPaneEvent e) { |
public void performMapPaneEvent(MapPaneEvent e) { |
211 |
if (!(e instanceof MapAreaChangedEvent)) |
if (!(e instanceof MapAreaChangedEvent)) |
212 |
return; |
return; |
213 |
|
|
268 |
} |
} |
269 |
|
|
270 |
/** |
/** |
271 |
* Sets the {@link JMapPane} controlled by this tool bar. |
* Sets the {@link SelectableXMapPane} controlled by this tool bar. |
272 |
* |
* |
273 |
* @param mapPane |
* @param mapPane |
274 |
* {@link JMapPane} to control (if {@code null} this tool bar |
* {@link SelectableXMapPane} to control (if {@code null} this tool bar |
275 |
* controls NOTHING!) |
* controls NOTHING!) |
276 |
*/ |
*/ |
277 |
public void setMapPane(JMapPane mapPane) { |
public void setMapPane(SelectableXMapPane mapPane) { |
278 |
// Remove listener from old MapPane |
// Remove listener from old MapPane |
279 |
if (this.mapPane != null) |
if (this.mapPane != null) |
280 |
this.mapPane.removeMapPaneListener(mapPaneListener); |
this.mapPane.removeMapPaneListener(mapPaneListener); |
425 |
switch (tool) { |
switch (tool) { |
426 |
case TOOL_PAN: |
case TOOL_PAN: |
427 |
// Set the mouse tool to "Panning" |
// Set the mouse tool to "Panning" |
428 |
mapPane.setWindowSelectionState(JMapPane.NONE); |
mapPane.setState(SelectableXMapPane.PAN); |
429 |
mapPane.setState(JMapPane.PAN); |
// mapPane.setNormalCursor(SwingUtil.PAN_CURSOR); |
|
mapPane.setNormalCursor(SwingUtil.PAN_CURSOR); |
|
430 |
break; |
break; |
431 |
case TOOL_INFO: |
case TOOL_INFO: |
432 |
// Set the mouse tool to "Info" |
// Set the mouse tool to "Info" |
433 |
mapPane.setWindowSelectionState(JMapPane.NONE); |
mapPane.setState(SelectableXMapPane.SELECT_ONE_FROM_TOP); |
434 |
mapPane.setState(JMapPane.SELECT_TOP); // Why not: |
// mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR); |
|
// JMapPane.SELECT_TOP_ONEONLY |
|
|
// properly removed it to save |
|
|
// performance |
|
|
mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR); |
|
435 |
break; |
break; |
436 |
case TOOL_ZOOMIN: |
case TOOL_ZOOMIN: |
437 |
// Set the mouse tool to "Zoom in" |
// Set the mouse tool to "Zoom in" |
438 |
mapPane.setWindowSelectionState(JMapPane.ZOOM_IN); |
mapPane.setState(SelectableXMapPane.ZOOM_IN); |
439 |
mapPane.setState(JMapPane.ZOOM_IN); |
// mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR); |
|
mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR); |
|
440 |
break; |
break; |
441 |
case TOOL_ZOOMOUT: |
case TOOL_ZOOMOUT: |
442 |
// Set the mouse tool to "Zoom out" |
// Set the mouse tool to "Zoom out" |
443 |
mapPane.setWindowSelectionState(JMapPane.NONE); |
mapPane.setState(SelectableXMapPane.ZOOM_OUT); |
444 |
mapPane.setState(JMapPane.ZOOM_OUT); |
// mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR); |
|
mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR); |
|
445 |
break; |
break; |
446 |
default: |
default: |
447 |
// Set map actions to default |
// Set map actions to default |
448 |
mapPane.setWindowSelectionState(JMapPane.NONE); |
mapPane.setState(SelectableXMapPane.NONE); |
449 |
mapPane.setState(JMapPane.NONE); |
// mapPane.setNormalCursor(null); |
|
mapPane.setNormalCursor(null); |
|
450 |
break; |
break; |
451 |
} |
} |
452 |
mapPane.updateCursor(); |
// mapPane.updateCursorAndRepaintTimer(); |
453 |
} |
} |
454 |
|
|
455 |
/** |
/** |