svn-gvsig-desktop / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / toc / GeoRasterTocMenuEntry.java @ 5362
History | View | Annotate | Download (6.63 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 org.gvsig.georeferencing.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 org.gvsig.georeferencing.gui.dialogs.GeoreferencingDialog; |
51 |
import org.gvsig.georeferencing.utils.GeoPointPersistence; |
52 |
import org.gvsig.georeferencing.utils.PointManager; |
53 |
import org.gvsig.georeferencing.utils.StackZoom; |
54 |
|
55 |
import com.iver.andami.PluginServices; |
56 |
import com.iver.andami.ui.mdiFrame.MDIFrame; |
57 |
import com.iver.cit.gvsig.fmap.FMap; |
58 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
59 |
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
60 |
import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
61 |
import com.iver.cit.gvsig.gui.View; |
62 |
import com.iver.cit.gvsig.gui.toc.FPopupMenu; |
63 |
import com.iver.cit.gvsig.gui.toc.TocMenuEntry; |
64 |
|
65 |
/**
|
66 |
* Entrada del men? del TOC que obtiene el cuadro de propiedades de capa
|
67 |
* georreferenciada.
|
68 |
*
|
69 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
70 |
*/
|
71 |
public class GeoRasterTocMenuEntry extends TocMenuEntry{ |
72 |
private JMenuItem propsMenuItem; |
73 |
private FLayer lyr = null; |
74 |
public static boolean isOpen = false; |
75 |
|
76 |
public void initialize(FPopupMenu m) { |
77 |
super.initialize(m);
|
78 |
|
79 |
if (isTocItemBranch()) {
|
80 |
lyr = getNodeLayer(); |
81 |
|
82 |
// Opcciones para capas FLyrGeoRaster
|
83 |
if ((lyr instanceof FLyrGeoRaster)) { |
84 |
propsMenuItem = new JMenuItem(PluginServices.getText(this, "georaster")); |
85 |
getMenu().add( propsMenuItem ); |
86 |
propsMenuItem.setFont(FPopupMenu.theFont); |
87 |
getMenu().setEnabled(true);
|
88 |
propsMenuItem.addActionListener(this);
|
89 |
} |
90 |
} |
91 |
} |
92 |
|
93 |
/**
|
94 |
* Evento producido al pulsar la entrada de men? del toc
|
95 |
* que muestra el cuadro con el dialogo de las propiedades
|
96 |
* de la capa de raster georreferenciada.
|
97 |
*/
|
98 |
public void actionPerformed(ActionEvent e) { |
99 |
FLyrGeoRaster lyrGeoRaster = null;
|
100 |
GeoreferencingDialog geoDialog = null;
|
101 |
|
102 |
//Caso en el que se crea una capa de georreferenciaci?n al abrir un proyecto
|
103 |
//hay que crear el dialogo, la persistencia y la pila de zooms y asignarlo a
|
104 |
//la capa de puntos. Todo esto se hace aqu? porque al levantar la capa desde el
|
105 |
//setXMLEntity no podemos acceder al c?digo de gvSIG
|
106 |
if(((FLyrGeoRaster)lyr).getPersistence() == null && ((FLyrGeoRaster)lyr).getZoom() == null){ |
107 |
JInternalFrame panel = PointManager.getInternalFrame(this); |
108 |
geoDialog = new GeoreferencingDialog(panel, ((FLyrGeoRaster)lyr));
|
109 |
((FLyrGeoRaster)lyr).getStackZoom().setInitExtent(((FLyrGeoRaster)lyr).getAssignExtent()); |
110 |
((FLyrGeoRaster)lyr).getFLyrPoints().saveState(); |
111 |
((FLyrGeoRaster)lyr).setGeoDialog(geoDialog); |
112 |
GeoPointPersistence geoPointPersistence = new GeoPointPersistence();
|
113 |
StackZoom zoom = new StackZoom();
|
114 |
((FLyrGeoRaster)lyr).setPersistence(geoPointPersistence); |
115 |
((FLyrGeoRaster)lyr).setZoom(zoom); |
116 |
GeoRasterTocMenuEntry.isOpen = true;
|
117 |
} |
118 |
|
119 |
if(isOpen){
|
120 |
GeoRasterTocMenuEntry.isOpen = false;
|
121 |
lyr = getNodeLayer(); |
122 |
|
123 |
PluginServices.getMainFrame().enableControls(); |
124 |
|
125 |
//Modificamos el nombre de la capa
|
126 |
if (lyr instanceof FLyrGeoRaster){ |
127 |
lyrGeoRaster = (FLyrGeoRaster)lyr; |
128 |
lyrGeoRaster.setName("*"+lyrGeoRaster.getName());
|
129 |
lyrGeoRaster.setActive(true);
|
130 |
geoDialog = (GeoreferencingDialog)lyrGeoRaster.getGeoDialog(); |
131 |
geoDialog.getSelectPointsPanel().resetControls(false);
|
132 |
geoDialog.getSelectPointsPanel().setEnlarge(true);
|
133 |
|
134 |
if(lyrGeoRaster.getFLyrPoints() != null){ |
135 |
//Salvamos el estado actual de la capa por si se cancela.
|
136 |
lyrGeoRaster.getFLyrPoints().saveState(); |
137 |
|
138 |
View theView = null; |
139 |
try{
|
140 |
theView = (View) PluginServices.getMDIManager().getActiveView();
|
141 |
}catch(ClassCastException exc){ |
142 |
return ;
|
143 |
} |
144 |
|
145 |
//Asignamos la capa de puntos como capa grafica
|
146 |
FMap fmap = theView.getMapControl().getMapContext(); |
147 |
if(fmap != null) |
148 |
fmap.setGraphicsLayer(lyrGeoRaster.getFLyrPoints()); |
149 |
|
150 |
//Hacemos visible la capa de puntos
|
151 |
lyrGeoRaster.getFLyrPoints().setVisible(true);
|
152 |
theView.getMapControl().getMapContext().invalidate(); |
153 |
|
154 |
geoDialog.getConectorPanel().getDataPointsTabPanel(). |
155 |
getSelectPointsPanel().getTableControlerPanel().setNItems(lyrGeoRaster.getFLyrPoints().getCountPoints()); |
156 |
|
157 |
if(lyrGeoRaster.getFLyrPoints().getCountPoints() > 0){ |
158 |
lyrGeoRaster.getFLyrPoints().getPointManager().selectPoint(0, geoDialog);
|
159 |
geoDialog.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getTableControlerPanel().getBDelPoint().setEnabled(true);
|
160 |
geoDialog.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getTableControlerPanel().getBClear().setEnabled(true);
|
161 |
} |
162 |
} |
163 |
} |
164 |
|
165 |
//Lanzamos el dialogo
|
166 |
JInternalFrame panel = PointManager.getInternalFrame(this); |
167 |
panel.getContentPane().add(geoDialog); |
168 |
geoDialog.setEnlarge(false);
|
169 |
geoDialog.setSelectedTab(0);
|
170 |
geoDialog.setFrame(panel); |
171 |
|
172 |
MDIFrame mainFrame = (MDIFrame) PluginServices.getMainFrame(); |
173 |
JLayeredPane lyrPane = mainFrame.getLayeredPane();
|
174 |
lyrPane.add(panel, JDesktopPane.PALETTE_LAYER);
|
175 |
panel.pack(); |
176 |
panel.setSize(geoDialog.getWidth() + 12, geoDialog.getHeight() + 10); |
177 |
panel.show(); |
178 |
|
179 |
PluginServices.getMainFrame().enableControls(); |
180 |
} |
181 |
} |
182 |
|
183 |
|
184 |
} |