root / trunk / extensions / extWCS / src / com / iver / cit / gvsig / gui / toc / WCSZoomPixelCursorTocMenuEntry.java @ 7771
History | View | Annotate | Download (2.26 KB)
1 | 2426 | nacho | package com.iver.cit.gvsig.gui.toc; |
---|---|---|---|
2 | |||
3 | import java.awt.event.ActionEvent; |
||
4 | |||
5 | import javax.swing.JMenuItem; |
||
6 | |||
7 | import com.iver.andami.PluginServices; |
||
8 | import com.iver.cit.gvsig.fmap.MapControl; |
||
9 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
10 | 2449 | nacho | import com.iver.cit.gvsig.fmap.layers.FLyrWCS; |
11 | 2426 | nacho | import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
12 | import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
||
13 | import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
||
14 | import com.iver.cit.gvsig.gui.toolListeners.WCSZoomPixelCursorListener; |
||
15 | 7304 | caballero | import com.iver.cit.gvsig.project.documents.view.gui.View; |
16 | import com.iver.cit.gvsig.project.documents.view.toc.TocMenuEntry; |
||
17 | import com.iver.cit.gvsig.project.documents.view.toc.gui.FPopupMenu; |
||
18 | 7771 | caballero | import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
19 | 2426 | nacho | |
20 | /**
|
||
21 | * @author Nacho Brodin <brodin_ign@gva.es>
|
||
22 | *
|
||
23 | * Entrada de men? para la activaci?n de la funcionalidad de zoom a un
|
||
24 | * pixel centrado en el cursor.
|
||
25 | */
|
||
26 | public class WCSZoomPixelCursorTocMenuEntry extends TocMenuEntry { |
||
27 | private JMenuItem properties; |
||
28 | FLayer lyr = null;
|
||
29 | |||
30 | public void initialize(FPopupMenu m) { |
||
31 | super.initialize(m);
|
||
32 | |||
33 | if (isTocItemBranch()) {
|
||
34 | 2449 | nacho | lyr = getNodeLayer(); |
35 | // Opcciones para capas WCS
|
||
36 | if ((lyr instanceof FLyrWCS)) { |
||
37 | properties = new JMenuItem(PluginServices.getText(this, "Zoom_pixel")); |
||
38 | getMenu().add( properties ); |
||
39 | properties.setFont(FPopupMenu.theFont); |
||
40 | getMenu().setEnabled(true);
|
||
41 | properties.addActionListener(this);
|
||
42 | |||
43 | 6880 | cesar | View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
44 | 2449 | nacho | MapControl mapCtrl = vista.getMapControl(); |
45 | |||
46 | StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
||
47 | |||
48 | WCSZoomPixelCursorListener zp = new WCSZoomPixelCursorListener(mapCtrl);
|
||
49 | mapCtrl.addMapTool("zoom_pixel_cursor", new Behavior[]{new PointBehavior(zp), new MouseMovementBehavior(sbl)}); |
||
50 | } |
||
51 | 2426 | nacho | } |
52 | } |
||
53 | |||
54 | public void actionPerformed(ActionEvent e) { |
||
55 | |||
56 | FLayer[] actives = getMapContext().getLayers().getActives();
|
||
57 | if (actives.length==1) { |
||
58 | lyr = getNodeLayer(); |
||
59 | 6880 | cesar | View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
60 | 2426 | nacho | MapControl mapCtrl = vista.getMapControl(); |
61 | |||
62 | mapCtrl.setTool("zoom_pixel_cursor");
|
||
63 | } |
||
64 | } |
||
65 | } |