gvsig-educa / org.gvsig.educa.batovi / trunk / org.gvsig.educa.batovi.mapviewer / org.gvsig.educa.batovi.mapviewer / src / main / java / org / gvsig / educa / batovi / mapviewer / MapToolsRegistrant.java @ 126
History | View | Annotate | Download (3.54 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.educa.batovi.mapviewer; |
23 |
|
24 |
import org.gvsig.educa.batovi.mapviewer.tools.AreaListener; |
25 |
import org.gvsig.educa.batovi.mapviewer.tools.MeasureListener; |
26 |
import org.gvsig.educa.batovi.mapviewer.tools.StatusBarBehavior; |
27 |
import org.gvsig.educa.thematicmap.swing.viewer.MapControlToolRegistrant; |
28 |
import org.gvsig.fmap.mapcontrol.MapControl; |
29 |
import org.gvsig.fmap.mapcontrol.tools.CompoundBehavior; |
30 |
import org.gvsig.fmap.mapcontrol.tools.PanListenerImpl; |
31 |
import org.gvsig.fmap.mapcontrol.tools.ZoomInListenerImpl; |
32 |
import org.gvsig.fmap.mapcontrol.tools.ZoomOutRightButtonListener; |
33 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
34 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseWheelBehavior; |
35 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MoveBehavior; |
36 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
37 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PolylineBehavior; |
38 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.RectangleBehavior; |
39 |
|
40 |
/**
|
41 |
* @author gvSIG Team
|
42 |
* @version $Id$
|
43 |
*
|
44 |
*/
|
45 |
public class MapToolsRegistrant implements MapControlToolRegistrant { |
46 |
|
47 |
public static final String TOOL_ZOOM_ID = "zoom"; |
48 |
|
49 |
public static final String TOOL_PAN_ID = "pan"; |
50 |
|
51 |
public static final String TOOL_MEASURE_ID = "mesaure"; |
52 |
|
53 |
public static final String TOOL_AREA_ID = "area"; |
54 |
|
55 |
private final StatusBarBehavior statusBarBehavior = new StatusBarBehavior(); |
56 |
private final MouseWheelBehavior mouseWheelBehavior = |
57 |
new MouseWheelBehavior();
|
58 |
private final CompoundBehavior compoundBehavior = new CompoundBehavior( |
59 |
new Behavior[] { mouseWheelBehavior, statusBarBehavior }); |
60 |
|
61 |
private StatusBar statusBar = null; |
62 |
|
63 |
public void registerTools(MapControl mapControl) { |
64 |
// Adds tools to mapControl
|
65 |
// mouseWhell
|
66 |
mapControl.addCombinedBehavior(compoundBehavior); |
67 |
// zoom
|
68 |
mapControl.addBehavior(TOOL_ZOOM_ID, new Behavior[] { |
69 |
new RectangleBehavior(new ZoomInListenerImpl(mapControl)), |
70 |
new PointBehavior(new ZoomOutRightButtonListener(mapControl)) }); |
71 |
// pan
|
72 |
mapControl.addBehavior(TOOL_PAN_ID, new MoveBehavior(
|
73 |
new PanListenerImpl(mapControl)));
|
74 |
|
75 |
// measure
|
76 |
mapControl.addBehavior(TOOL_MEASURE_ID, new PolylineBehavior(
|
77 |
new MeasureListener(mapControl, statusBar)));
|
78 |
|
79 |
// area
|
80 |
mapControl.addBehavior(TOOL_AREA_ID, new PolylineBehavior(
|
81 |
new AreaListener(mapControl, statusBar)));
|
82 |
|
83 |
mapControl.setTool(TOOL_PAN_ID); |
84 |
} |
85 |
|
86 |
/**
|
87 |
*
|
88 |
*/
|
89 |
public void setStatusBar(StatusBar statusBar) { |
90 |
this.statusBar = statusBar;
|
91 |
this.statusBarBehavior.setStatusBar(statusBar);
|
92 |
} |
93 |
|
94 |
} |