Revision 1670

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toc/FPopupMenu.java
47 47
import java.awt.Font;
48 48
import java.awt.event.ActionEvent;
49 49
import java.awt.event.ActionListener;
50
import java.awt.geom.Rectangle2D;
50 51
import java.util.ArrayList;
51 52

  
52 53
import javax.swing.JColorChooser;
......
54 55
import javax.swing.JFrame;
55 56
import javax.swing.JMenuItem;
56 57
import javax.swing.JPopupMenu;
58
import javax.swing.JTabbedPane;
57 59
import javax.swing.tree.DefaultMutableTreeNode;
58 60

  
59 61
import com.iver.andami.PluginServices;
......
70 72
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
71 73
import com.iver.cit.gvsig.gui.Panels.AdjustTransparencyPanel;
72 74
import com.iver.cit.gvsig.gui.legendmanager.FLegendManagerWindow;
75
import com.iver.cit.gvsig.gui.thememanager.FThemeManagerWindow;
73 76

  
74 77
/**
75 78
 * Realiza el cambio de color si se pulsa OK
......
97 100
        	color = new JMenuItem(PluginServices.getText(this, "Cambio_Color"));
98 101
        	color.setFont(FPopupMenu.theFont);
99 102
        	getMenu().add(color);        
100
        	getMenu().enable();
103
        	getMenu().setEnabled(true);
101 104
	        //Cambio color
102 105
	        color.addActionListener(this);
103 106
		}
......
183 186
	}
184 187
}
185 188

  
189
/**
190
 * Muestra el men? de propiedades del tema.
191
 * 
192
 * @author jmorell
193
 *
194
 * TODO To change the template for this generated type comment go to
195
 * Window - Preferences - Java - Code Style - Code Templates
196
 */
197
class FLyrVectEditPropertiesTocMenuEntry extends TocMenuEntry {
198
    private JMenuItem prop;
199
	public void initialize(FPopupMenu m) {
200
		super.initialize(m);
201
		FLayer lyr = null;
202
		if (isTocItemBranch()) {
203
			getMenu().addSeparator();
204
			lyr = getNodeLayer();
205
			if (lyr instanceof ClassifiableVectorial) {
206
		    	prop = new JMenuItem("Propiedades Pliego");
207
				getMenu().add(prop);
208
				prop.setFont(FPopupMenu.theFont);
209
				//Cambio estilo
210
				prop.addActionListener(this);
211
			}
212
		}
213
	}
214
	/* (non-Javadoc)
215
	 * @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
216
	 */
217
	public void actionPerformed(ActionEvent e) {
218
		/*FThemeManagerWindow fThemeManagerWindow = new FThemeManagerWindow();
219
		try {
220
			fThemeManagerWindow.setMapContext(getMapContext());
221
		} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
222
			e1.printStackTrace();
223
		}*/
224
		FLayer[] actives = getMapContext().getLayers().getActives();
225
		FThemeManagerWindow fThemeManagerWindow;
226
    	if (actives.length==1) {
227
    		System.out.println("openPliegoThemeProperties(): Una sola capa. Abrimos el panel para la capa " + actives[0]);
228
    		fThemeManagerWindow = new FThemeManagerWindow();
229
    		try {
230
    			fThemeManagerWindow.setMapContext(getMapContext());
231
    		} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
232
    			e1.printStackTrace();
233
    		}
234
            //PluginServices.getMDIManager().addView(fThemeManagerWindow);
235
    		if (PluginServices.getMainFrame() == null) {
236
    			JDialog dlg = new JDialog();
237
    			fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize());
238
    			dlg.getContentPane().add(fThemeManagerWindow);
239
    			dlg.setModal(false);			
240
    			dlg.pack();
241
    			dlg.show();
242
    		} else {
243
    			PluginServices.getMDIManager().addView(fThemeManagerWindow);
244
    		}
245
    	} else {
246
        	for (int i = 0; i < actives.length; i++){
247
        		System.out.println("openPliegoThemeProperties(): Muchas capas. Abrimos el panel para la capa " + actives[i]);
248
        		fThemeManagerWindow = new FThemeManagerWindow(actives[i], getMapContext());
249
                //PluginServices.getMDIManager().addView(fThemeManagerWindow);
250
        		if (PluginServices.getMainFrame() == null) {
251
        			JDialog dlg = new JDialog();
252
        			fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize());
253
        			dlg.getContentPane().add(fThemeManagerWindow);
254
        			dlg.setModal(false);			
255
        			dlg.pack();
256
        			dlg.show();
257
        		} else {
258
        			PluginServices.getMDIManager().addView(fThemeManagerWindow);
259
        		}
260
        	}
261
    	}
262
		/*if (PluginServices.getMainFrame() == null) {
263
			JDialog dlg = new JDialog();
264
			fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize());
265
			dlg.getContentPane().add(fThemeManagerWindow);
266
			dlg.setModal(false);			
267
			dlg.pack();
268
			dlg.show();
269
		} else {
270
			PluginServices.getMDIManager().addView(fThemeManagerWindow);
271
		}*/
272
	}
