root / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / imagefusion / gui / FusionPanel.java @ 22828
History | View | Annotate | Download (7.03 KB)
1 |
/*
|
---|---|
2 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
3 |
*
|
4 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* Generalitat Valenciana
|
23 |
* Conselleria d'Infraestructures i Transport
|
24 |
* Av. Blasco Iba?ez, 50
|
25 |
* 46010 VALENCIA
|
26 |
* SPAIN
|
27 |
*
|
28 |
* +34 963862235
|
29 |
* gvsig@gva.es
|
30 |
* www.gvsig.gva.es
|
31 |
*
|
32 |
* or
|
33 |
*
|
34 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
|
35 |
* Campus Universitario s/n
|
36 |
* 02071 Alabacete
|
37 |
* Spain
|
38 |
*
|
39 |
* +34 967 599 200
|
40 |
*/
|
41 |
|
42 |
package org.gvsig.remotesensing.imagefusion.gui; |
43 |
|
44 |
import java.awt.BorderLayout; |
45 |
import java.awt.Dimension; |
46 |
import java.awt.GridBagConstraints; |
47 |
import java.awt.GridBagLayout; |
48 |
import java.awt.Insets; |
49 |
import java.util.ArrayList; |
50 |
|
51 |
import javax.swing.BorderFactory; |
52 |
import javax.swing.JPanel; |
53 |
import javax.swing.border.TitledBorder; |
54 |
|
55 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
56 |
import org.gvsig.raster.beans.previewbase.IPreviewRenderProcess; |
57 |
import org.gvsig.raster.beans.previewbase.PreviewBasePanel; |
58 |
import org.gvsig.raster.grid.filter.FilterTypeException; |
59 |
import org.gvsig.raster.hierarchy.IRasterRendering; |
60 |
import org.gvsig.remotesensing.imagefusion.gui.components.CreateOptionsFusionPanel; |
61 |
|
62 |
import com.iver.andami.PluginServices; |
63 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
64 |
|
65 |
/**
|
66 |
* Panel que compone el dialogo para la fusion de imagenes.
|
67 |
*
|
68 |
* @author aMu?oz (alejandro.munoz@uclm.es)
|
69 |
*/
|
70 |
public class FusionPanel extends JPanel implements IPreviewRenderProcess { |
71 |
private static final long serialVersionUID = 7152780112689637266L; |
72 |
|
73 |
private PreviewBasePanel previewBasePanel = null; |
74 |
private FLayer layer = null; |
75 |
private FusionListener fusionListener = null; |
76 |
private String viewName = null; |
77 |
private JPanel jPanelOptions = null; |
78 |
private FusionMainPanel fusionMain = null; |
79 |
private FusionDialog fusionDialog = null; |
80 |
private CreateOptionsFusionPanel newLayerPanel = null; |
81 |
|
82 |
/**
|
83 |
* Constructor
|
84 |
* @param width Ancho del panel
|
85 |
* @param height Alto del panel
|
86 |
*/
|
87 |
public FusionPanel(FLayer layer, FusionDialog filterDialog) {
|
88 |
this.fusionDialog = filterDialog;
|
89 |
setLayer(layer); |
90 |
initialize(); |
91 |
} |
92 |
|
93 |
private void initialize() { |
94 |
setLayout(new BorderLayout()); |
95 |
add(getPreviewBasePanel(), BorderLayout.CENTER);
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* Obtiene el panel con el histograma
|
100 |
* @return HistogramPanel
|
101 |
*/
|
102 |
private PreviewBasePanel getPreviewBasePanel() {
|
103 |
if (previewBasePanel == null) { |
104 |
ArrayList list = new ArrayList(); |
105 |
list.add(getMainPanel()); |
106 |
previewBasePanel = new PreviewBasePanel(list, null, panelOptions(), this, (FLyrRasterSE) layer); |
107 |
previewBasePanel.setPreviewSize(new Dimension(230, 215)); |
108 |
previewBasePanel.addButtonPressedListener(fusionDialog); |
109 |
} |
110 |
return previewBasePanel;
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* Devuelve el componente <code>fusionListener</code>, que contendr? el
|
115 |
* proceso en si del panel
|
116 |
*/
|
117 |
private FusionListener getFusionListener() {
|
118 |
if (fusionListener == null) { |
119 |
fusionListener = new FusionListener(this); |
120 |
} |
121 |
return fusionListener;
|
122 |
} |
123 |
|
124 |
/**
|
125 |
* Devuelve el panel de Opciones, en caso de no existir, lo crea.
|
126 |
* @return
|
127 |
*/
|
128 |
private JPanel panelOptions() { |
129 |
if (jPanelOptions == null) { |
130 |
jPanelOptions = new JPanel(); |
131 |
GridBagConstraints gridBagConstraints;
|
132 |
jPanelOptions.setLayout(new GridBagLayout()); |
133 |
gridBagConstraints = new GridBagConstraints(); |
134 |
gridBagConstraints.gridx = 0;
|
135 |
gridBagConstraints.gridy = 4;
|
136 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
137 |
gridBagConstraints.insets = new Insets(3, 3, 3, 3); |
138 |
jPanelOptions.add(getNewLayerPanel().getJPanel(), gridBagConstraints); |
139 |
gridBagConstraints = new GridBagConstraints(); |
140 |
gridBagConstraints.gridx = 0;
|
141 |
gridBagConstraints.gridy = 5;
|
142 |
gridBagConstraints.weightx = 1.0;
|
143 |
gridBagConstraints.weighty = 1.0;
|
144 |
jPanelOptions.add(new JPanel(), gridBagConstraints); |
145 |
} |
146 |
return jPanelOptions;
|
147 |
} |
148 |
|
149 |
/**Panel con las opciones de seleccion de bandas para la fusion*/
|
150 |
public CreateOptionsFusionPanel getNewLayerPanel() {
|
151 |
if (newLayerPanel == null) { |
152 |
newLayerPanel = new CreateOptionsFusionPanel((FLyrRasterSE)layer);
|
153 |
} |
154 |
return newLayerPanel;
|
155 |
} |
156 |
|
157 |
|
158 |
/**
|
159 |
* Definir el FLayer del panel, haciendo todas las cargas necesarias despues
|
160 |
* de especificarlo.
|
161 |
* @param layer
|
162 |
*/
|
163 |
private void setLayer(FLayer layer) { |
164 |
if (layer == null) |
165 |
return;
|
166 |
this.layer = layer;
|
167 |
getPreviewBasePanel().setLayer((FLyrRasterSE) layer); |
168 |
} |
169 |
|
170 |
public FusionMainPanel getMainPanel() {
|
171 |
if (fusionMain == null) { |
172 |
fusionMain = new FusionMainPanel(getFusionListener());
|
173 |
JPanel panel = getNewLayerPanel().getFileNamePanel();
|
174 |
panel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "nombre_capa"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
175 |
fusionMain.getCentralPanel().add(panel, BorderLayout.SOUTH);
|
176 |
} |
177 |
return fusionMain;
|
178 |
} |
179 |
|
180 |
/**
|
181 |
* Volvemos todo a la normalidad cuando se cancela
|
182 |
*/
|
183 |
public void cancel() { |
184 |
if (layer != null) |
185 |
layer.getMapContext().invalidate(); |
186 |
} |
187 |
|
188 |
/**
|
189 |
* Cuando se aceptan los cambios en el panel ejecutaremos el aceptar del
|
190 |
* listener
|
191 |
*/
|
192 |
public void accept() { |
193 |
fusionListener.accept(); |
194 |
} |
195 |
|
196 |
|
197 |
/**
|
198 |
* Actualizamos la vista previa
|
199 |
*/
|
200 |
public void refreshPreview() { |
201 |
getPreviewBasePanel().refreshPreview(); |
202 |
} |
203 |
|
204 |
/**
|
205 |
* Devuelve el FLayer asignado al panel
|
206 |
* @return
|
207 |
*/
|
208 |
public FLayer getLayer() {
|
209 |
return layer;
|
210 |
} |
211 |
|
212 |
/**
|
213 |
* Obtiene el nombre de la vista
|
214 |
* @return
|
215 |
*/
|
216 |
public String getViewName() { |
217 |
return viewName;
|
218 |
} |
219 |
|
220 |
/**
|
221 |
* Especificar el nombre de la nueva capa para el recuadro de texto asign?ndo
|
222 |
* en cada llamada un nombre consecutivo.
|
223 |
*/
|
224 |
public void updateNewLayerText() { |
225 |
getNewLayerPanel().updateNewLayerText(); |
226 |
} |
227 |
|
228 |
/*
|
229 |
* (non-Javadoc)
|
230 |
* @see org.gvsig.raster.beans.previewbase.IPreviewRenderProcess#process(org.gvsig.raster.hierarchy.IRasterRendering)
|
231 |
*/
|
232 |
public void process(IRasterRendering rendering) throws FilterTypeException { |
233 |
//getFusionListener().drawImage(rendering);
|
234 |
} |
235 |
|
236 |
/*
|
237 |
* (non-Javadoc)
|
238 |
* @see org.gvsig.raster.beans.previewbase.IPreviewRenderProcess#isShowPreview()
|
239 |
*/
|
240 |
public boolean isShowPreview() { |
241 |
return true; |
242 |
} |
243 |
|
244 |
/*
|
245 |
* (non-Javadoc)
|
246 |
* @see org.gvsig.raster.beans.previewbase.IPreviewRenderProcess#setShowPreview(boolean)
|
247 |
*/
|
248 |
public void setShowPreview(boolean showPreview) { |
249 |
} |
250 |
} |