gvsig-raster / org.gvsig.raster.wcs / trunk / org.gvsig.raster.wcs / org.gvsig.raster.wcs.app / org.gvsig.raster.wcs.app.wcsclient / src / main / java / org / gvsig / raster / wcs / app / wcsclient / gui / toc / WCSZoomPixelCursorTocMenuEntry.java @ 418
History | View | Annotate | Download (2.77 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.raster.wcs.app.wcsclient.gui.toc; |
23 |
|
24 |
import org.gvsig.andami.PluginServices; |
25 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
26 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
27 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
28 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
29 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
30 |
import org.gvsig.fmap.mapcontrol.MapControl; |
31 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
32 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
33 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
34 |
import org.gvsig.raster.app.extension.wcsclient.layer.FLyrWCS; |
35 |
|
36 |
|
37 |
/**
|
38 |
* @author Nacho Brodin <nachobrodin@gmail.com>
|
39 |
*
|
40 |
* Entrada de men? para la activaci?n de la funcionalidad de zoom a un
|
41 |
* pixel centrado en el cursor.
|
42 |
*/
|
43 |
public class WCSZoomPixelCursorTocMenuEntry extends |
44 |
AbstractTocContextMenuAction { |
45 |
|
46 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
47 |
|
48 |
DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
49 |
MapControl mapCtrl = vista.getMapControl(); |
50 |
|
51 |
if (!mapCtrl.hasTool("zoom_pixel_cursor")) { |
52 |
StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
53 |
|
54 |
WCSZoomPixelCursorListener zp = new WCSZoomPixelCursorListener(
|
55 |
mapCtrl); |
56 |
mapCtrl.addBehavior("zoom_pixel_cursor", new Behavior[] { |
57 |
new PointBehavior(zp), new MouseMovementBehavior(sbl) }); |
58 |
|
59 |
} |
60 |
|
61 |
mapCtrl.setTool("zoom_pixel_cursor");
|
62 |
} |
63 |
|
64 |
public String getText() { |
65 |
return PluginServices.getText(this, "Zoom_pixel"); |
66 |
} |
67 |
|
68 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
69 |
return selectedItems.length == 1 && selectedItems[0].isAvailable(); |
70 |
} |
71 |
|
72 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
73 |
if (selectedItems.length != 1) { |
74 |
return false; |
75 |
} |
76 |
return selectedItems[0] instanceof FLyrWCS; |
77 |
|
78 |
} |
79 |
|
80 |
} |