gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / clip / ui / panel / ClippingSelectionPanel.java @ 4181
History | View | Annotate | Download (4.65 KB)
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.tools.app.basic.tool.clip.ui.panel; |
23 |
|
24 |
import java.awt.BorderLayout; |
25 |
import java.io.File; |
26 |
|
27 |
import javax.swing.JPanel; |
28 |
|
29 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
30 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
31 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
32 |
import org.gvsig.gui.beans.table.TableContainer; |
33 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
34 |
import org.gvsig.i18n.Messages; |
35 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
36 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
37 |
|
38 |
/**
|
39 |
* Panel de seleccion de que bandas. Permite seleccionar que bandas se van a
|
40 |
* guardar y especificar su orden.
|
41 |
*
|
42 |
* @version 25/09/2007
|
43 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
44 |
*/
|
45 |
public class ClippingSelectionPanel extends JPanel { |
46 |
private static final long serialVersionUID = 813234785743904477L; |
47 |
private TableContainer tableContainer = null; |
48 |
|
49 |
/**
|
50 |
* Construye un Panel de seleccion para el recorte
|
51 |
*/
|
52 |
public ClippingSelectionPanel() {
|
53 |
initialize(); |
54 |
} |
55 |
|
56 |
|
57 |
private void initialize() { |
58 |
setLayout(new BorderLayout()); |
59 |
add(getTableContainer(), BorderLayout.CENTER);
|
60 |
} |
61 |
|
62 |
/**
|
63 |
* Obtiene la tabla de selecci?n de bandas
|
64 |
* @return Tabla de selecci?n de bandas
|
65 |
*/
|
66 |
public TableContainer getTableContainer() {
|
67 |
if (tableContainer == null) { |
68 |
String[] columnNames = {Messages.getText("bandas"), Messages.getText("nombre"), ""}; |
69 |
int[] columnWidths = {55, 305, 0}; |
70 |
tableContainer = new TableContainer(columnNames, columnWidths);
|
71 |
tableContainer.setModel("CheckBoxModel");
|
72 |
tableContainer.initialize(); |
73 |
tableContainer.setControlVisible(false);
|
74 |
tableContainer.setMoveRowsButtonsVisible(true);
|
75 |
|
76 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(2).setMinWidth(0); |
77 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(2).setMaxWidth(0); |
78 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(0).setMinWidth(55); |
79 |
tableContainer.getTable().getJTable().getColumnModel().getColumn(0).setMaxWidth(55); |
80 |
|
81 |
} |
82 |
|
83 |
return tableContainer;
|
84 |
} |
85 |
|
86 |
/**
|
87 |
* Establecer la capa para usarla en el recorte
|
88 |
* @param fLayer
|
89 |
*/
|
90 |
public void setLayer(FLyrRaster fLayer) { |
91 |
// Rellenar el arbol de bandas
|
92 |
RasterDataStore dataStore = fLayer.getDataStore(); |
93 |
int cont = 0; |
94 |
|
95 |
RasterDataParameters[] params = dataStore.getDataParametersByProvider();
|
96 |
int[] nBands = dataStore.getBandCountByProvider(); |
97 |
|
98 |
for (int i = 0; i < params.length; i++) { |
99 |
String fName = null; |
100 |
if(params[i] instanceof RasterDataParameters) |
101 |
fName = ((RasterDataParameters)params[i]).getURI().getPath(); |
102 |
if(params[i] == null && params[i] instanceof TileDataParameters && ((TileDataParameters)params[i]).getName() != null) |
103 |
fName = ((TileDataParameters)params[i]).getName(); |
104 |
cont = loadBandsTable(nBands[i], fName, cont); |
105 |
} |
106 |
} |
107 |
|
108 |
/**
|
109 |
* Loads the band table
|
110 |
* @param dataStore
|
111 |
* @param fName
|
112 |
* @param cont
|
113 |
* @return
|
114 |
*/
|
115 |
private int loadBandsTable(int nBands, String fName, int cont) { |
116 |
String bandName = new File(fName).getName(); |
117 |
|
118 |
if (nBands > 1) { |
119 |
for (int b = 0; b < nBands; b++) { |
120 |
Object row[] = { new Boolean(true), new String("B" + (b + 1) + " - " + bandName), new Integer(cont++)}; |
121 |
try {
|
122 |
getTableContainer().addRow(row); |
123 |
} catch (NotInitializeException e) {
|
124 |
RasterSwingLibrary.messageBoxError("error_rowtable", this, e); |
125 |
} |
126 |
} |
127 |
} else {
|
128 |
Object row[] = { new Boolean(true), new String("B - " + bandName), new Integer(cont++)}; |
129 |
try {
|
130 |
getTableContainer().addRow(row); |
131 |
} catch (NotInitializeException e) {
|
132 |
RasterSwingLibrary.messageBoxError("error_rowtable", this, e); |
133 |
} |
134 |
} |
135 |
|
136 |
return cont;
|
137 |
} |
138 |
} |