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