273
}
186 274

  
187 275
class FLyrRasterAdjustTransparencyTocMenuEntry extends TocMenuEntry {
188 276
	private JMenuItem transparency;
......
197 285
    		    transparency = new JMenuItem(PluginServices.getText(this, "adjust_transparency"));
198 286
    			getMenu().add( transparency );
199 287
    			transparency.setFont(FPopupMenu.theFont);
200
    			getMenu().enable();
288
    			getMenu().setEnabled(true);
201 289
    			getMenu().addSeparator();
202 290
    	        //Cambio color
203 291
    	        transparency.addActionListener(this);
......
219 307
    private JMenuItem zoom;
220 308
	public void initialize(FPopupMenu m) {
221 309
		super.initialize(m);
222
		
223 310
		if (isTocItemBranch()) {
224 311
			zoom = new JMenuItem(PluginServices.getText(this, "Zoom_al_Tema"));
225 312
			getMenu().add(zoom);
......
232 319
	 * @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
233 320
	 */
234 321
	public void actionPerformed(ActionEvent e) {
235
    	FLayer lyr = getNodeLayer();
236

  
322
    	/*FLayer lyr = getNodeLayer();
237 323
        try {
238 324
        	getMapContext().getViewPort().setExtent(lyr.getFullExtent());
239 325
		} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
240 326
			e1.printStackTrace();
327
		}*/
328
		// 050209, jmorell: Para que haga un zoom a un grupo de capas seleccionadas.
329
		FLayer[] actives = getMapContext().getLayers().getActives();
330
		if (actives.length==1) {
331
	        try {
332
	        	getMapContext().getViewPort().setExtent(actives[0].getFullExtent());
333
			} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
334
				e1.printStackTrace();
335
			}
336
		} else {
337
			try {
338
				Rectangle2D maxExtent = setMaxExtent(actives);
339
		    	getMapContext().getViewPort().setExtent(maxExtent);
340
			} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
341
				e1.printStackTrace();
342
			}
241 343
		}
242 344
	}
345
	
346
	private Rectangle2D setMaxExtent(FLayer[] actives) throws DriverException {
347
		Rectangle2D extRef = actives[0].getFullExtent();
348
		double minXRef = extRef.getMinX();
349
		double maxYRef = extRef.getMaxY();
350
		double maxXRef = extRef.getMaxX();
351
		double minYRef = extRef.getMinY();
352
		for (int i=0;i<actives.length;i++) {
353
        	Rectangle2D extVar = actives[i].getFullExtent();
354
    		double minXVar = extVar.getMinX();
355
    		double maxYVar = extVar.getMaxY();
356
    		double maxXVar = extVar.getMaxX();
357
    		double minYVar = extVar.getMinY();
358
    		if (minXVar<=minXRef) minXRef=minXVar;
359
    		if (maxYVar>=maxYRef) maxYRef=maxYVar;
360
    		if (maxXVar>=maxXRef) maxXRef=maxXVar;
361
    		if (minYVar<=minYRef) minYRef=minYVar;
362
    		extRef.setRect(minXRef, minYRef, maxXRef-minXRef, maxYRef-minYRef);
363
		}
364
		return extRef;
365
	}
243 366
}
244 367

  
245 368
class EliminarCapaTocMenuEntry extends TocMenuEntry {
246 369
    private JMenuItem removeLayer;
247 370
	public void initialize(FPopupMenu m) {
248 371
		super.initialize(m);
249
		
250 372
		if (getNodeUserObject() instanceof TocItemBranch) {
251 373
			getMenu().addSeparator();
252 374
			removeLayer = new JMenuItem(PluginServices.getText(this, "eliminar_capa"));
......
259 381
	 * @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem)
260 382
	 */
261 383
	public void actionPerformed(ActionEvent e) {
262
    	FLayer lyr = getNodeLayer();
263

  
384
    	// 050209, jmorell: Para poder borrar todas las capas seleccionadas desde el FPopUpMenu.
385
		//					Es necesario pulsar May?sculas a la vez que el bot?n derecho.
386
    	FMap fMap = getMapContext();
387
    	FLayer[] actives = fMap.getLayers().getActives();
388
    	for (int i = 0; i < actives.length; i++){
389
        	try {
390
            	getMapContext().getLayers().removeLayer(actives[i]);
391
            	if (getMapContext().getLayers().getLayersCount()==0)PluginServices.getMainFrame().enableControls();
392
    		} catch (CancelationException e1) {
393
    			e1.printStackTrace();
394
    		}
395
    	}
396
		// 050209, jmorell: As? solo borra una capa (sobre la que pulsas).
397
    	/*FLayer lyr = getNodeLayer();
264 398
        try {
265 399
        	getMapContext().getLayers().removeLayer(lyr);
266 400
        	if (getMapContext().getLayers().getLayersCount()==0)PluginServices.getMainFrame().enableControls();
267 401
		} catch (CancelationException e1) {
268 402
			e1.printStackTrace();
269
		}
403
		}*/
270 404
    }
271

  
272 405
}
273 406

  
274 407
/**
......
299 432
    	menuEntrys.add(new FLyrRasterAdjustTransparencyTocMenuEntry());
300 433
    	menuEntrys.add(new ZoomAlTemaTocMenuEntry());
301 434
    	menuEntrys.add(new EliminarCapaTocMenuEntry());
435
    	//050201 jmorell: Acceso al men? propiedades.
436
    	menuEntrys.add(new FLyrVectEditPropertiesTocMenuEntry());
302 437
    }
303 438

  
304 439
    public static void addEntry(TocMenuEntry entry) {

Also available in: Unified diff