gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / multiresolution / ZoomResolutionLevelTocMenuEntry.java @ 1174
History | View | Annotate | Download (5.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.raster.tools.app.basic.tool.multiresolution; |
23 |
|
24 |
import java.awt.Component; |
25 |
import java.beans.PropertyChangeEvent; |
26 |
import java.beans.PropertyChangeListener; |
27 |
|
28 |
import javax.swing.Icon; |
29 |
import javax.swing.JOptionPane; |
30 |
|
31 |
import org.gvsig.andami.PluginServices; |
32 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
33 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
34 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
35 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
36 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
37 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
38 |
import org.gvsig.fmap.mapcontrol.MapControl; |
39 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
40 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
41 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
42 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
43 |
import org.gvsig.raster.fmap.layers.ILayerState; |
44 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
45 |
import org.gvsig.raster.tools.app.basic.raster.gui.IGenericToolBarMenuItem; |
46 |
|
47 |
|
48 |
/**
|
49 |
* Entry point for zoom by resolution level
|
50 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
51 |
*/
|
52 |
public class ZoomResolutionLevelTocMenuEntry extends AbstractTocContextMenuAction implements PropertyChangeListener, IGenericToolBarMenuItem { |
53 |
static private ZoomResolutionLevelTocMenuEntry singleton = null; |
54 |
|
55 |
/**
|
56 |
* Nadie puede crear una instancia a esta clase ?nica, hay que usar el
|
57 |
* getSingleton()
|
58 |
*/
|
59 |
private ZoomResolutionLevelTocMenuEntry() {}
|
60 |
|
61 |
/**
|
62 |
* Devuelve un objeto unico a dicha clase
|
63 |
* @return
|
64 |
*/
|
65 |
static public ZoomResolutionLevelTocMenuEntry getSingleton() { |
66 |
if (singleton == null) |
67 |
singleton = new ZoomResolutionLevelTocMenuEntry();
|
68 |
return singleton;
|
69 |
} |
70 |
|
71 |
/*
|
72 |
* (non-Javadoc)
|
73 |
* @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroup()
|
74 |
*/
|
75 |
public String getGroup() { |
76 |
return "RasterLayer"; |
77 |
} |
78 |
|
79 |
/*
|
80 |
* (non-Javadoc)
|
81 |
* @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroupOrder()
|
82 |
*/
|
83 |
public int getGroupOrder() { |
84 |
return 10; |
85 |
} |
86 |
|
87 |
/*
|
88 |
* (non-Javadoc)
|
89 |
* @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getOrder()
|
90 |
*/
|
91 |
public int getOrder() { |
92 |
return 90; |
93 |
} |
94 |
|
95 |
/*
|
96 |
* (non-Javadoc)
|
97 |
* @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getText()
|
98 |
*/
|
99 |
public String getText() { |
100 |
return RasterToolsUtil.getText(this, "goto_resolution_level"); |
101 |
} |
102 |
|
103 |
/*
|
104 |
* (non-Javadoc)
|
105 |
* @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
106 |
*/
|
107 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
108 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
109 |
return false; |
110 |
if (selectedItems[0] instanceof ILayerState) { |
111 |
if (!((ILayerState) selectedItems[0]).isOpen()) |
112 |
return false; |
113 |
if (selectedItems[0] instanceof FLyrRaster) { |
114 |
FLyrRaster lyr = (FLyrRaster)selectedItems[0];
|
115 |
if(lyr.isTiled())
|
116 |
return true; |
117 |
} |
118 |
} |
119 |
return false; |
120 |
} |
121 |
|
122 |
/*
|
123 |
* (non-Javadoc)
|
124 |
* @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
125 |
*/
|
126 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
127 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
128 |
return false; |
129 |
if (selectedItems[0] instanceof FLyrRaster) |
130 |
return true; |
131 |
return false; |
132 |
} |
133 |
|
134 |
/*
|
135 |
* (non-Javadoc)
|
136 |
* @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
137 |
*/
|
138 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
139 |
IWindow theView = PluginServices.getMDIManager().getActiveWindow(); |
140 |
if(!(theView instanceof AbstractViewPanel)) { |
141 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this.getClass(), "window_not_valid")); |
142 |
return;
|
143 |
} |
144 |
|
145 |
MapControl mapCtrl = ((AbstractViewPanel)theView).getMapControl(); |
146 |
StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
147 |
ResolutionLevelListener rll = new ResolutionLevelListener();
|
148 |
mapCtrl.addBehavior("zoomResolutionLevel", new Behavior[]{new PointBehavior(rll), |
149 |
new MouseMovementBehavior(sbl)});
|
150 |
mapCtrl.setTool("zoomResolutionLevel");
|
151 |
} |
152 |
|
153 |
|
154 |
/*
|
155 |
* (non-Javadoc)
|
156 |
* @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getIcon()
|
157 |
*/
|
158 |
public Icon getIcon() { |
159 |
return RasterToolsUtil.getIcon("layer-zoom-res-level"); |
160 |
} |
161 |
|
162 |
public void propertyChange(PropertyChangeEvent evt) {} |
163 |
} |