svn-gvsig-desktop / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / toc / GeoRasterTocMenuEntry.java @ 4840
History | View | Annotate | Download (5.43 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.toc; |
42 |
|
43 |
import java.awt.event.ActionEvent; |
44 |
|
45 |
import javax.swing.JDesktopPane; |
46 |
import javax.swing.JInternalFrame; |
47 |
import javax.swing.JLayeredPane; |
48 |
import javax.swing.JMenuItem; |
49 |
|
50 |
import com.iver.andami.PluginServices; |
51 |
import com.iver.andami.ui.mdiFrame.MDIFrame; |
52 |
import com.iver.cit.gvsig.fmap.MapControl; |
53 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
54 |
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
55 |
import com.iver.cit.gvsig.gui.View; |
56 |
import com.iver.cit.gvsig.gui.dialogs.GeoreferencingDialog; |
57 |
import com.iver.cit.gvsig.gui.toc.FPopupMenu; |
58 |
import com.iver.cit.gvsig.gui.toc.TocMenuEntry; |
59 |
import com.iver.cit.gvsig.gui.wizards.GeoRasterWizard; |
60 |
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
61 |
import com.iver.cit.gvsig.utils.PointManager; |
62 |
|
63 |
/**
|
64 |
* Entrada del men? del TOC que obtiene el cuadro de propiedades de capa
|
65 |
* georreferenciada.
|
66 |
*
|
67 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
68 |
*/
|
69 |
public class GeoRasterTocMenuEntry extends TocMenuEntry{ |
70 |
private JMenuItem propsMenuItem; |
71 |
private FLayer lyr = null; |
72 |
public static boolean isOpen = false; |
73 |
|
74 |
public void initialize(FPopupMenu m) { |
75 |
super.initialize(m);
|
76 |
|
77 |
if (isTocItemBranch()) {
|
78 |
lyr = getNodeLayer(); |
79 |
|
80 |
// Opcciones para capas FLyrGeoRaster
|
81 |
if ((lyr instanceof FLyrGeoRaster)) { |
82 |
propsMenuItem = new JMenuItem(PluginServices.getText(this, "georaster_properties")); |
83 |
getMenu().add( propsMenuItem ); |
84 |
propsMenuItem.setFont(FPopupMenu.theFont); |
85 |
getMenu().setEnabled(true);
|
86 |
propsMenuItem.addActionListener(this);
|
87 |
} |
88 |
} |
89 |
} |
90 |
|
91 |
/**
|
92 |
* Evento producido al pulsar la entrada de men? del toc
|
93 |
* que muestra el cuadro con el dialogo de las propiedades
|
94 |
* de la capa de raster georreferenciada.
|
95 |
*/
|
96 |
public void actionPerformed(ActionEvent e) { |
97 |
if(isOpen){
|
98 |
GeoRasterTocMenuEntry.isOpen = false;
|
99 |
FLyrGeoRaster lyrGeoRaster = null;
|
100 |
lyr = getNodeLayer(); |
101 |
GeoreferencingDialog geoDialog = null;
|
102 |
|
103 |
PluginServices.getMainFrame().enableControls(); |
104 |
|
105 |
//Modificamos el nombre de la capa
|
106 |
if (lyr instanceof FLyrGeoRaster){ |
107 |
lyrGeoRaster = (FLyrGeoRaster)lyr; |
108 |
lyrGeoRaster.setName("*"+lyrGeoRaster.getName());
|
109 |
lyrGeoRaster.setActive(true);
|
110 |
geoDialog = lyrGeoRaster.getGeoDialog(); |
111 |
geoDialog.getSelectPointsPanel().resetControls(false);
|
112 |
geoDialog.getSelectPointsPanel().setEnlarge(true);
|
113 |
|
114 |
if(lyrGeoRaster.getFLyrPoints() != null){ |
115 |
//Salvamos el estado actual de la capa por si se cancela.
|
116 |
|
117 |
lyrGeoRaster.getFLyrPoints().saveState(); |
118 |
|
119 |
//lyrGeoRaster.getFLyrPoints().showPoints();
|
120 |
|
121 |
View theView = null; |
122 |
try{
|
123 |
theView = (View) PluginServices.getMDIManager().getActiveView();
|
124 |
}catch(ClassCastException exc){ |
125 |
return ;
|
126 |
} |
127 |
|
128 |
//Hacemos visible la capa de puntos
|
129 |
lyrGeoRaster.getFLyrPoints().setVisible(true);
|
130 |
theView.getMapControl().getMapContext().invalidate(); |
131 |
|
132 |
geoDialog.getConectorPanel().getDataPointsTabPanel(). |
133 |
getSelectPointsPanel().getTableControlerPanel().setNItems(lyrGeoRaster.getFLyrPoints().getCountPoints()); |
134 |
|
135 |
if(lyrGeoRaster.getFLyrPoints().getCountPoints() > 0){ |
136 |
lyrGeoRaster.getFLyrPoints().getPointManager().selectPoint(0, geoDialog);
|
137 |
geoDialog.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getTableControlerPanel().getBDelPoint().setEnabled(true);
|
138 |
geoDialog.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getTableControlerPanel().getBClear().setEnabled(true);
|
139 |
} |
140 |
} |
141 |
} |
142 |
|
143 |
//Lanzamos el dialogo
|
144 |
JInternalFrame panel = PointManager.getInternalFrame(this); |
145 |
panel.getContentPane().add(geoDialog); |
146 |
geoDialog.setEnlarge(false);
|
147 |
geoDialog.setSelectedTab(0);
|
148 |
geoDialog.setFrame(panel); |
149 |
|
150 |
MDIFrame mainFrame = (MDIFrame) PluginServices.getMainFrame(); |
151 |
JLayeredPane lyrPane = mainFrame.getLayeredPane();
|
152 |
lyrPane.add(panel, JDesktopPane.PALETTE_LAYER);
|
153 |
panel.pack(); |
154 |
panel.setSize(geoDialog.getWidth() + 12, geoDialog.getHeight() + 10); |
155 |
panel.show(); |
156 |
|
157 |
PluginServices.getMainFrame().enableControls(); |
158 |
} |
159 |
} |
160 |
|
161 |
|
162 |
} |