root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / clipping / panels / ClippingSelectionPanel.java @ 15782
History | View | Annotate | Download (4.01 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 |
package org.gvsig.rastertools.clipping.panels; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.io.File; |
23 |
|
24 |
import javax.swing.JPanel; |
25 |
|
26 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
27 |
import org.gvsig.gui.beans.table.TableContainer; |
28 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
29 |
import org.gvsig.raster.dataset.IRasterDataSource; |
30 |
import org.gvsig.raster.util.RasterToolsUtil; |
31 |
|
32 |
import com.iver.andami.PluginServices; |
33 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
34 |
/**
|
35 |
* Panel de seleccion de que bandas. Permite seleccionar que bandas se van a
|
36 |
* guardar y especificar su orden.
|
37 |
*
|
38 |
* @version 25/09/2007
|
39 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
40 |
*/
|
41 |
public class ClippingSelectionPanel extends JPanel { |
42 |
private static final long serialVersionUID = 813234785743904477L; |
43 |
private TableContainer tableContainer = null; |
44 |
|
45 |
/**
|
46 |
* Construye un Panel de seleccion para el recorte
|
47 |
*/
|
48 |
public ClippingSelectionPanel() {
|
49 |
initialize(); |
50 |
} |
51 |
|
52 |
|
53 |
private void initialize() { |
54 |
setLayout(new BorderLayout()); |
55 |
add(getTableContainer(), BorderLayout.CENTER);
|
56 |
} |
57 |
|
58 |
/**
|
59 |
* Obtiene la tabla de selecci?n de bandas
|
60 |
* @return Tabla de selecci?n de bandas
|
61 |
*/
|
62 |
public TableContainer getTableContainer() {
|
63 |
if (tableContainer == null) { |
64 |
String[] columnNames = {PluginServices.getText(this, "bandas"), PluginServices.getText(this, "nombre"), ""}; |
65 |
int[] columnWidths = {55, 305, 0}; |
66 |
tableContainer = new TableContainer(columnNames, columnWidths);
|
67 |
tableContainer.setModel("CheckBoxModel");
|
68 |
tableContainer.initialize(); |
69 |
tableContainer.setControlVisible(false);
|
70 |
tableContainer.setMoveRowsButtonsVisible(true);
|
71 |
|
72 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(2).setMinWidth(0); |
73 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(2).setMaxWidth(0); |
74 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(0).setMinWidth(55); |
75 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(0).setMaxWidth(55); |
76 |
|
77 |
} |
78 |
|
79 |
return tableContainer;
|
80 |
} |
81 |
|
82 |
/**
|
83 |
* Establecer la capa para usarla en el recorte
|
84 |
* @param fLayer
|
85 |
*/
|
86 |
public void setLayer(FLayer fLayer) { |
87 |
// Rellenar el arbol de bandas
|
88 |
IRasterDataSource mDataset = ((FLyrRasterSE) fLayer).getDataSource(); |
89 |
int cont = 0; |
90 |
for (int i = 0; i < mDataset.getDatasetCount(); i++) { |
91 |
String fName = mDataset.getDataset(i)[0].getFName(); |
92 |
String bandName = new File(fName).getName(); |
93 |
|
94 |
if (mDataset.getDataset(i)[0].getBandCount() > 1) { |
95 |
for (int b = 0; b < mDataset.getDataset(i)[0].getBandCount(); b++) { |
96 |
Object row[] = { new Boolean(true), new String("B" + (b + 1) + " - " + bandName), new Integer(cont++)}; |
97 |
try {
|
98 |
getTableContainer().addRow(row); |
99 |
} catch (NotInitializeException e) {
|
100 |
RasterToolsUtil.messageBoxError("error_rowtable", this, e); |
101 |
} |
102 |
} |
103 |
} else {
|
104 |
Object row[] = { new Boolean(true), new String("B - " + bandName), new Integer(cont++)}; |
105 |
try {
|
106 |
getTableContainer().addRow(row); |
107 |
} catch (NotInitializeException e) {
|
108 |
RasterToolsUtil.messageBoxError("error_rowtable", this, e); |
109 |
} |
110 |
} |
111 |
} |
112 |
} |
113 |
} |