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