Revision 38564 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/extension/ViewControls.java
ViewControls.java | ||
---|---|---|
46 | 46 |
*/ |
47 | 47 |
package org.gvsig.app.extension; |
48 | 48 |
|
49 |
import javax.swing.JOptionPane; |
|
50 |
|
|
51 |
import org.gvsig.andami.IconThemeHelper; |
|
49 | 52 |
import org.gvsig.andami.PluginServices; |
50 | 53 |
import org.gvsig.andami.plugins.Extension; |
51 | 54 |
import org.gvsig.andami.preferences.IPreference; |
... | ... | |
53 | 56 |
import org.gvsig.app.gui.preferencespage.GridPage; |
54 | 57 |
import org.gvsig.app.gui.preferencespage.ViewPage; |
55 | 58 |
import org.gvsig.app.project.Project; |
56 |
import org.gvsig.app.project.documents.AbstractDocument; |
|
57 | 59 |
import org.gvsig.app.project.documents.view.Encuadrator; |
58 | 60 |
import org.gvsig.app.project.documents.view.ViewDocument; |
61 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
59 | 62 |
import org.gvsig.app.project.documents.view.gui.ExtentListSelectorModel; |
60 | 63 |
import org.gvsig.app.project.documents.view.gui.FPanelExtentSelector; |
61 | 64 |
import org.gvsig.app.project.documents.view.gui.FPanelLocConfig; |
62 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
63 | 65 |
import org.gvsig.app.project.documents.view.toc.gui.FPopupMenu; |
64 | 66 |
import org.gvsig.app.project.documents.view.toolListeners.snapping.Snapping; |
65 | 67 |
import org.gvsig.fmap.mapcontext.MapContext; |
... | ... | |
67 | 69 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
68 | 70 |
import org.gvsig.fmap.mapcontrol.MapControl; |
69 | 71 |
import org.gvsig.tools.ToolsLocator; |
72 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
70 | 73 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
71 | 74 |
import org.slf4j.Logger; |
72 | 75 |
import org.slf4j.LoggerFactory; |
... | ... | |
90 | 93 |
* @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String) |
91 | 94 |
*/ |
92 | 95 |
public void execute(String s) { |
93 |
ViewDocument model = vista.getModel(); |
|
94 |
MapContext mapa = model.getMapContext(); |
|
96 |
execute(s,null); |
|
97 |
} |
|
98 |
|
|
99 |
public void execute(String command, Object[] args) { |
|
100 |
ViewDocument document = vista.getViewDocument(); |
|
101 |
MapContext mapa = document.getMapContext(); |
|
95 | 102 |
MapControl mapCtrl = vista.getMapControl(); |
96 |
logger.debug("Comand : " + s); |
|
97 | 103 |
|
98 |
if (s.equals("FULL") ) {
|
|
104 |
if (command.equalsIgnoreCase("view-navigation-zoom-all") ) {
|
|
99 | 105 |
// mapa.beginAtomicEvent(); |
100 | 106 |
mapa.getViewPort().setEnvelope(mapa.getLayers().getFullEnvelope()); |
101 |
((AbstractDocument)vista.getModel()).setModified(true);
|
|
107 |
document.setModified(true);
|
|
102 | 108 |
// mapa.endAtomicEvent(); |
103 |
} else if (s.equals("ENCUADRE") ) { |
|
109 |
|
|
110 |
} else if (command.equalsIgnoreCase("view-navigation-frame-manager") ) { |
|
104 | 111 |
FPanelExtentSelector l = new FPanelExtentSelector(); |
105 | 112 |
|
106 | 113 |
ProjectExtension p = (ProjectExtension) PluginServices.getExtension(org.gvsig.app.extension.ProjectExtension.class); |
... | ... | |
110 | 117 |
project.addPropertyChangeListener(modelo); |
111 | 118 |
l.setModel(modelo); |
112 | 119 |
l.addSelectionListener(new Encuadrator(project, mapa, vista)); |
113 |
((AbstractDocument)vista.getModel()).setModified(true);
|
|
120 |
document.setModified(true);
|
|
114 | 121 |
PluginServices.getMDIManager().addWindow(l); |
115 |
} else if (s.equals("CONFIG_LOCATOR") ) { |
|
122 |
|
|
123 |
} else if (command.equalsIgnoreCase("view-locator-setup") ) { |
|
116 | 124 |
//Set up the map overview |
117 | 125 |
FPanelLocConfig m_panelLoc = new FPanelLocConfig(vista.getMapOverview()); |
118 | 126 |
PluginServices.getMDIManager().addWindow(m_panelLoc); |
119 | 127 |
m_panelLoc.setPreferredSize(m_panelLoc.getSize()); |
120 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
121 |
} else if (s.equals("PAN") ) { |
|
128 |
document.setModified(true); |
|
129 |
|
|
130 |
} else if (command.equalsIgnoreCase("view-navigation-pan") ) { |
|
122 | 131 |
mapCtrl.setTool("pan"); |
123 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
124 |
} else if (s.equals("ZOOM_IN") ) { |
|
132 |
document.setModified(true); |
|
133 |
|
|
134 |
} else if (command.equalsIgnoreCase("view-navigation-zoom-in-topoint") ) { |
|
125 | 135 |
mapCtrl.setTool("zoomIn"); |
126 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
127 |
} else if (s.equals("ZOOM_OUT") ) { |
|
136 |
document.setModified(true); |
|
137 |
|
|
138 |
} else if (command.equalsIgnoreCase("view-navigation-zoom-out-topoint") ) { |
|
128 | 139 |
mapCtrl.setTool("zoomOut"); |
129 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
130 |
} else if (s.equals("CAPAS_VISIBLES") ) { |
|
140 |
document.setModified(true); |
|
141 |
|
|
142 |
} else if (command.equalsIgnoreCase("layer-set-visible") ) { |
|
131 | 143 |
setVisibles(true, mapa.getLayers()); |
132 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
133 |
} else if (s.equals("CAPAS_NOVISIBLES") ) { |
|
144 |
document.setModified(true); |
|
145 |
|
|
146 |
} else if (command.equalsIgnoreCase("layer-set-hide") ) { |
|
134 | 147 |
setVisibles(false, mapa.getLayers()); |
135 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
136 |
} else if (s.equals("CAPAS_ACTIVAS") ) { |
|
148 |
document.setModified(true); |
|
149 |
|
|
150 |
} else if (command.equalsIgnoreCase("layer-set-active") ) { |
|
137 | 151 |
setActives(true, mapa.getLayers()); |
138 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
139 |
} else if (s.equals("CAPAS_NOACTIVAS") ) { |
|
152 |
document.setModified(true); |
|
153 |
|
|
154 |
} else if (command.equalsIgnoreCase("layer-set-inactive") ) { |
|
140 | 155 |
setActives(false, mapa.getLayers()); |
141 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
142 |
} else if (s.equals("SAVERASTER") ) { |
|
143 |
mapCtrl.setTool("saveRaster"); |
|
144 |
} else if (s.equals("SELECTIMAGE") ) { |
|
145 |
mapCtrl.setTool("selectImage"); |
|
146 |
} else if (s.equals("ACTION_ZOOM_IN") ) { |
|
156 |
document.setModified(true); |
|
157 |
|
|
158 |
} else if (command.equalsIgnoreCase("view-navigation-zoom-in-center") ) { |
|
147 | 159 |
mapCtrl.zoomIn(); |
148 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
149 |
} else if (s.equals("ACTION_ZOOM_OUT") ) { |
|
160 |
document.setModified(true); |
|
161 |
|
|
162 |
} else if (command.equalsIgnoreCase("view-navigation-zoom-out-center") ) { |
|
150 | 163 |
mapCtrl.zoomOut(); |
151 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
152 |
} else if (s.startsWith("CHANGE_SCALE_")){ |
|
153 |
String scl=s.replaceAll("CHANGE_SCALE_",""); |
|
154 |
long scale=Long.parseLong(scl); |
|
155 |
mapa.setScaleView(scale); |
|
156 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
164 |
document.setModified(true); |
|
165 |
|
|
166 |
} else if (command.equalsIgnoreCase("view-change-scale")) { |
|
167 |
try { |
|
168 |
Long scale = (Long) ToolsLocator.getDataTypesManager().coerce(DataTypes.LONG, args[0]); |
|
169 |
mapa.setScaleView(scale.longValue()); |
|
170 |
document.setModified(true); |
|
171 |
} catch(Throwable ex) { |
|
172 |
logger.info("Can't change scale of view.", ex); |
|
173 |
PluginServices.getMainFrame().getStatusBar().message("Can't change scale of view.", JOptionPane.ERROR_MESSAGE); |
|
174 |
} |
|
157 | 175 |
} |
158 | 176 |
} |
159 | 177 |
|
... | ... | |
205 | 223 |
|
206 | 224 |
if (f!=null && f instanceof DefaultViewPanel) { |
207 | 225 |
vista = (DefaultViewPanel) f; |
208 |
ViewDocument model = vista.getModel();
|
|
226 |
ViewDocument model = vista.getViewDocument();
|
|
209 | 227 |
MapContext mapa = model.getMapContext(); |
210 | 228 |
|
211 | 229 |
return mapa.getLayers().getLayersCount() > 0; |
... | ... | |
237 | 255 |
} |
238 | 256 |
|
239 | 257 |
private void registerIcons(){ |
240 |
|
|
241 |
PluginServices.getIconTheme().registerDefault( |
|
242 |
"view-zoom-in", |
|
243 |
this.getClass().getClassLoader().getResource("images/ZoomIn.png") |
|
244 |
); |
|
245 |
PluginServices.getIconTheme().registerDefault( |
|
246 |
"view-zoom-out", |
|
247 |
this.getClass().getClassLoader().getResource("images/ZoomOut.png") |
|
248 |
); |
|
249 |
PluginServices.getIconTheme().registerDefault( |
|
250 |
"view-zoom-map-contents", |
|
251 |
this.getClass().getClassLoader().getResource("images/MapContents.png") |
|
252 |
); |
|
253 |
PluginServices.getIconTheme().registerDefault( |
|
254 |
"view-zoom-center-in", |
|
255 |
this.getClass().getClassLoader().getResource("images/zoommas.png") |
|
256 |
); |
|
257 |
PluginServices.getIconTheme().registerDefault( |
|
258 |
"view-zoom-center-out", |
|
259 |
this.getClass().getClassLoader().getResource("images/zoommenos.png") |
|
260 |
); |
|
261 |
|
|
262 |
PluginServices.getIconTheme().registerDefault( |
|
263 |
"view-pan", |
|
264 |
this.getClass().getClassLoader().getResource("images/Pan.png") |
|
265 |
); |
|
266 |
|
|
267 |
PluginServices.getIconTheme().registerDefault( |
|
268 |
"view-zoom-manager", |
|
269 |
this.getClass().getClassLoader().getResource("images/encuadre.png") |
|
270 |
); |
|
271 |
|
|
272 |
PluginServices.getIconTheme().registerDefault( |
|
273 |
"toc-layer-group", |
|
274 |
this.getClass().getClassLoader().getResource("images/layerGroup.png") |
|
275 |
); |
|
258 |
IconThemeHelper.registerIcon("action", "view-navigation-zoom-in-topoint", this); |
|
259 |
IconThemeHelper.registerIcon("action", "view-navigation-zoom-out-topoint", this); |
|
260 |
IconThemeHelper.registerIcon("action", "view-navigation-zoom-all", this); |
|
261 |
IconThemeHelper.registerIcon("action", "view-navigation-zoom-in-center", this); |
|
262 |
IconThemeHelper.registerIcon("action", "view-navigation-zoom-out-center", this); |
|
263 |
IconThemeHelper.registerIcon("action", "view-navigation-pan", this); |
|
264 |
IconThemeHelper.registerIcon("action", "view-navigation-frame-manager", this); |
|
276 | 265 |
} |
277 | 266 |
|
278 | 267 |
/** |
279 | 268 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
280 | 269 |
*/ |
281 | 270 |
public boolean isEnabled() { |
282 |
ViewDocument model = vista.getModel();
|
|
271 |
ViewDocument model = vista.getViewDocument();
|
|
283 | 272 |
MapContext mapa = model.getMapContext(); |
284 | 273 |
|
285 | 274 |
FLayers layers = mapa.getLayers(); |
Also available in: Unified diff