root / branches / gvSIG_03_SLD / applications / appgvSIG / src / com / iver / cit / gvsig / gui / toc / FPopupMenu.java @ 2104
History | View | Annotate | Download (18.7 KB)
1 |
/*
|
---|---|
2 |
* Created on 02-mar-2004
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
package com.iver.cit.gvsig.gui.toc; |
45 |
|
46 |
import java.awt.Color; |
47 |
import java.awt.Font; |
48 |
import java.awt.event.ActionEvent; |
49 |
import java.awt.geom.Rectangle2D; |
50 |
import java.util.ArrayList; |
51 |
|
52 |
import javax.swing.JColorChooser; |
53 |
import javax.swing.JDialog; |
54 |
import javax.swing.JMenuItem; |
55 |
import javax.swing.JPopupMenu; |
56 |
import javax.swing.tree.DefaultMutableTreeNode; |
57 |
|
58 |
import com.iver.andami.PluginServices; |
59 |
import com.iver.cit.gvsig.fmap.DriverException; |
60 |
import com.iver.cit.gvsig.fmap.FMap; |
61 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
62 |
import com.iver.cit.gvsig.fmap.layers.CancelationException; |
63 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
64 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
65 |
import com.iver.cit.gvsig.fmap.layers.FLyrDefault; |
66 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
67 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial; |
68 |
import com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend; |
69 |
import com.iver.cit.gvsig.gui.View; |
70 |
import com.iver.cit.gvsig.gui.Panels.AdjustTransparencyPanel; |
71 |
import com.iver.cit.gvsig.gui.thememanager.FThemeManagerWindow; |
72 |
|
73 |
/**
|
74 |
* Realiza el cambio de color si se pulsa OK
|
75 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
76 |
*/
|
77 |
class FSymbolChangeColorTocMenuEntry extends TocMenuEntry { |
78 |
private JMenuItem color; |
79 |
public void initialize(FPopupMenu m) { |
80 |
super.initialize(m);
|
81 |
boolean bShow = false; |
82 |
if (isTocItemBranch())
|
83 |
{ |
84 |
FLayer lyr = getNodeLayer(); |
85 |
if ((lyr instanceof ClassifiableVectorial)) |
86 |
{ |
87 |
ClassifiableVectorial lyrVect = (ClassifiableVectorial) lyr; |
88 |
if (lyrVect.getLegend() instanceof SingleSymbolLegend) |
89 |
bShow = true;
|
90 |
} |
91 |
} |
92 |
else
|
93 |
bShow = true;
|
94 |
if (bShow)
|
95 |
{ |
96 |
color = new JMenuItem(PluginServices.getText(this, "Cambio_Color")); |
97 |
color.setFont(FPopupMenu.theFont); |
98 |
getMenu().add(color); |
99 |
getMenu().setEnabled(true);
|
100 |
//Cambio color
|
101 |
color.addActionListener(this);
|
102 |
} |
103 |
} |
104 |
|
105 |
/* (non-Javadoc)
|
106 |
* @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
|
107 |
*/
|
108 |
public void actionPerformed(ActionEvent e) { |
109 |
ITocItem tocItem = (ITocItem) getNodeUserObject(); |
110 |
|
111 |
Color newColor = JColorChooser.showDialog(null, |
112 |
PluginServices.getText(this, "Elegir_Color"), |
113 |
null);
|
114 |
if (newColor != null) |
115 |
{ |
116 |
if (isTocItemBranch())
|
117 |
{ |
118 |
FLayer lyr = getNodeLayer(); |
119 |
if ((lyr instanceof ClassifiableVectorial)) |
120 |
{ |
121 |
ClassifiableVectorial lyrVect = (ClassifiableVectorial) lyr; |
122 |
if (lyrVect.getLegend() instanceof SingleSymbolLegend) |
123 |
{ |
124 |
SingleSymbolLegend leg = (SingleSymbolLegend) lyrVect.getLegend(); |
125 |
leg.getDefaultSymbol().setColor(newColor); |
126 |
} |
127 |
} |
128 |
} |
129 |
else
|
130 |
{ |
131 |
TocItemLeaf leaf = (TocItemLeaf) tocItem; |
132 |
FSymbol sym = leaf.getSymbol(); |
133 |
sym.setColor(newColor); |
134 |
|
135 |
} |
136 |
// TRUCO PARA REFRESCAR.
|
137 |
getMapContext().invalidate(); |
138 |
|
139 |
} |
140 |
|
141 |
} |
142 |
} |
143 |
|
144 |
/*class FLyrVectChangeStyleTocMenuEntry extends TocMenuEntry {
|
145 |
private JMenuItem estilo;
|
146 |
public void initialize(FPopupMenu m) {
|
147 |
super.initialize(m);
|
148 |
FLayer lyr = null;
|
149 |
|
150 |
if (isTocItemBranch()) {
|
151 |
lyr = getNodeLayer();
|
152 |
if (lyr instanceof ClassifiableVectorial) {
|
153 |
estilo = new JMenuItem(PluginServices.getText(this, "Cambio_Estilo"));
|
154 |
getMenu().add(estilo);
|
155 |
estilo.setFont(FPopupMenu.theFont);
|
156 |
//Cambio estilo
|
157 |
estilo.addActionListener(this);
|
158 |
}
|
159 |
}
|
160 |
}
|
161 |
|
162 |
public void actionPerformed(ActionEvent e) {
|
163 |
FThemeManagerWindow m_LegendEditor = new FThemeManagerWindow();
|
164 |
try {
|
165 |
m_LegendEditor.setMapContext(getMapContext());
|
166 |
} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
|
167 |
e1.printStackTrace();
|
168 |
}
|
169 |
if (PluginServices.getMainFrame() == null) {
|
170 |
JDialog dlg = new JDialog();
|
171 |
|
172 |
m_LegendEditor.setPreferredSize(m_LegendEditor.getSize());
|
173 |
dlg.getContentPane().add(m_LegendEditor);
|
174 |
dlg.setModal(false);
|
175 |
dlg.pack();
|
176 |
dlg.show();
|
177 |
|
178 |
} else
|
179 |
PluginServices.getMDIManager().addView(m_LegendEditor);
|
180 |
}
|
181 |
}
|
182 |
*/
|
183 |
/**
|
184 |
* Muestra el men? de propiedades del tema.
|
185 |
*
|
186 |
* @author jmorell
|
187 |
*
|
188 |
* TODO To change the template for this generated type comment go to
|
189 |
* Window - Preferences - Java - Code Style - Code Templates
|
190 |
*/
|
191 |
class FLyrVectEditPropertiesTocMenuEntry extends TocMenuEntry { |
192 |
private JMenuItem prop; |
193 |
public void initialize(FPopupMenu m) { |
194 |
super.initialize(m);
|
195 |
FLayer lyr = null;
|
196 |
if (isTocItemBranch()) {
|
197 |
getMenu().addSeparator(); |
198 |
lyr = getNodeLayer(); |
199 |
if (lyr instanceof ClassifiableVectorial) { |
200 |
prop = new JMenuItem(PluginServices.getText(this, "Cambio_Estilo")); |
201 |
getMenu().add(prop); |
202 |
prop.setFont(FPopupMenu.theFont); |
203 |
//Cambio estilo
|
204 |
prop.addActionListener(this);
|
205 |
} |
206 |
} |
207 |
} |
208 |
/* (non-Javadoc)
|
209 |
* @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
|
210 |
*/
|
211 |
public void actionPerformed(ActionEvent e) { |
212 |
/*FThemeManagerWindow fThemeManagerWindow = new FThemeManagerWindow();
|
213 |
try {
|
214 |
fThemeManagerWindow.setMapContext(getMapContext());
|
215 |
} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
|
216 |
e1.printStackTrace();
|
217 |
}*/
|
218 |
FLayer[] actives = getMapContext().getLayers().getActives();
|
219 |
FThemeManagerWindow fThemeManagerWindow; |
220 |
if (actives.length==1) { |
221 |
System.out.println("openPliegoThemeProperties(): Una sola capa. Abrimos el panel para la capa " + actives[0]); |
222 |
fThemeManagerWindow = new FThemeManagerWindow();
|
223 |
try {
|
224 |
fThemeManagerWindow.setMapContext(getMapContext()); |
225 |
} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
|
226 |
e1.printStackTrace(); |
227 |
} |
228 |
//PluginServices.getMDIManager().addView(fThemeManagerWindow);
|
229 |
if (PluginServices.getMainFrame() == null) { |
230 |
JDialog dlg = new JDialog(); |
231 |
fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize()); |
232 |
dlg.getContentPane().add(fThemeManagerWindow); |
233 |
dlg.setModal(false);
|
234 |
dlg.pack(); |
235 |
dlg.show(); |
236 |
} else {
|
237 |
PluginServices.getMDIManager().addView(fThemeManagerWindow); |
238 |
} |
239 |
} else {
|
240 |
for (int i = 0; i < actives.length; i++){ |
241 |
System.out.println("openPliegoThemeProperties(): Muchas capas. Abrimos el panel para la capa " + actives[i]); |
242 |
fThemeManagerWindow = new FThemeManagerWindow(actives[i], getMapContext());
|
243 |
//PluginServices.getMDIManager().addView(fThemeManagerWindow);
|
244 |
if (PluginServices.getMainFrame() == null) { |
245 |
JDialog dlg = new JDialog(); |
246 |
fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize()); |
247 |
dlg.getContentPane().add(fThemeManagerWindow); |
248 |
dlg.setModal(false);
|
249 |
dlg.pack(); |
250 |
dlg.show(); |
251 |
} else {
|
252 |
PluginServices.getMDIManager().addView(fThemeManagerWindow); |
253 |
} |
254 |
} |
255 |
} |
256 |
/*if (PluginServices.getMainFrame() == null) {
|
257 |
JDialog dlg = new JDialog();
|
258 |
fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize());
|
259 |
dlg.getContentPane().add(fThemeManagerWindow);
|
260 |
dlg.setModal(false);
|
261 |
dlg.pack();
|
262 |
dlg.show();
|
263 |
} else {
|
264 |
PluginServices.getMDIManager().addView(fThemeManagerWindow);
|
265 |
}*/
|
266 |
} |
267 |
} |
268 |
|
269 |
class FLyrRasterAdjustTransparencyTocMenuEntry extends TocMenuEntry { |
270 |
private JMenuItem transparency; |
271 |
FLayer lyr = null;
|
272 |
public void initialize(FPopupMenu m) { |
273 |
super.initialize(m);
|
274 |
|
275 |
if (isTocItemBranch()) {
|
276 |
lyr = getNodeLayer(); |
277 |
// Opcciones para capas raster
|
278 |
if ((lyr instanceof FLyrRaster)) { |
279 |
transparency = new JMenuItem(PluginServices.getText(this, "adjust_transparency")); |
280 |
getMenu().add( transparency ); |
281 |
transparency.setFont(FPopupMenu.theFont); |
282 |
getMenu().setEnabled(true);
|
283 |
getMenu().addSeparator(); |
284 |
//Cambio color
|
285 |
transparency.addActionListener(this);
|
286 |
} |
287 |
} |
288 |
} |
289 |
/* (non-Javadoc)
|
290 |
* @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
|
291 |
*/
|
292 |
public void actionPerformed(ActionEvent e) { |
293 |
lyr = getNodeLayer(); |
294 |
AdjustTransparencyPanel transPanel = new AdjustTransparencyPanel((FLyrDefault) lyr);
|
295 |
transPanel.openJDialog(); |
296 |
//getMapContext().invalidate();
|
297 |
} |
298 |
} |
299 |
|
300 |
class ZoomAlTemaTocMenuEntry extends TocMenuEntry { |
301 |
private JMenuItem zoom; |
302 |
public void initialize(FPopupMenu m) { |
303 |
super.initialize(m);
|
304 |
if (isTocItemBranch()) {
|
305 |
zoom = new JMenuItem(PluginServices.getText(this, "Zoom_al_Tema")); |
306 |
getMenu().add(zoom); |
307 |
zoom.setFont(FPopupMenu.theFont); |
308 |
|
309 |
zoom.addActionListener(this);
|
310 |
} |
311 |
} |
312 |
/* (non-Javadoc)
|
313 |
* @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
|
314 |
*/
|
315 |
public void actionPerformed(ActionEvent e) { |
316 |
/*FLayer lyr = getNodeLayer();
|
317 |
try {
|
318 |
getMapContext().getViewPort().setExtent(lyr.getFullExtent());
|
319 |
} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
|
320 |
e1.printStackTrace();
|
321 |
}*/
|
322 |
// 050209, jmorell: Para que haga un zoom a un grupo de capas seleccionadas.
|
323 |
FLayer[] actives = getMapContext().getLayers().getActives();
|
324 |
if (actives.length==1) { |
325 |
try {
|
326 |
getMapContext().getViewPort().setExtent(actives[0].getFullExtent());
|
327 |
} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
|
328 |
e1.printStackTrace(); |
329 |
} |
330 |
} else {
|
331 |
try {
|
332 |
Rectangle2D maxExtent = setMaxExtent(actives);
|
333 |
getMapContext().getViewPort().setExtent(maxExtent); |
334 |
} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
|
335 |
e1.printStackTrace(); |
336 |
} |
337 |
} |
338 |
} |
339 |
|
340 |
private Rectangle2D setMaxExtent(FLayer[] actives) throws DriverException { |
341 |
Rectangle2D extRef = actives[0].getFullExtent(); |
342 |
double minXRef = extRef.getMinX();
|
343 |
double maxYRef = extRef.getMaxY();
|
344 |
double maxXRef = extRef.getMaxX();
|
345 |
double minYRef = extRef.getMinY();
|
346 |
for (int i=0;i<actives.length;i++) { |
347 |
Rectangle2D extVar = actives[i].getFullExtent();
|
348 |
double minXVar = extVar.getMinX();
|
349 |
double maxYVar = extVar.getMaxY();
|
350 |
double maxXVar = extVar.getMaxX();
|
351 |
double minYVar = extVar.getMinY();
|
352 |
if (minXVar<=minXRef) minXRef=minXVar;
|
353 |
if (maxYVar>=maxYRef) maxYRef=maxYVar;
|
354 |
if (maxXVar>=maxXRef) maxXRef=maxXVar;
|
355 |
if (minYVar<=minYRef) minYRef=minYVar;
|
356 |
extRef.setRect(minXRef, minYRef, maxXRef-minXRef, maxYRef-minYRef); |
357 |
} |
358 |
return extRef;
|
359 |
} |
360 |
} |
361 |
|
362 |
class EliminarCapaTocMenuEntry extends TocMenuEntry { |
363 |
private JMenuItem removeLayer; |
364 |
public void initialize(FPopupMenu m) { |
365 |
super.initialize(m);
|
366 |
if (getNodeUserObject() instanceof TocItemBranch) { |
367 |
getMenu().addSeparator(); |
368 |
removeLayer = new JMenuItem(PluginServices.getText(this, "eliminar_capa")); |
369 |
getMenu().add(removeLayer); |
370 |
removeLayer.setFont(FPopupMenu.theFont); |
371 |
removeLayer.addActionListener(this);
|
372 |
} |
373 |
} |
374 |
/* (non-Javadoc)
|
375 |
* @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
|
376 |
*/
|
377 |
public void actionPerformed(ActionEvent e) { |
378 |
// 050209, jmorell: Para poder borrar todas las capas seleccionadas desde el FPopUpMenu.
|
379 |
// Es necesario pulsar May?sculas a la vez que el bot?n derecho.
|
380 |
FMap fMap = getMapContext(); |
381 |
FLayer[] actives = fMap.getLayers().getActives();
|
382 |
for (int i = actives.length-1; i>=0; i--){ |
383 |
try {
|
384 |
actives[i].getParentLayer().removeLayer(actives[i]); |
385 |
FLayers lyrs=getMapContext().getLayers(); |
386 |
lyrs.addLayer(actives[i]); |
387 |
actives[i].getParentLayer().removeLayer(actives[i]); |
388 |
|
389 |
if (getMapContext().getLayers().getLayersCount()==0) |
390 |
PluginServices.getMainFrame().enableControls(); |
391 |
} catch (CancelationException e1) {
|
392 |
e1.printStackTrace(); |
393 |
} |
394 |
} |
395 |
// 050209, jmorell: As? solo borra una capa (sobre la que pulsas).
|
396 |
/*FLayer lyr = getNodeLayer();
|
397 |
try {
|
398 |
getMapContext().getLayers().removeLayer(lyr);
|
399 |
if (getMapContext().getLayers().getLayersCount()==0)PluginServices.getMainFrame().enableControls();
|
400 |
} catch (CancelationException e1) {
|
401 |
e1.printStackTrace();
|
402 |
}*/
|
403 |
} |
404 |
} |
405 |
/**
|
406 |
* Realiza una agrupaci?n de capas, a partir de las capas que se encuentren activas.
|
407 |
*
|
408 |
* @author Vicente Caballero Navarro
|
409 |
*/
|
410 |
class LayersGroupTocMenuEntry extends TocMenuEntry { |
411 |
private JMenuItem agrupar; |
412 |
public void initialize(FPopupMenu m) { |
413 |
super.initialize(m);
|
414 |
agrupar = new JMenuItem(PluginServices.getText(this, "agrupar_capas")); |
415 |
agrupar.setFont(FPopupMenu.theFont); |
416 |
getMenu().add(agrupar); |
417 |
getMenu().setEnabled(true);
|
418 |
agrupar.addActionListener(this);
|
419 |
} |
420 |
|
421 |
/* (non-Javadoc)
|
422 |
* @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
|
423 |
*/
|
424 |
public void actionPerformed(ActionEvent e) { |
425 |
ITocItem tocItem = (ITocItem) getNodeUserObject(); |
426 |
|
427 |
String nombre="Agrupaci?n"; |
428 |
|
429 |
if (nombre != null){ |
430 |
if (isTocItemBranch()){
|
431 |
FLayer[] actives = getMapContext().getLayers().getActives();
|
432 |
|
433 |
if (actives.length>1) { |
434 |
FLayers layerGroup=new FLayers(getMapContext(),getNodeLayer().getParentLayer());
|
435 |
for (int i=0;i<actives.length;i++){ |
436 |
actives[i].getParentLayer().removeLayer(actives[i]); |
437 |
layerGroup.addLayer(actives[i]); |
438 |
|
439 |
///removeLayer(actives[i]);
|
440 |
|
441 |
} |
442 |
layerGroup.setName(nombre); |
443 |
//getNodeLayer().getParentLayer().addLayer(layerGroup);
|
444 |
View theView = (View) PluginServices.getMDIManager().getActiveView(); |
445 |
theView.getMapControl().getMapContext().getLayers() |
446 |
.addLayer(layerGroup); |
447 |
|
448 |
} |
449 |
|
450 |
} |
451 |
/*else
|
452 |
{
|
453 |
TocItemLeaf leaf = (TocItemLeaf) tocItem;
|
454 |
FSymbol sym = leaf.getSymbol();
|
455 |
sym.setColor(newColor);
|
456 |
|
457 |
}*/
|
458 |
// TRUCO PARA REFRESCAR.
|
459 |
getMapContext().invalidate(); |
460 |
|
461 |
} |
462 |
|
463 |
} |
464 |
} |
465 |
/**
|
466 |
* Realiza una desagrupaci?n de capas, a partir de las capas que se encuentren activas.
|
467 |
*
|
468 |
* @author Vicente Caballero Navarro
|
469 |
*/
|
470 |
class LayersUngroupTocMenuEntry extends TocMenuEntry { |
471 |
private JMenuItem desagrupar; |
472 |
public void initialize(FPopupMenu m) { |
473 |
super.initialize(m);
|
474 |
boolean isFLayers=true; |
475 |
if (isTocItemBranch()){
|
476 |
FLayer lyr = getNodeLayer(); |
477 |
if (!(lyr instanceof FLayers)){ |
478 |
isFLayers=false;
|
479 |
} |
480 |
/* for (int i=0;i<actives.length;i++){
|
481 |
if (!(actives[i] instanceof FLayers)){
|
482 |
isFLayers=false;
|
483 |
}
|
484 |
}
|
485 |
*/
|
486 |
} |
487 |
if (isFLayers){
|
488 |
desagrupar = new JMenuItem(PluginServices.getText(this, "desagrupar_capas")); |
489 |
desagrupar.setFont(FPopupMenu.theFont); |
490 |
getMenu().add(desagrupar); |
491 |
getMenu().setEnabled(true);
|
492 |
desagrupar.addActionListener(this);
|
493 |
} |
494 |
} |
495 |
|
496 |
/* (non-Javadoc)
|
497 |
* @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
|
498 |
*/
|
499 |
public void actionPerformed(ActionEvent e) { |
500 |
ITocItem tocItem = (ITocItem) getNodeUserObject(); |
501 |
if (isTocItemBranch()){
|
502 |
FLayers agrupa = (FLayers)getNodeLayer(); |
503 |
FLayers parent=agrupa.getParentLayer(); |
504 |
if (parent!=null){ |
505 |
for (int j=0;j<agrupa.getLayersCount();j++){ |
506 |
parent.addLayer(agrupa.getLayer(j)); |
507 |
} |
508 |
parent.removeLayer(agrupa); |
509 |
} |
510 |
|
511 |
/*View theView = (View) PluginServices.getMDIManager().getActiveView();
|
512 |
theView.getMapControl().getMapContext().getLayers()
|
513 |
.addLayer(layerGroup);
|
514 |
*/
|
515 |
|
516 |
} |
517 |
/*else
|
518 |
{
|
519 |
TocItemLeaf leaf = (TocItemLeaf) tocItem;
|
520 |
FSymbol sym = leaf.getSymbol();
|
521 |
sym.setColor(newColor);
|
522 |
|
523 |
}*/
|
524 |
// TRUCO PARA REFRESCAR.
|
525 |
getMapContext().invalidate(); |
526 |
|
527 |
} |
528 |
|
529 |
} |
530 |
|
531 |
/**
|
532 |
* Menu de bot?n derecho para el TOC.
|
533 |
* Se pueden a?adir entradas facilmente desde una extensi?n,
|
534 |
* creando una clase derivando de TocMenuEntry, y a?adiendola en
|
535 |
* est?tico (o en tiempo de carga de la extensi?n) a FPopupMenu.
|
536 |
* (Las entradas actuales est?n hechas de esa manera).
|
537 |
*
|
538 |
* @author vcn To change the template for this generated type comment go to
|
539 |
* Window>Preferences>Java>Code Generation>Code and
|
540 |
* Comments
|
541 |
*/
|
542 |
|
543 |
public class FPopupMenu extends JPopupMenu { |
544 |
private static ArrayList menuEntrys = null; |
545 |
public DefaultMutableTreeNode nodo; |
546 |
protected FMap mapContext;
|
547 |
//private JMenuItem capa;
|
548 |
// Lo de fijar la fuente es porque en linux se ve?a mal si no se fija.
|
549 |
// TODO: Esto no funcionar? para idiomas como el chino. Hay que cambiarlo.
|
550 |
public final static Font theFont = new Font("SansSerif", Font.PLAIN, 10); |
551 |
|
552 |
static {
|
553 |
menuEntrys = new ArrayList(); |
554 |
menuEntrys.add(new FSymbolChangeColorTocMenuEntry());
|
555 |
menuEntrys.add(new FLyrVectEditPropertiesTocMenuEntry());
|
556 |
menuEntrys.add(new FLyrRasterAdjustTransparencyTocMenuEntry());
|
557 |
menuEntrys.add(new ZoomAlTemaTocMenuEntry());
|
558 |
menuEntrys.add(new EliminarCapaTocMenuEntry());
|
559 |
menuEntrys.add(new LayersGroupTocMenuEntry());
|
560 |
menuEntrys.add(new LayersUngroupTocMenuEntry());
|
561 |
} |
562 |
|
563 |
public static void addEntry(TocMenuEntry entry) { |
564 |
menuEntrys.add(entry); |
565 |
} |
566 |
|
567 |
/**
|
568 |
* Creates a new FPopupMenu object.
|
569 |
*
|
570 |
* @param nodo DOCUMENT ME!
|
571 |
* @param vista DOCUMENT ME!
|
572 |
*/
|
573 |
public FPopupMenu(FMap mc, DefaultMutableTreeNode node) { |
574 |
//super();
|
575 |
this.mapContext = mc;
|
576 |
this.nodo = node;
|
577 |
|
578 |
//salir = new MenuItem("Salir");
|
579 |
|
580 |
for (int i=0; i<menuEntrys.size(); i++) { |
581 |
((TocMenuEntry) menuEntrys.get(i)).initialize(this);
|
582 |
} |
583 |
} |
584 |
|
585 |
public FMap getMapContext() { return mapContext; } |
586 |
|
587 |
} |