|
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.thematicmap.app.viewer;
|
|
23 |
|
|
24 |
import org.gvsig.andami.PluginServices;
|
|
25 |
import org.gvsig.andami.plugins.Extension;
|
|
26 |
import org.gvsig.andami.ui.mdiManager.IWindow;
|
|
27 |
import org.gvsig.app.project.documents.view.toolListeners.InfoListener;
|
|
28 |
import org.gvsig.educa.thematicmap.app.viewer.ui.ThematicMapDocumentViewer;
|
|
29 |
import org.gvsig.educa.thematicmap.swing.ThematicMapSwingLocator;
|
|
30 |
import org.gvsig.educa.thematicmap.swing.viewer.MapControlToolRegistrant;
|
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLayers;
|
|
32 |
import org.gvsig.fmap.mapcontrol.MapControl;
|
|
33 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior;
|
|
34 |
|
|
35 |
/**
|
|
36 |
* ThematicMap Info-by-point tool
|
|
37 |
*
|
|
38 |
* @author gvSIG Team
|
|
39 |
* @version $Id$
|
|
40 |
*
|
|
41 |
*/
|
|
42 |
public class ThematicMapInfoByPointToolsExtension extends Extension implements
|
|
43 |
MapControlToolRegistrant {
|
|
44 |
|
|
45 |
public void initialize() {
|
|
46 |
// Nothing to do
|
|
47 |
|
|
48 |
}
|
|
49 |
|
|
50 |
@Override
|
|
51 |
public void postInitialize() {
|
|
52 |
|
|
53 |
// Register tools
|
|
54 |
ThematicMapSwingLocator.getSwingManager().addMapControlRegistrant(this);
|
|
55 |
}
|
|
56 |
|
|
57 |
public boolean isEnabled() {
|
|
58 |
IWindow window = PluginServices.getMDIManager().getActiveWindow();
|
|
59 |
|
|
60 |
if (window instanceof ThematicMapDocumentViewer) {
|
|
61 |
ThematicMapDocumentViewer viewer =
|
|
62 |
(ThematicMapDocumentViewer) window;
|
|
63 |
|
|
64 |
FLayers layers =
|
|
65 |
viewer.getThematicMap().getMapContext().getLayers();
|
|
66 |
|
|
67 |
for (int i = 0; i < layers.getLayersCount(); i++) {
|
|
68 |
if (layers.getLayer(i).isAvailable()) {
|
|
69 |
return true;
|
|
70 |
}
|
|
71 |
}
|
|
72 |
}
|
|
73 |
return false;
|
|
74 |
}
|
|
75 |
|
|
76 |
public boolean isVisible() {
|
|
77 |
IWindow window = PluginServices.getMDIManager().getActiveWindow();
|
|
78 |
return window instanceof ThematicMapDocumentViewer;
|
|
79 |
}
|
|
80 |
|
|
81 |
public void registerTools(MapControl mapControl) {
|
|
82 |
|
|
83 |
// Info por punto
|
|
84 |
InfoListener il = new InfoListener(mapControl);
|
|
85 |
mapControl.addBehavior("info", new PointBehavior(il));
|
|
86 |
|
|
87 |
}
|
|
88 |
|
|
89 |
public void execute(String actionCommand) {
|
|
90 |
IWindow window = PluginServices.getMDIManager().getActiveWindow();
|
|
91 |
if (!(window instanceof ThematicMapDocumentViewer)) {
|
|
92 |
return;
|
|
93 |
}
|
|
94 |
ThematicMapDocumentViewer tmDocViewer =
|
|
95 |
(ThematicMapDocumentViewer) window;
|
|
96 |
MapControl mapCtrl = tmDocViewer.getViewer().getMapControl();
|
|
97 |
if (actionCommand.equals("INFO")) {
|
|
98 |
mapCtrl.setTool("info");
|
|
99 |
}
|
|
100 |
}
|
|
101 |
}
|