Revision 9890
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.80/org.gvsig.raster.multifile.app.multifileclient/buildNumber.properties | ||
---|---|---|
1 |
#Mon Oct 07 10:20:26 CEST 2019 |
|
2 |
buildNumber=132 |
|
0 | 3 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.80/org.gvsig.raster.multifile.app.multifileclient/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
|
|
26 |
<dependencySets> |
|
27 |
<dependencySet> |
|
28 |
<useProjectArtifact>false</useProjectArtifact> |
|
29 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
30 |
<outputDirectory>lib</outputDirectory> |
|
31 |
<includes> |
|
32 |
<include>org.gvsig:org.gvsig.raster.multifile.app.multifileclient:jar</include> |
|
33 |
<include>org.gvsig:org.gvsig.raster.multifile.io:jar</include> |
|
34 |
</includes> |
|
35 |
</dependencySet> |
|
36 |
</dependencySets> |
|
37 |
</assembly> |
|
0 | 38 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.80/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/BandSelectorPanel.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.multifile.app.panel; |
|
23 |
|
|
24 |
import java.awt.Dimension; |
|
25 |
import java.awt.GridBagConstraints; |
|
26 |
import java.awt.GridBagLayout; |
|
27 |
import java.awt.Insets; |
|
28 |
import java.awt.event.ComponentEvent; |
|
29 |
import java.awt.image.DataBuffer; |
|
30 |
import java.io.File; |
|
31 |
import java.net.URI; |
|
32 |
import java.util.ArrayList; |
|
33 |
import java.util.List; |
|
34 |
|
|
35 |
import javax.swing.JButton; |
|
36 |
import javax.swing.JComboBox; |
|
37 |
import javax.swing.JLabel; |
|
38 |
import javax.swing.JPanel; |
|
39 |
import javax.swing.event.TableModelEvent; |
|
40 |
import javax.swing.event.TableModelListener; |
|
41 |
import javax.swing.table.DefaultTableModel; |
|
42 |
|
|
43 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
44 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
45 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
46 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
|
47 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
|
48 |
import org.gvsig.gui.beans.table.TableContainer; |
|
49 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
50 |
import org.gvsig.i18n.Messages; |
|
51 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
52 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
|
53 |
import org.gvsig.raster.mainplugin.properties.RasterPropertiesTocMenuEntry; |
|
54 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
55 |
import org.slf4j.Logger; |
|
56 |
import org.slf4j.LoggerFactory; |
|
57 |
|
|
58 |
/** |
|
59 |
* Selecciona las bandas visibles en un raster. Contiene una tabla con una fila |
|
60 |
* por cada banda de la imagen. Por medio de checkbox se selecciona para cada |
|
61 |
* RGB que banda de la imagen ser? visualizada. |
|
62 |
* |
|
63 |
|
|
64 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
65 |
*/ |
|
66 |
public class BandSelectorPanel extends AbstractPanel implements TableModelListener { |
|
67 |
final private static long serialVersionUID = -3370601314380922368L; |
|
68 |
public static final int TYPE_PROPERTIES = 0; |
|
69 |
public static final int TYPE_DIALOG = 1; |
|
70 |
|
|
71 |
private final String[] columnNames = { "A", "R", "G", "B", "Band" }; |
|
72 |
private final int[] columnWidths = { 22, 22, 22, 22, 334 }; |
|
73 |
|
|
74 |
private FLyrRaster fLayer = null; |
|
75 |
|
|
76 |
private BandSelectorFileList fileList = null; |
|
77 |
|
|
78 |
// Ultima y penultima columnas activadas del jtable para cuando hay 2 bandas seleccionadas en el combo |
|
79 |
private int[] col = { 0, 1 }; |
|
80 |
private AbstractBandSelectorListener |
|
81 |
panelListener = null; |
|
82 |
private TableContainer table = null; |
|
83 |
private JButton saveButton = null; |
|
84 |
|
|
85 |
private JPanel buttonsPanel = null; |
|
86 |
private JComboBox jComboBox = null; |
|
87 |
|
|
88 |
private static final Logger logger = |
|
89 |
LoggerFactory.getLogger(BandSelectorPanel.class); |
|
90 |
/** |
|
91 |
* Constructor to be instantiated from the properties panels |
|
92 |
*/ |
|
93 |
public BandSelectorPanel() { |
|
94 |
super(); |
|
95 |
panelListener = new BandSelectorPropertiesListener(this); |
|
96 |
initialize(); |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* This method initializes |
|
101 |
* @param type |
|
102 |
*/ |
|
103 |
public BandSelectorPanel(int type) { |
|
104 |
super(); |
|
105 |
if(type == TYPE_PROPERTIES) |
|
106 |
panelListener = new BandSelectorPropertiesListener(this); |
|
107 |
if(type == TYPE_DIALOG) |
|
108 |
panelListener = new BandSelectorNewLayerListener(this); |
|
109 |
initialize(); |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* @return AbstractBandSelectorListener |
|
114 |
*/ |
|
115 |
public AbstractBandSelectorListener getListener() { |
|
116 |
return panelListener; |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* This method initializes this |
|
121 |
*/ |
|
122 |
protected void initialize() { |
|
123 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
124 |
setLayout(new GridBagLayout()); |
|
125 |
gbc.insets = new Insets(0, 0, 0, 0); |
|
126 |
gbc.fill = GridBagConstraints.BOTH; |
|
127 |
|
|
128 |
gbc.weightx = 1.0; |
|
129 |
gbc.weighty = 1.0; |
|
130 |
add(getFileList(), gbc); |
|
131 |
|
|
132 |
gbc.gridy = 1; |
|
133 |
add(getARGBTable(), gbc); |
|
134 |
|
|
135 |
gbc.weighty = 0; |
|
136 |
gbc.gridy = 2; |
|
137 |
gbc.fill = GridBagConstraints.EAST; |
|
138 |
gbc.anchor = GridBagConstraints.EAST; |
|
139 |
gbc.insets = new Insets(0, 0, 0, 8); |
|
140 |
if(panelListener instanceof BandSelectorPropertiesListener) |
|
141 |
add(getButtonsPanel(), gbc); |
|
142 |
|
|
143 |
this.setPreferredSize(new Dimension(100, 80)); |
|
144 |
super.setLabel(Messages.getText("bands_panel")); |
|
145 |
|
|
146 |
this.setPriority(80); |
|
147 |
} |
|
148 |
|
|
149 |
/** |
|
150 |
* Obtiene el panel que contiene la lista de ficheros por banda. |
|
151 |
* @return Panel FileList |
|
152 |
*/ |
|
153 |
public BandSelectorFileList getFileList() { |
|
154 |
if (fileList == null) |
|
155 |
fileList = new BandSelectorFileList(); |
|
156 |
return fileList; |
|
157 |
} |
|
158 |
|
|
159 |
/** |
|
160 |
* Obtiene la Tabla |
|
161 |
* @return Tabla de bandas de la imagen |
|
162 |
*/ |
|
163 |
public TableContainer getARGBTable() { |
|
164 |
if (table == null) { |
|
165 |
ArrayList<AbstractBandSelectorListener> listeners = new ArrayList<AbstractBandSelectorListener>(); |
|
166 |
listeners.add(panelListener); |
|
167 |
table = new TableContainer(columnNames, columnWidths, listeners); |
|
168 |
table.setModel("ARGBBandSelectorModel"); |
|
169 |
table.setControlVisible(false); |
|
170 |
table.getModel().addTableModelListener(this); |
|
171 |
table.initialize(); |
|
172 |
} |
|
173 |
return table; |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* Obtiene el Panel con bot?n de salvado y selector de bandas. |
|
178 |
* @return JPanel |
|
179 |
*/ |
|
180 |
public JPanel getButtonsPanel() { |
|
181 |
if (buttonsPanel == null) { |
|
182 |
buttonsPanel = new JPanel(); |
|
183 |
buttonsPanel.setLayout(new GridBagLayout()); |
|
184 |
JLabel lbandasVisibles = new JLabel(); |
|
185 |
lbandasVisibles.setText(Messages.getText("bands")); |
|
186 |
|
|
187 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
188 |
gbc.insets = new Insets(0, 8, 0, 0); |
|
189 |
gbc.fill = GridBagConstraints.BOTH; |
|
190 |
gbc.weightx = 1.0; |
|
191 |
buttonsPanel.add(lbandasVisibles, gbc); |
|
192 |
|
|
193 |
gbc = new GridBagConstraints(); |
|
194 |
gbc.insets = new Insets(0, 8, 0, 0); |
|
195 |
gbc.fill = GridBagConstraints.BOTH; |
|
196 |
gbc.gridx = 1; |
|
197 |
getNumBandSelectorCombo().setMinimumSize(new Dimension(50, getNumBandSelectorCombo().getMinimumSize().height)); |
|
198 |
getNumBandSelectorCombo().setPreferredSize(new Dimension(50, getNumBandSelectorCombo().getMinimumSize().height)); |
|
199 |
buttonsPanel.add(getNumBandSelectorCombo(), gbc); |
|
200 |
|
|
201 |
gbc = new GridBagConstraints(); |
|
202 |
gbc.insets = new Insets(0, 8, 0, 0); |
|
203 |
gbc.fill = GridBagConstraints.BOTH; |
|
204 |
gbc.weightx = 1.0; |
|
205 |
gbc.gridx = 2; |
|
206 |
buttonsPanel.add(getSaveButton(), gbc); |
|
207 |
} |
|
208 |
return buttonsPanel; |
|
209 |
} |
|
210 |
|
|
211 |
/** |
|
212 |
* Obtiene el combo del selector del n?mero de bandas |
|
213 |
* @return JComboBox |
|
214 |
*/ |
|
215 |
public JComboBox getNumBandSelectorCombo() { |
|
216 |
if (jComboBox == null) { |
|
217 |
String[] list = { "1", "2", "3" }; |
|
218 |
jComboBox = new JComboBox(list); |
|
219 |
jComboBox.setSelectedIndex(2); |
|
220 |
jComboBox.setPreferredSize(new java.awt.Dimension(36, 25)); |
|
221 |
} |
|
222 |
|
|
223 |
return jComboBox; |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* Bot?n de salvar la interpretaci?n de color seleccionada como predeterminada en |
|
228 |
* la capa |
|
229 |
* @return JButton |
|
230 |
*/ |
|
231 |
public JButton getSaveButton() { |
|
232 |
if(saveButton == null) { |
|
233 |
saveButton = new JButton(Messages.getText("save")); |
|
234 |
saveButton.setToolTipText(Messages.getText("save_color_interpretation")); |
|
235 |
saveButton.addActionListener(panelListener); |
|
236 |
} |
|
237 |
return saveButton; |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* A?ade la lista de georasterfiles a la tabla |
|
242 |
* @param dstore |
|
243 |
* @throws NotInitializeException |
|
244 |
*/ |
|
245 |
public void addFiles(RasterDataStore dstore) throws NotInitializeException { |
|
246 |
getFileList().clear(); |
|
247 |
clear(); |
|
248 |
if(dstore.isMultiFile()) { |
|
249 |
URI[] uris = dstore.getURIByProvider(); |
|
250 |
for (int i = 0; i < uris.length; i++) { |
|
251 |
getFileList().addFName(new File(uris[i]).getAbsolutePath()); |
|
252 |
} |
|
253 |
} else |
|
254 |
getFileList().addFName(dstore.getName()); |
|
255 |
|
|
256 |
int nbands = dstore.getBandCount(); |
|
257 |
for (int i = 0; i < nbands; i++) { |
|
258 |
URI uriByBand = dstore.getURIByBand(i); |
|
259 |
String bandName = ""; |
|
260 |
if("FILE".equalsIgnoreCase(uriByBand.getScheme())){ |
|
261 |
File file = new File(uriByBand); |
|
262 |
bandName = file.getName(); |
|
263 |
} else { |
|
264 |
bandName = dstore.getFullName(); |
|
265 |
} |
|
266 |
|
|
267 |
String bandType = ""; |
|
268 |
|
|
269 |
switch (dstore.getDataType()[0]) { |
|
270 |
case DataBuffer.TYPE_BYTE: |
|
271 |
bandType = "8U"; |
|
272 |
break; |
|
273 |
case DataBuffer.TYPE_INT: |
|
274 |
bandType = "32"; |
|
275 |
break; |
|
276 |
case DataBuffer.TYPE_DOUBLE: |
|
277 |
bandType = "64"; |
|
278 |
break; |
|
279 |
case DataBuffer.TYPE_FLOAT: |
|
280 |
bandType = "32"; |
|
281 |
break; |
|
282 |
case DataBuffer.TYPE_SHORT: |
|
283 |
bandType = "16"; |
|
284 |
break; |
|
285 |
case DataBuffer.TYPE_USHORT: |
|
286 |
bandType = "16U"; |
|
287 |
break; |
|
288 |
case DataBuffer.TYPE_UNDEFINED: |
|
289 |
bandType = "??"; |
|
290 |
break; |
|
291 |
} |
|
292 |
|
|
293 |
addBand((i + 1) + " [" + bandType + "] " + bandName); |
|
294 |
} |
|
295 |
|
|
296 |
if(fLayer != null) { |
|
297 |
readDrawedBands(); |
|
298 |
saveStatus(); |
|
299 |
} |
|
300 |
//evaluateControlsEnabled(); |
|
301 |
} |
|
302 |
|
|
303 |
/** |
|
304 |
* Elimina un fichero de la lista |
|
305 |
* @param file Nombre del fichero a eliminar |
|
306 |
*/ |
|
307 |
public void removeFile(String file) { |
|
308 |
getFileList().removeFName(file); |
|
309 |
|
|
310 |
for (int i = 0; i < ((DefaultTableModel) getARGBTable().getModel()).getRowCount(); i++) { |
|
311 |
// Si el fichero borrado estaba seleccionado como banda visible. Pasaremos |
|
312 |
// esta visibilidad a la banda inmediata superior y si esta acci?n produce |
|
313 |
// una excepci?n (porque no hay) se pasa al inmediato inferior. |
|
314 |
if (((String) ((DefaultTableModel) getARGBTable().getModel()).getValueAt(i, 4)).endsWith(file)) { |
|
315 |
try { |
|
316 |
if (((Boolean) ((DefaultTableModel) getARGBTable().getModel()).getValueAt(i, 0)).booleanValue()) { |
|
317 |
((DefaultTableModel) getARGBTable().getModel()).setValueAt(new Boolean(true), i - 1, 1); |
|
318 |
} |
|
319 |
} catch (ArrayIndexOutOfBoundsException exc) { |
|
320 |
((DefaultTableModel) getARGBTable().getModel()).setValueAt(new Boolean(true), i + 1, 1); |
|
321 |
} |
|
322 |
|
|
323 |
try { |
|
324 |
if (((Boolean) ((DefaultTableModel) getARGBTable().getModel()).getValueAt(i, 1)).booleanValue()) { |
|
325 |
((DefaultTableModel) getARGBTable().getModel()).setValueAt(new Boolean(true), i - 1, 2); |
|
326 |
} |
|
327 |
} catch (ArrayIndexOutOfBoundsException exc) { |
|
328 |
((DefaultTableModel) getARGBTable().getModel()).setValueAt(new Boolean(true), i + 1, 2); |
|
329 |
} |
|
330 |
|
|
331 |
try { |
|
332 |
if (((Boolean) ((DefaultTableModel) getARGBTable().getModel()).getValueAt(i, 2)).booleanValue()) { |
|
333 |
((DefaultTableModel) getARGBTable().getModel()).setValueAt(new Boolean(true), i - 1, 3); |
|
334 |
} |
|
335 |
} catch (ArrayIndexOutOfBoundsException exc) { |
|
336 |
((DefaultTableModel) getARGBTable().getModel()).setValueAt(new Boolean(true), i + 1, 3); |
|
337 |
} |
|
338 |
|
|
339 |
((DefaultTableModel) getARGBTable().getModel()).removeRow(i); |
|
340 |
i--; // Ojo! que hemos eliminado una fila |
|
341 |
} |
|
342 |
} |
|
343 |
panelListener.setNewBandsPositionInRendering(); |
|
344 |
} |
|
345 |
|
|
346 |
/** |
|
347 |
* Cuando cambiamos el combo de seleccion de numero de bandas a visualizar |
|
348 |
* debemos resetear la tabla de checkbox para que no haya activados m?s de los |
|
349 |
* permitidos |
|
350 |
* @param mode |
|
351 |
*/ |
|
352 |
public void resetMode(int mode) { |
|
353 |
DefaultTableModel model = getARGBTable().getModel(); |
|
354 |
// Reseteamos los checkbox |
|
355 |
for (int i = 0; i < (model.getColumnCount() - 1); i++) |
|
356 |
for (int j = 0; j < model.getRowCount(); j++) |
|
357 |
model.setValueAt(Boolean.FALSE, j, i); |
|
358 |
|
|
359 |
// Asignamos los valores |
|
360 |
if (getNBands() >= 1) { |
|
361 |
switch (mode) { |
|
362 |
case 3: |
|
363 |
int b = 2; |
|
364 |
if (getNBands() < 3) |
|
365 |
b = getNBands() - 1; |
|
366 |
model.setValueAt(Boolean.TRUE, b, 3); |
|
367 |
case 2: |
|
368 |
int g = 1; |
|
369 |
if (getNBands() == 1) |
|
370 |
g = 0; |
|
371 |
model.setValueAt(Boolean.TRUE, g, 2); |
|
372 |
case 1: |
|
373 |
model.setValueAt(Boolean.TRUE, 0, 1); |
|
374 |
} |
|
375 |
} |
|
376 |
|
|
377 |
col[0] = 0; |
|
378 |
col[1] = 1; |
|
379 |
} |
|
380 |
|
|
381 |
/** |
|
382 |
* A?ade una banda a la tabla bandas de la imagen asignandole un nombre y |
|
383 |
* valor a los checkbox |
|
384 |
* @param bandName Nombre de la banda |
|
385 |
* @throws NotInitializeException |
|
386 |
*/ |
|
387 |
private void addBand(String bandName) throws NotInitializeException { |
|
388 |
Object[] row = { new Boolean(false), |
|
389 |
new Boolean(false), |
|
390 |
new Boolean(false), |
|
391 |
new Boolean(false), |
|
392 |
bandName }; |
|
393 |
getARGBTable().addRow(row); |
|
394 |
} |
|
395 |
|
|
396 |
/** |
|
397 |
* Elimina todas las entradas de la tabla de bandas. |
|
398 |
*/ |
|
399 |
private void clear() { |
|
400 |
int rows = ((DefaultTableModel) getARGBTable().getModel()).getRowCount(); |
|
401 |
if (rows > 0) { |
|
402 |
for (int i = 0; i < rows; i++) |
|
403 |
((DefaultTableModel) getARGBTable().getModel()).removeRow(0); |
|
404 |
} |
|
405 |
} |
|
406 |
|
|
407 |
/** |
|
408 |
* Obtiene el n?mero de bandas de la lista |
|
409 |
* |
|
410 |
* @return the number of bands |
|
411 |
*/ |
|
412 |
public int getNBands() { |
|
413 |
return ((DefaultTableModel) getARGBTable().getModel()).getRowCount(); |
|
414 |
} |
|
415 |
|
|
416 |
/** |
|
417 |
* Obtiene el nombre de la banda de la posici?n i de la tabla |
|
418 |
* |
|
419 |
* @param i |
|
420 |
* @return the band name |
|
421 |
*/ |
|
422 |
public String getBandName(int i) { |
|
423 |
String s = (String) ((DefaultTableModel) getARGBTable().getModel()).getValueAt(i, 3); |
|
424 |
return s.substring(s.lastIndexOf("[8U]") + 5, s.length()); |
|
425 |
} |
|
426 |
|
|
427 |
/** |
|
428 |
* Mantiene la asignaci?n entre R, G o B y la banda de la imagen que le |
|
429 |
* corresponde |
|
430 |
* |
|
431 |
* @param nBand Banda de la imagen que corresponde |
|
432 |
* @param flag R, G o B se selecciona por medio de un flag que los identifica |
|
433 |
*/ |
|
434 |
public void assignBand(int nBand, int flag) { |
|
435 |
Boolean t = new Boolean(true); |
|
436 |
try { |
|
437 |
if ((flag & RasterDataStore.ALPHA_BAND) == RasterDataStore.ALPHA_BAND) |
|
438 |
((DefaultTableModel) getARGBTable().getModel()).setValueAt(t, nBand, 0); |
|
439 |
|
|
440 |
if ((flag & RasterDataStore.RED_BAND) == RasterDataStore.RED_BAND) |
|
441 |
((DefaultTableModel) getARGBTable().getModel()).setValueAt(t, nBand, 1); |
|
442 |
|
|
443 |
if ((flag & RasterDataStore.GREEN_BAND) == RasterDataStore.GREEN_BAND) |
|
444 |
((DefaultTableModel) getARGBTable().getModel()).setValueAt(t, nBand, 2); |
|
445 |
|
|
446 |
if ((flag & RasterDataStore.BLUE_BAND) == RasterDataStore.BLUE_BAND) |
|
447 |
((DefaultTableModel) getARGBTable().getModel()).setValueAt(t, nBand, 3); |
|
448 |
} catch (ArrayIndexOutOfBoundsException e) { |
|
449 |
|
|
450 |
} |
|
451 |
} |
|
452 |
|
|
453 |
/** |
|
454 |
* Obtiene la correspondencia entre el R, G o B y la banda asignada |
|
455 |
* |
|
456 |
* @param flag R, G o B se selecciona por medio de un flag que los identifica |
|
457 |
* @return Banda de la imagen asignada al flag pasado por par?metro |
|
458 |
*/ |
|
459 |
public int getColorInterpretationByColorBandBand(int flag) { |
|
460 |
DefaultTableModel model = ((DefaultTableModel) getARGBTable().getModel()); |
|
461 |
if ((flag & RasterDataStore.ALPHA_BAND) == RasterDataStore.ALPHA_BAND) { |
|
462 |
for (int nBand = 0; nBand < getARGBTable().getModel().getRowCount(); nBand++) |
|
463 |
if (((Boolean) model.getValueAt(nBand, 0)).booleanValue()) |
|
464 |
return nBand; |
|
465 |
} |
|
466 |
|
|
467 |
if ((flag & RasterDataStore.RED_BAND) == RasterDataStore.RED_BAND) { |
|
468 |
for (int nBand = 0; nBand < getARGBTable().getModel().getRowCount(); nBand++) |
|
469 |
if (((Boolean) model.getValueAt(nBand, 1)).booleanValue()) |
|
470 |
return nBand; |
|
471 |
} |
|
472 |
|
|
473 |
if ((flag & RasterDataStore.GREEN_BAND) == RasterDataStore.GREEN_BAND) { |
|
474 |
for (int nBand = 0; nBand < getARGBTable().getModel().getRowCount(); nBand++) |
|
475 |
if (((Boolean) model.getValueAt(nBand, 2)).booleanValue()) |
|
476 |
return nBand; |
|
477 |
} |
|
478 |
|
|
479 |
if ((flag & RasterDataStore.BLUE_BAND) == RasterDataStore.BLUE_BAND) { |
|
480 |
for (int nBand = 0; nBand < getARGBTable().getModel().getRowCount(); nBand++) |
|
481 |
if (((Boolean) model.getValueAt(nBand, 3)).booleanValue()) |
|
482 |
return nBand; |
|
483 |
} |
|
484 |
|
|
485 |
return -1; |
|
486 |
} |
|
487 |
|
|
488 |
/** |
|
489 |
* Obtiene la interpretaci?n de color por n?mero de banda |
|
490 |
* @param nBand N?mero de banda |
|
491 |
* @return Interpretaci?n de color. Constante definida en DatasetColorInterpretation |
|
492 |
*/ |
|
493 |
public String getColorInterpretationByBand(int nBand) { |
|
494 |
DefaultTableModel model = ((DefaultTableModel) getARGBTable().getModel()); |
|
495 |
for (int col = 0; col < 4; col++) { |
|
496 |
if(((Boolean) model.getValueAt(nBand, col)).booleanValue()) { |
|
497 |
switch (col) { |
|
498 |
case 0: return ColorInterpretation.ALPHA_BAND; |
|
499 |
case 1: return ColorInterpretation.RED_BAND; |
|
500 |
case 2: return ColorInterpretation.GREEN_BAND; |
|
501 |
case 3: return ColorInterpretation.BLUE_BAND; |
|
502 |
} |
|
503 |
} |
|
504 |
} |
|
505 |
return ColorInterpretation.UNDEF_BAND; |
|
506 |
} |
|
507 |
|
|
508 |
/** |
|
509 |
* @return the color interpretation |
|
510 |
*/ |
|
511 |
public ColorInterpretation getSelectedColorInterpretation() { |
|
512 |
try { |
|
513 |
String[] colorInter = new String[getARGBTable().getRowCount()]; |
|
514 |
for (int iBand = 0; iBand < getARGBTable().getRowCount(); iBand++) { |
|
515 |
if(isSelected(iBand, 1) && isSelected(iBand, 2) && isSelected(iBand, 3)) { |
|
516 |
colorInter[iBand] = ColorInterpretation.GRAY_BAND; |
|
517 |
} else if(isSelected(iBand, 1) && isSelected(iBand, 2)) { |
|
518 |
colorInter[iBand] = ColorInterpretation.RED_GREEN_BAND; |
|
519 |
} else if(isSelected(iBand, 1) && isSelected(iBand, 3)) { |
|
520 |
colorInter[iBand] = ColorInterpretation.RED_BLUE_BAND; |
|
521 |
} else if(isSelected(iBand, 2) && isSelected(iBand, 3)) { |
|
522 |
colorInter[iBand] = ColorInterpretation.GREEN_BLUE_BAND; |
|
523 |
} else if(isSelected(iBand, 1)) { |
|
524 |
colorInter[iBand] = ColorInterpretation.RED_BAND; |
|
525 |
} else if(isSelected(iBand, 2)) { |
|
526 |
colorInter[iBand] = ColorInterpretation.GREEN_BAND; |
|
527 |
} else if(isSelected(iBand, 3)) { |
|
528 |
colorInter[iBand] = ColorInterpretation.BLUE_BAND; |
|
529 |
} else if(isSelected(iBand, 0)) { |
|
530 |
colorInter[iBand] = ColorInterpretation.ALPHA_BAND; |
|
531 |
} else |
|
532 |
colorInter[iBand] = ColorInterpretation.UNDEF_BAND; |
|
533 |
} |
|
534 |
return RasterLocator.getManager().getDataStructFactory().createColorInterpretation(colorInter); |
|
535 |
} catch (NotInitializeException e) { |
|
536 |
RasterSwingLibrary.messageBoxError(Messages.getText("table_not_initialize"), this, e); |
|
537 |
} |
|
538 |
return null; |
|
539 |
} |
|
540 |
|
|
541 |
private boolean isSelected(int iBand, int col) { |
|
542 |
DefaultTableModel model = ((DefaultTableModel) getARGBTable().getModel()); |
|
543 |
return ((Boolean) model.getValueAt(iBand, col)).booleanValue(); |
|
544 |
} |
|
545 |
|
|
546 |
public void tableChanged(TableModelEvent e) { |
|
547 |
getARGBTable().revalidate(); |
|
548 |
revalidate(); |
|
549 |
} |
|
550 |
|
|
551 |
/** |
|
552 |
* @return RasterDataStore |
|
553 |
*/ |
|
554 |
public RasterDataStore getResult() { |
|
555 |
return panelListener.getResult(); |
|
556 |
} |
|
557 |
|
|
558 |
/** |
|
559 |
* Activa o desactiva la funcionalidad |
|
560 |
*/ |
|
561 |
private void actionEnabled() { |
|
562 |
boolean enabled = true; |
|
563 |
|
|
564 |
IRasterLayerActions actions = null; |
|
565 |
|
|
566 |
if(fLayer != null && fLayer instanceof IRasterLayerActions) |
|
567 |
actions = (IRasterLayerActions)fLayer; |
|
568 |
|
|
569 |
if (!actions.isActionEnabled(IRasterLayerActions.BANDS_FILE_LIST)) |
|
570 |
enabled = false; |
|
571 |
getFileList().setEnabled(enabled); |
|
572 |
|
|
573 |
enabled = true; |
|
574 |
if (!actions.isActionEnabled(IRasterLayerActions.BANDS_RGB)) |
|
575 |
enabled = false; |
|
576 |
getARGBTable().setEnabled(enabled); |
|
577 |
|
|
578 |
// TODO: Mirar el setVisible... |
|
579 |
if (!actions.isActionEnabled(IRasterLayerActions.BANDS_FILE_LIST) && |
|
580 |
!actions.isActionEnabled(IRasterLayerActions.BANDS_RGB)) |
|
581 |
setVisible(false); |
|
582 |
else |
|
583 |
setVisible(true); |
|
584 |
|
|
585 |
if (!actions.isActionEnabled(IRasterLayerActions.SAVE_COLORINTERP)) |
|
586 |
getSaveButton().setVisible(false); |
|
587 |
} |
|
588 |
|
|
589 |
/** |
|
590 |
* Lee desde el renderizador las bandas que se han dibujado y en que posici?n se ha hecho. |
|
591 |
*/ |
|
592 |
public void readDrawedBands() { |
|
593 |
if (fLayer.getRender() != null) { |
|
594 |
int[] renderBands = fLayer.getRender().getRenderColorInterpretation().buildRenderBands(); |
|
595 |
Transparency transp = fLayer.getRender().getRenderingTransparency(); |
|
596 |
if(transp != null && transp.getAlphaBandNumber() != -1) |
|
597 |
this.assignBand(transp.getAlphaBandNumber(), RasterDataStore.ALPHA_BAND); |
|
598 |
for (int i = 0; i < renderBands.length; i++) { |
|
599 |
if (renderBands[i] >= 0) { |
|
600 |
switch (i) { |
|
601 |
case 0: |
|
602 |
this.assignBand(renderBands[i], RasterDataStore.RED_BAND); |
|
603 |
break; |
|
604 |
case 1: |
|
605 |
this.assignBand(renderBands[i], RasterDataStore.GREEN_BAND); |
|
606 |
break; |
|
607 |
case 2: |
|
608 |
this.assignBand(renderBands[i], RasterDataStore.BLUE_BAND); |
|
609 |
break; |
|
610 |
} |
|
611 |
} |
|
612 |
} |
|
613 |
} |
|
614 |
} |
|
615 |
|
|
616 |
public void accept() { |
|
617 |
if (!getPanelGroup().isPanelInGUI(this)) |
|
618 |
return; |
|
619 |
|
|
620 |
onlyApply(); |
|
621 |
} |
|
622 |
|
|
623 |
/** |
|
624 |
* Aplica y guarda los cambios del panel |
|
625 |
*/ |
|
626 |
public void apply() { |
|
627 |
if (!getPanelGroup().isPanelInGUI(this)) |
|
628 |
return; |
|
629 |
|
|
630 |
onlyApply(); |
|
631 |
saveStatus(); |
|
632 |
} |
|
633 |
|
|
634 |
/** |
|
635 |
* Aplicar los cambios sin guardar su estado |
|
636 |
*/ |
|
637 |
public void onlyApply() { |
|
638 |
if (RasterPropertiesTocMenuEntry.enableEvents) |
|
639 |
panelListener.apply(); |
|
640 |
} |
|
641 |
|
|
642 |
/** |
|
643 |
* Guarda el estado actual del panel |
|
644 |
*/ |
|
645 |
@SuppressWarnings("unchecked") |
|
646 |
private void saveStatus() { |
|
647 |
List<String> aux = new ArrayList<String>(); |
|
648 |
String[] valuesCI = fLayer.getRender().getRenderColorInterpretation().getValues(); |
|
649 |
for (int i = 0; i < valuesCI.length; i++) { |
|
650 |
aux.add(valuesCI[i]); |
|
651 |
} |
|
652 |
getPanelGroup().getProperties().put("renderBands", aux); |
|
653 |
} |
|
654 |
|
|
655 |
|
|
656 |
/** |
|
657 |
* Deja la capa en el ?ltimo estado guardado y la refresca |
|
658 |
*/ |
|
659 |
@SuppressWarnings("unchecked") |
|
660 |
public void restoreStatus() { |
|
661 |
if (fLayer != null) |
|
662 |
return; |
|
663 |
|
|
664 |
List<String> aux = (List<String>) getPanelGroup().getProperties().get("renderBands"); |
|
665 |
|
|
666 |
if(fLayer.getRender() != null) { |
|
667 |
ColorInterpretation ci = RasterLocator.getManager().getDataStructFactory().createColorInterpretation((String[])aux.toArray()); |
|
668 |
fLayer.getRender().setRenderColorInterpretation(ci); |
|
669 |
} |
|
670 |
|
|
671 |
fLayer.getMapContext().invalidate(); |
|
672 |
} |
|
673 |
|
|
674 |
public void cancel() { |
|
675 |
if (!getPanelGroup().isPanelInGUI(this)) |
|
676 |
return; |
|
677 |
|
|
678 |
restoreStatus(); |
|
679 |
} |
|
680 |
|
|
681 |
/** |
|
682 |
* Activa y desactiva el control |
|
683 |
* @param enabled true para activar y false para desactivar |
|
684 |
*/ |
|
685 |
public void setEnabled(boolean enabled) { |
|
686 |
if (panelListener != null) |
|
687 |
panelListener.setEnabledPanelAction(enabled); |
|
688 |
getARGBTable().setEnabled(enabled); |
|
689 |
getFileList().setEnabled(enabled); |
|
690 |
} |
|
691 |
|
|
692 |
/** |
|
693 |
* Sets the current layer when the panel is opened from |
|
694 |
* raster properties |
|
695 |
*/ |
|
696 |
public void setReference(Object ref) { |
|
697 |
super.setReference(ref); |
|
698 |
|
|
699 |
if (!(ref instanceof FLyrRaster)) |
|
700 |
return; |
|
701 |
|
|
702 |
fLayer = (FLyrRaster) ref; |
|
703 |
|
|
704 |
actionEnabled(); |
|
705 |
|
|
706 |
clear(); |
|
707 |
getFileList().clear(); |
|
708 |
|
|
709 |
//Si tiene tabla de color inicializamos solamente |
|
710 |
|
|
711 |
if (fLayer.existColorTable()) { |
|
712 |
((BandSelectorPropertiesListener)panelListener).init(fLayer); |
|
713 |
return; |
|
714 |
} |
|
715 |
|
|
716 |
//Si no tiene tabla de color se a?aden los ficheros e inicializamos |
|
717 |
try { |
|
718 |
addFiles(fLayer.getDataStore()); |
|
719 |
} catch (NotInitializeException e) { |
|
720 |
RasterSwingLibrary.messageBoxError(Messages.getText("table_not_initialize"), this); |
|
721 |
} |
|
722 |
|
|
723 |
((BandSelectorPropertiesListener)panelListener).init(fLayer); |
|
724 |
} |
|
725 |
|
|
726 |
/** |
|
727 |
* @param e |
|
728 |
*/ |
|
729 |
public void componentHidden(ComponentEvent e) {} |
|
730 |
/** |
|
731 |
* @param e |
|
732 |
*/ |
|
733 |
public void componentShown(ComponentEvent e) {} |
|
734 |
/** |
|
735 |
* @param e |
|
736 |
*/ |
|
737 |
public void componentMoved(ComponentEvent e) {} |
|
738 |
|
|
739 |
|
|
740 |
public void selected() { |
|
741 |
setReference(fLayer); |
|
742 |
} |
|
743 |
} |
|
0 | 744 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.80/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/BandSelectorPropertiesListener.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.multifile.app.panel; |
|
23 |
|
|
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.io.File; |
|
27 |
import java.net.URI; |
|
28 |
import java.util.ArrayList; |
|
29 |
import java.util.List; |
|
30 |
|
|
31 |
import org.apache.commons.io.FilenameUtils; |
|
32 |
|
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
35 |
import org.gvsig.fmap.dal.DALLocator; |
|
36 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
37 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
|
38 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
|
39 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
40 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
41 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
42 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
|
43 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
|
44 |
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider; |
|
45 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.FilesystemExplorerWizardPanel; |
|
46 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
47 |
import org.gvsig.fmap.dal.spi.DataStoreProvider; |
|
48 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
49 |
import org.gvsig.gui.beans.swing.JFileChooser; |
|
50 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
51 |
import org.gvsig.i18n.Messages; |
|
52 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
53 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
54 |
import org.gvsig.raster.mainplugin.RasterMainPluginUtils; |
|
55 |
import org.gvsig.raster.mainplugin.config.Configuration; |
|
56 |
import org.gvsig.raster.multifile.io.MultiFileDataParameters; |
|
57 |
import org.gvsig.raster.multifile.io.MultiFileProvider; |
|
58 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
59 |
import org.gvsig.raster.swing.basepanel.ButtonsPanelEvent; |
|
60 |
|
|
61 |
/** |
|
62 |
* Clase que maneja los eventos del panel BandSetupPanel. Gestiona el a?adir o |
|
63 |
* eliminar ficheros de la lista y contiene las acciones a realizar cuando en |
|
64 |
* panel registrable se pulsa aceptar, aplicar o cancelar. |
|
65 |
* |
|
66 |
* @author Nacho Brodin (brodin_ign@gva.es) |
|
67 |
*/ |
|
68 |
public class BandSelectorPropertiesListener extends AbstractBandSelectorListener { |
|
69 |
private JFileChooser fileChooser = null; |
|
70 |
private FLyrRaster fLayer = null; |
|
71 |
private List<File> fileList = null; |
|
72 |
|
|
73 |
/** |
|
74 |
* Constructor |
|
75 |
* @param bs Panel del selector de bandas |
|
76 |
*/ |
|
77 |
public BandSelectorPropertiesListener(BandSelectorPanel bs) { |
|
78 |
super(bs); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* Constructor |
|
83 |
* @param lyr Capa raster |
|
84 |
*/ |
|
85 |
public void init(FLyrRaster lyr) { |
|
86 |
fLayer = lyr; |
|
87 |
} |
|
88 |
|
|
89 |
public RasterDataStore getResult() { |
|
90 |
return fLayer.getDataStore(); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* Listener para la gesti?n de los botones de a?adir, eliminar fichero y |
|
95 |
* el combo de selecci?n de bandas. |
|
96 |
*/ |
|
97 |
public void actionPerformed(ActionEvent e) { |
|
98 |
super.actionPerformed(e); |
|
99 |
|
|
100 |
if (e.getSource().equals(bandSetupPanel.getNumBandSelectorCombo())) { |
|
101 |
String vBands = (String) bandSetupPanel.getNumBandSelectorCombo().getSelectedItem(); |
|
102 |
if (vBands != null) { |
|
103 |
if (vBands.compareTo("3") == 0) |
|
104 |
bandSetupPanel.resetMode(3); |
|
105 |
|
|
106 |
if (vBands.compareTo("2") == 0) |
|
107 |
bandSetupPanel.resetMode(2); |
|
108 |
|
|
109 |
if (vBands.compareTo("1") == 0) |
|
110 |
bandSetupPanel.resetMode(1); |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
if (e.getSource().equals(bandSetupPanel.getSaveButton())) { |
|
115 |
int numBandToRed = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.RED_BAND); |
|
116 |
int numBandToGreen = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.GREEN_BAND); |
|
117 |
int numBandToBlue = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.BLUE_BAND); |
|
118 |
int numBandToAlpha = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.ALPHA_BAND); |
|
119 |
|
|
120 |
if (!isCorrectAssignedBand(numBandToRed, numBandToGreen, numBandToBlue, numBandToAlpha)) { |
|
121 |
RasterSwingLibrary.messageBoxError(Messages.getText("combinacion_no_asignable"), bandSetupPanel); |
|
122 |
return; |
|
123 |
} |
|
124 |
|
|
125 |
RasterSwingLibrary.messageBoxYesOrNot(Messages.getText("color_interpretation_continue"), this); |
|
126 |
RasterDataStore dataSource = fLayer.getDataStore(); |
|
127 |
if(dataSource == null) { |
|
128 |
RasterSwingLibrary.messageBoxError(Messages.getText("error_carga_capa"), bandSetupPanel); |
|
129 |
return; |
|
130 |
} |
|
131 |
|
|
132 |
//ColorInterpretation ci = dataSource.getColorInterpretation(); |
|
133 |
try { |
|
134 |
String[] bands = new String[bandSetupPanel.getARGBTable().getRowCount()]; |
|
135 |
ColorInterpretation ci = RasterLocator.getManager().getDataStructFactory().createColorInterpretation(bands); |
|
136 |
|
|
137 |
// Combinaci?n GRAY |
|
138 |
if ((numBandToRed == numBandToGreen) && (numBandToRed == numBandToBlue) && (numBandToRed >= 0)) { |
|
139 |
for (int iBand = 0; iBand < bandSetupPanel.getARGBTable().getRowCount(); iBand++) { |
|
140 |
ci.setColorInterpValue(iBand, ColorInterpretation.UNDEF_BAND); |
|
141 |
} |
|
142 |
ci.setColorInterpValue(0, ColorInterpretation.GRAY_BAND); |
|
143 |
ci.setColorInterpValue(numBandToAlpha, ColorInterpretation.ALPHA_BAND); |
|
144 |
} else { |
|
145 |
// Combinaci?n RGB |
|
146 |
for (int iBand = 0; iBand < bandSetupPanel.getARGBTable().getRowCount(); iBand++) |
|
147 |
ci.setColorInterpValue(iBand, bandSetupPanel.getColorInterpretationByBand(iBand)); |
|
148 |
} |
|
149 |
String fileName = fLayer.getDataStore().getName(); |
|
150 |
dataSource.setColorInterpretation(ci); |
|
151 |
RasterLocator.getManager().getProviderServices().saveObjectToRmfFile(fileName, ci); |
|
152 |
} catch (RmfSerializerException exc) { |
|
153 |
RasterSwingLibrary.messageBoxError(Messages.getText("error_salvando_rmf"), bandSetupPanel, exc); |
|
154 |
} catch (NotInitializeException exc) { |
|
155 |
RasterSwingLibrary.messageBoxError(Messages.getText("table_not_initialize"), bandSetupPanel, exc); |
|
156 |
} |
|
157 |
} |
|
158 |
|
|
159 |
boolean autoRefreshView = Configuration.getValue("general_auto_preview", Boolean.TRUE).booleanValue(); |
|
160 |
|
|
161 |
if (!autoRefreshView) |
|
162 |
return; |
|
163 |
|
|
164 |
bandSetupPanel.onlyApply(); |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* A?ade una banda al raster |
|
169 |
*/ |
|
170 |
public void addFileBand() { |
|
171 |
fileChooser = createJFileChooser(); |
|
172 |
int result = fileChooser.showOpenDialog(bandSetupPanel); |
|
173 |
|
|
174 |
if (result == JFileChooser.APPROVE_OPTION) { |
|
175 |
RasterDataStore dataStore = fLayer.getDataStore(); |
|
176 |
File[] files = fileChooser.getSelectedFiles(); |
|
177 |
|
|
178 |
JFileChooser.setLastPath(FilesystemExplorerWizardPanel.OPEN_LAYER_FILE_CHOOSER_ID, files[0]); |
|
179 |
|
|
180 |
fileList = new ArrayList<File>(); |
|
181 |
|
|
182 |
for (int i = 0; i < files.length; i++) { |
|
183 |
//Checks that the file does not exist |
|
184 |
URI[] uris = dataStore.getURIByProvider(); |
|
185 |
boolean exists = false; |
|
186 |
for (int j = 0; j < uris.length; j++) { |
|
187 |
if (new File(uris[j]).getAbsolutePath().endsWith(files[i].getName())) { |
|
188 |
RasterSwingLibrary.messageBoxError( Messages.getText("fichero_existe") + ": " + files[i].getAbsolutePath(), bandSetupPanel); |
|
189 |
exists = true; |
|
190 |
break; |
|
191 |
} |
|
192 |
} |
|
193 |
if(!exists) |
|
194 |
fileList.add(files[i]); |
|
195 |
} |
|
196 |
|
|
197 |
if(!checkStoresCompatibility(fLayer.getDataStore(), fileList)) |
|
198 |
return; |
|
199 |
|
|
200 |
if(dataStore.isMultiFile()) { |
|
201 |
for (int i = 0; i < fileList.size(); i++) { |
|
202 |
try { |
|
203 |
dataStore.addFile(fileList.get(i)); |
|
204 |
} catch (InvalidSourceException e) { |
|
205 |
RasterSwingLibrary.messageBoxError(Messages.getText("addband_error"), bandSetupPanel, e); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
dataStore.setProvider(dataStore.getProvider()); |
|
210 |
|
|
211 |
//It shows the files and bands in the panel |
|
212 |
try { |
|
213 |
bandSetupPanel.addFiles(dataStore); |
|
214 |
} catch (NotInitializeException e) { |
|
215 |
RasterSwingLibrary.messageBoxError("table_not_initialize", this, e); |
|
216 |
} |
|
217 |
} else { |
|
218 |
//New layer name |
|
219 |
WindowInfo wi = PluginServices.getMDIManager().getActiveWindow().getWindowInfo(); |
|
220 |
LayerNameDialog dialog = new LayerNameDialog(new Point2D.Double(wi.getX(), wi.getY()), 300, 80, this); |
|
221 |
RasterMainPluginUtils.addWindow(dialog); |
|
222 |
} |
|
223 |
} |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* Elimina una banda del raster. Si queda solo un fichero o no se ha |
|
228 |
* seleccionado ninguna banda no hace nada. |
|
229 |
* |
|
230 |
*/ |
|
231 |
public void delFileBand() { |
|
232 |
Object[] objects = bandSetupPanel.getFileList().getJList().getSelectedValues(); |
|
233 |
RasterDataStore dataStore = fLayer.getDataStore(); |
|
234 |
|
|
235 |
for (int i = objects.length - 1; i >= 0; i--) { |
|
236 |
if (bandSetupPanel.getFileList().getNFiles() > 1) { |
|
237 |
String pathName = objects[i].toString(); |
|
238 |
dataStore.removeFile(new File(pathName)); |
|
239 |
|
|
240 |
String file = pathName.substring(pathName.lastIndexOf(File.separator) + 1); |
|
241 |
file = file.substring(file.lastIndexOf("\\") + 1); |
|
242 |
bandSetupPanel.removeFile(file); |
|
243 |
} |
|
244 |
} |
|
245 |
|
|
246 |
setNewBandsPositionInRendering(); |
|
247 |
} |
|
248 |
|
|
249 |
/** |
|
250 |
* Catchs the events from LayerNameDialog to get the name of the new layer |
|
251 |
*/ |
|
252 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
|
253 |
String layerName = (String)e.getSource(); |
|
254 |
|
|
255 |
RasterDataStore dataStore = fLayer.getDataStore(); |
|
256 |
RasterDataParameters paramFirstFile = (RasterDataParameters)dataStore.getParameters();//(RasterDataParameters)((RasterProvider)dataStore.getProvider()).getDataParameters(); |
|
257 |
|
|
258 |
File firstFile = new File(paramFirstFile.getURI()); |
|
259 |
String path = FilenameUtils.getFullPath(firstFile.getAbsolutePath()); |
|
260 |
|
|
261 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
|
262 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
|
263 |
|
|
264 |
try { |
|
265 |
MultiFileProvider provMultifile = createMultiFileProvider(layerName, path); |
|
266 |
MultiFileDataParameters newParamsMultifile = (MultiFileDataParameters)provMultifile.getDataParameters(); |
|
267 |
newParamsMultifile.addProvider(dataStore); |
|
268 |
|
|
269 |
//And now it creates and adds the new ones |
|
270 |
for (int i = 0; i < fileList.size(); i++) { |
|
271 |
ArrayList<RasterDataParameters> storeParametersList = provServ.createParametersList(fileList.get(i)); //.getAbsolutePath()); |
|
272 |
for (int j = 0; j < storeParametersList.size(); j++) { |
|
273 |
DataStoreProvider newFileProv = dataManager.createProvider((DataStoreProviderServices)dataStore, storeParametersList.get(j)); |
|
274 |
newParamsMultifile.addProviderNotTiled(newFileProv); |
|
275 |
} |
|
276 |
} |
|
277 |
|
|
278 |
((DefaultFLyrRaster)fLayer).setName(layerName); |
|
279 |
//Assigns the MultifileProvider to the store |
|
280 |
dataStore.setProvider((CoverageStoreProvider)provMultifile); |
|
281 |
|
|
282 |
//It shows the files and bands in the panel |
|
283 |
try { |
|
284 |
bandSetupPanel.addFiles(dataStore); |
|
285 |
} catch (NotInitializeException ex) { |
|
286 |
RasterSwingLibrary.messageBoxError(Messages.getText("table_not_initialize"), this, ex); |
|
287 |
} |
|
288 |
|
|
289 |
ArrayList<File> uriList = new ArrayList<File>(); |
|
290 |
uriList.add(firstFile); |
|
291 |
for (int i = 0; i < fileList.size(); i++) { |
|
292 |
uriList.add(fileList.get(i)); |
|
293 |
} |
|
294 |
saveMultiFileLayer(layerName, path, uriList); |
|
295 |
|
|
296 |
} catch (Exception exc) { |
|
297 |
RasterSwingLibrary.messageBoxError(Messages.getText("addband_error"), bandSetupPanel, exc); |
|
298 |
} |
|
299 |
} |
|
300 |
|
|
301 |
/** |
|
302 |
* Acciones a ejecutar cuando se aplica |
|
303 |
*/ |
|
304 |
public void apply() { |
|
305 |
if (enabled) |
|
306 |
setNewBandsPositionInRendering(); |
|
307 |
} |
|
308 |
|
|
309 |
public void setNewBandsPositionInRendering() { |
|
310 |
if (fLayer != null && fLayer.getRender() != null) { |
|
311 |
fLayer.getRender().setRenderColorInterpretation(bandSetupPanel.getSelectedColorInterpretation()); |
|
312 |
|
|
313 |
int alphaBand = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.ALPHA_BAND); |
|
314 |
Transparency gt = fLayer.getRender().getRenderingTransparency(); |
|
315 |
if(gt != null) |
|
316 |
gt.setTransparencyBand(alphaBand); |
|
317 |
fLayer.getMapContext().invalidate(); |
|
318 |
} |
|
319 |
} |
|
320 |
|
|
321 |
} |
|
0 | 322 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.80/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/MainWindow.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2011-2012 Prodevelop S.L |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
*/ |
|
21 |
package org.gvsig.raster.multifile.app.panel; |
|
22 |
|
|
23 |
import java.awt.BorderLayout; |
|
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
|
|
27 |
import javax.swing.JComponent; |
|
28 |
|
|
29 |
import org.gvsig.andami.PluginServices; |
|
30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
31 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
32 |
import org.gvsig.i18n.Messages; |
|
33 |
import org.gvsig.raster.swing.basepanel.AbstractButtonsPanel; |
|
34 |
import org.gvsig.raster.swing.basepanel.IButtonsPanel; |
|
35 |
|
|
36 |
|
|
37 |
/** |
|
38 |
* Basic frame for a gvSIG <code>IWindow</code> object. This frame adds buttons |
|
39 |
* of Cancel, Accept and others. |
|
40 |
* |
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
42 |
*/ |
|
43 |
public class MainWindow extends AbstractButtonsPanel implements IWindow, ActionListener { |
|
44 |
|
|
45 |
private static final long serialVersionUID = -4401123724140025094L; |
|
46 |
private ActionListener listener = null; |
|
47 |
private WindowInfo info = null; |
|
48 |
|
|
49 |
private Object profile = WindowInfo.EDITOR_PROFILE; |
|
50 |
|
|
51 |
/** |
|
52 |
* @param panel |
|
53 |
* @param title |
|
54 |
* @param w |
|
55 |
* @param h |
|
56 |
* @param actionListener |
|
57 |
*/ |
|
58 |
public MainWindow(JComponent panel, String title, int w, int h, ActionListener actionListener) { |
|
59 |
this.listener = actionListener; |
|
60 |
|
|
61 |
setLayout(new BorderLayout()); |
|
62 |
add(panel, BorderLayout.CENTER); |
|
63 |
|
|
64 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_APPLY).setVisible(false); |
|
65 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_ACCEPT).addActionListener(this); |
|
66 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_CANCEL).addActionListener(this); |
|
67 |
|
|
68 |
info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE); |
|
69 |
info.setTitle(title); |
|
70 |
info.setWidth(w); |
|
71 |
info.setHeight(h); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* @param panel |
|
76 |
* @param title |
|
77 |
* @param w |
|
78 |
* @param h |
|
79 |
* @param actionListener |
|
80 |
* @param mainPanel |
|
81 |
*/ |
|
82 |
public MainWindow(JComponent panel, String title, int w, int h, ActionListener actionListener, boolean mainPanel) { |
|
83 |
this.listener = actionListener; |
|
84 |
|
|
85 |
setLayout(new BorderLayout()); |
|
86 |
add(panel, BorderLayout.CENTER); |
|
87 |
|
|
88 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_APPLY).setVisible(false); |
|
89 |
|
|
90 |
if(mainPanel) { |
|
91 |
getButtonsPanel().addButton(Messages.getText("load_layer"), IButtonsPanel.BUTTON_USR1); |
|
92 |
getButtonsPanel().addButton(Messages.getText("generate_file"), IButtonsPanel.BUTTON_USR2); |
|
93 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_APPLY).setVisible(false); |
|
94 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_ACCEPT).setVisible(false); |
|
95 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_CANCEL).setVisible(false); |
|
96 |
getButtonsPanel().addClose(); |
|
97 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_CLOSE).addActionListener(this); |
|
98 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR1).addActionListener(this); |
|
99 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR2).addActionListener(this); |
|
100 |
} else { |
|
101 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_ACCEPT).addActionListener(this); |
|
102 |
getButtonsPanel().getButton(IButtonsPanel.BUTTON_CANCEL).addActionListener(this); |
|
103 |
} |
|
104 |
|
|
105 |
info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE); |
|
106 |
info.setTitle(title); |
|
107 |
info.setWidth(w); |
|
108 |
info.setHeight(h); |
|
109 |
} |
|
110 |
|
|
111 |
public WindowInfo getWindowInfo() { |
|
112 |
return info; |
|
113 |
} |
|
114 |
|
|
115 |
public Object getWindowProfile() { |
|
116 |
return profile; |
|
117 |
} |
|
118 |
|
|
119 |
public void actionPerformed(ActionEvent e) { |
|
120 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR1)) { |
|
121 |
listener.actionPerformed(new ActionEvent(e.getSource(), IButtonsPanel.BUTTON_USR1, e.getActionCommand())); |
|
122 |
PluginServices.getMDIManager().closeWindow(this); |
|
123 |
} |
|
124 |
|
|
125 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR2)) { |
|
126 |
listener.actionPerformed(new ActionEvent(e.getSource(), IButtonsPanel.BUTTON_USR2, e.getActionCommand())); |
|
127 |
PluginServices.getMDIManager().closeWindow(this); |
|
128 |
} |
|
129 |
|
|
130 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_ACCEPT)) { |
|
131 |
listener.actionPerformed(new ActionEvent(e.getSource(), IButtonsPanel.BUTTON_ACCEPT, e.getActionCommand())); |
|
132 |
PluginServices.getMDIManager().closeWindow(this); |
|
133 |
} |
|
134 |
|
|
135 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_APPLY)) { |
|
136 |
listener.actionPerformed(new ActionEvent(e.getSource(), IButtonsPanel.BUTTON_APPLY, e.getActionCommand())); |
|
137 |
} |
|
138 |
|
|
139 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_CANCEL)) { |
|
140 |
PluginServices.getMDIManager().closeWindow(this); |
|
141 |
} |
|
142 |
|
|
143 |
if(e.getSource() == getButtonsPanel().getButton(IButtonsPanel.BUTTON_CLOSE)) { |
|
144 |
PluginServices.getMDIManager().closeWindow(this); |
|
145 |
} |
|
146 |
} |
|
147 |
} |
|
0 | 148 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.80/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/LayerNameDialog.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 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 |
package org.gvsig.raster.multifile.app.panel; |
|
20 |
|
|
21 |
import java.awt.BorderLayout; |
|
22 |
import java.awt.GridBagConstraints; |
|
23 |
import java.awt.GridBagLayout; |
|
24 |
import java.awt.Insets; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
|
|
27 |
import javax.swing.JOptionPane; |
|
28 |
import javax.swing.JPanel; |
|
29 |
import javax.swing.JTextField; |
|
30 |
|
|
31 |
import org.gvsig.andami.PluginServices; |
|
32 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
33 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
34 |
import org.gvsig.i18n.Messages; |
|
35 |
import org.gvsig.raster.swing.basepanel.AbstractButtonsPanel; |
|
36 |
import org.gvsig.raster.swing.basepanel.ButtonsPanelEvent; |
|
37 |
import org.gvsig.raster.swing.basepanel.ButtonsPanelListener; |
|
38 |
import org.gvsig.raster.swing.basepanel.IButtonsPanel; |
|
39 |
|
|
40 |
/** |
|
41 |
* <code>LayerNameDialog</code>. |
|
42 |
* Window to introduce the name of the new layer |
|
43 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
44 |
*/ |
|
45 |
public class LayerNameDialog extends AbstractButtonsPanel implements IWindow, ButtonsPanelListener { |
|
46 |
private static final long serialVersionUID = 7362459094802955247L; |
|
47 |
private JPanel panel = null; |
|
48 |
private String layerName = null; |
|
49 |
private JTextField name = null; |
|
50 |
private ButtonsPanelListener listener = null; |
|
51 |
private Point2D position = null; |
|
52 |
|
|
53 |
/** |
|
54 |
* Builds a new window. |
|
55 |
* @param position |
|
56 |
* @param width |
|
57 |
* @param height |
|
58 |
* @param listener |
|
59 |
*/ |
|
60 |
public LayerNameDialog(Point2D position, int width, int height, ButtonsPanelListener listener) { |
|
61 |
super(IButtonsPanel.BUTTONS_ACCEPTCANCEL); |
|
62 |
this.position = position; |
|
63 |
layerName = null; |
|
64 |
this.listener = listener; |
|
65 |
this.setSize(width, height); |
|
66 |
this.setLayout(new BorderLayout(5, 5)); |
|
67 |
this.add(getMainPanel(), java.awt.BorderLayout.CENTER); |
|
68 |
this.addButtonPressedListener(this); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Builds a new window. |
|
73 |
* @param width |
|
74 |
* @param height |
|
75 |
* @param listener |
|
76 |
*/ |
|
77 |
public LayerNameDialog(int width, int height, ButtonsPanelListener listener) { |
|
78 |
this(new Point2D.Double(), width, height, listener); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* Gets the main panel |
|
83 |
* @return JPanel |
|
84 |
*/ |
|
85 |
public JPanel getMainPanel() { |
|
86 |
if (panel == null) { |
|
87 |
panel = new JPanel(); |
|
88 |
panel.setLayout(new GridBagLayout()); |
|
89 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
90 |
gbc.insets = new Insets(0, 0, 0, 0); |
|
91 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
92 |
gbc.anchor = GridBagConstraints.CENTER; |
|
93 |
gbc.weightx = 1.0; |
|
94 |
panel.add(getNameField(), gbc); |
|
95 |
} |
|
96 |
return panel; |
|
97 |
} |
|
98 |
|
|
99 |
private JTextField getNameField() { |
|
100 |
if(name == null) { |
|
101 |
name = new JTextField(); |
|
102 |
} |
|
103 |
return name; |
|
104 |
} |
|
105 |
|
|
106 |
public WindowInfo getWindowInfo() { |
|
107 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE); |
|
108 |
m_viewinfo.setTitle(Messages.getText("layer_name")); |
|
109 |
m_viewinfo.setHeight(this.getHeight()); |
|
110 |
m_viewinfo.setWidth(this.getWidth()); |
|
111 |
m_viewinfo.setX((int)position.getX()); |
|
112 |
m_viewinfo.setY((int)position.getY()); |
|
113 |
return m_viewinfo; |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* Cancel actions |
|
118 |
*/ |
|
119 |
private void close() { |
|
120 |
try { |
|
121 |
PluginServices.getMDIManager().closeWindow(this); |
|
122 |
} catch (ArrayIndexOutOfBoundsException e) { |
|
123 |
//Si la ventana no se puede eliminar no hacemos nada |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* Accept actions |
|
129 |
*/ |
|
130 |
private void accept() { |
|
131 |
String txt = getNameField().getText(); |
|
132 |
if(txt == null || txt.compareTo("") == 0) { |
|
133 |
JOptionPane.showMessageDialog(null, Messages.getText("character_not_valid"), "", JOptionPane.ERROR_MESSAGE); |
|
134 |
return; |
|
135 |
} |
|
136 |
|
|
137 |
byte[] byteList = txt.getBytes(); |
|
138 |
for (int i = 0; i < byteList.length; i++) { |
|
139 |
if(byteList[i] < 45 || |
|
140 |
(byteList[i] > 45 && byteList[i] < 48) || |
|
141 |
(byteList[i] > 57 && byteList[i] < 65) || |
|
142 |
(byteList[i] > 90 && byteList[i] < 95) || |
|
143 |
(byteList[i] > 95 && byteList[i] < 97) || |
|
144 |
(byteList[i] > 122 && byteList[i] < 126) || |
|
145 |
(byteList[i] > 126)) { |
|
146 |
JOptionPane.showMessageDialog(null, Messages.getText("character_not_valid"), "", JOptionPane.ERROR_MESSAGE); |
|
147 |
return; |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
layerName = txt; |
|
152 |
close(); |
|
153 |
listener.actionButtonPressed(new ButtonsPanelEvent(layerName, IButtonsPanel.BUTTON_ACCEPT)); |
|
154 |
} |
|
155 |
|
|
156 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
|
157 |
if (e.getButton() == IButtonsPanel.BUTTON_CANCEL) { |
|
158 |
close(); |
|
159 |
} |
|
160 |
|
|
161 |
if (e.getButton() == IButtonsPanel.BUTTON_ACCEPT) { |
|
162 |
accept(); |
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
public Object getWindowProfile() { |
|
167 |
return WindowInfo.PROPERTIES_PROFILE; |
|
168 |
} |
|
169 |
} |
|
0 | 170 |
org.gvsig.raster.multifile/tags/org.gvsig.raster.multifile-2.2.80/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/AbstractBandSelectorListener.java | ||
---|---|---|
1 |
package org.gvsig.raster.multifile.app.panel; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
import java.awt.geom.Rectangle2D; |
|
6 |
import java.io.File; |
Also available in: Unified diff