Revision 13589 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/BandSetupPanel.java
BandSetupPanel.java | ||
---|---|---|
44 | 44 |
import javax.swing.table.TableColumn; |
45 | 45 |
|
46 | 46 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
47 |
import org.gvsig.fmap.raster.layers.IRasterLayerActions; |
|
47 | 48 |
import org.gvsig.raster.dataset.IRasterDataSource; |
48 | 49 |
import org.gvsig.raster.dataset.RasterDataset; |
49 | 50 |
import org.gvsig.raster.gui.properties.dialog.IRegistrablePanel; |
... | ... | |
65 | 66 |
* @author Nacho Brodin (brodin_ign@gva.es) |
66 | 67 |
*/ |
67 | 68 |
public class BandSetupPanel extends JPanel implements TableModelListener, ComponentListener, IRegistrablePanel { |
68 |
final private static long serialVersionUID = -3370601314380922368L;
|
|
69 |
final private static long serialVersionUID = -3370601314380922368L;
|
|
69 | 70 |
|
70 |
/**
|
|
71 |
* Variables para la asignaci?n de tama?o de los componentes del panel.
|
|
72 |
*/
|
|
73 |
private int wComp = 445, hComp = 239;
|
|
74 |
private int wFileList = wComp, hFileList = (int)Math.round(hComp * 0.46);
|
|
75 |
private int wBand = wFileList, hBand = hComp - hFileList - 20;
|
|
71 |
/**
|
|
72 |
* Variables para la asignaci?n de tama?o de los componentes del panel.
|
|
73 |
*/
|
|
74 |
private int wComp = 445, hComp = 239;
|
|
75 |
private int wFileList = wComp, hFileList = (int)Math.round(hComp * 0.46);
|
|
76 |
private int wBand = wFileList, hBand = hComp - hFileList - 20;
|
|
76 | 77 |
|
77 |
/**
|
|
78 |
* Asigna la banda del rojo
|
|
79 |
*/
|
|
80 |
public static final int RED_BAND = RasterDataset.RED_BAND;
|
|
78 |
/**
|
|
79 |
* Asigna la banda del rojo
|
|
80 |
*/
|
|
81 |
public static final int RED_BAND = RasterDataset.RED_BAND;
|
|
81 | 82 |
|
82 |
/**
|
|
83 |
* Asigna la banda del verde
|
|
84 |
*/
|
|
85 |
public static final int GREEN_BAND = RasterDataset.GREEN_BAND;
|
|
83 |
/**
|
|
84 |
* Asigna la banda del verde
|
|
85 |
*/
|
|
86 |
public static final int GREEN_BAND = RasterDataset.GREEN_BAND;
|
|
86 | 87 |
|
87 |
/**
|
|
88 |
* Asigna banda del azul
|
|
89 |
*/
|
|
90 |
public static final int BLUE_BAND = RasterDataset.BLUE_BAND;
|
|
91 |
private final static String[] columnNames = { "R", "G", "B", "Band" };
|
|
88 |
/**
|
|
89 |
* Asigna banda del azul
|
|
90 |
*/
|
|
91 |
public static final int BLUE_BAND = RasterDataset.BLUE_BAND;
|
|
92 |
private final static String[] columnNames = { "R", "G", "B", "Band" };
|
|
92 | 93 |
|
93 |
FLayer fLayer = null;
|
|
94 |
FLayer fLayer = null;
|
|
94 | 95 |
|
95 |
/** |
|
96 |
* Nombre del panel |
|
97 |
*/ |
|
98 |
private String id = "bands_panel"; |
|
99 |
private BandSetupFileList fileList = null; |
|
100 |
private JTable rgbTable = null; |
|
101 |
private JScrollPane rgbBandAssignPane = null; |
|
102 |
RGBBandAsignTableModel tableModel = null; |
|
103 |
private byte mode = 3; |
|
104 |
// Ultima y penultima columnas activadas del jtable para cuando hay 2 bandas seleccionadas en el combo |
|
105 |
private int[] col = { 0, 1 }; |
|
106 |
private BandSetupListener panelListener = null; |
|
107 |
private IRasterProperties prop = null; |
|
108 |
private IRasterDataset dataset = null; |
|
109 |
private boolean visible = true; |
|
110 |
|
|
111 |
/** |
|
112 |
* This method initializes |
|
113 |
*/ |
|
114 |
public BandSetupPanel() { |
|
115 |
super(); |
|
116 |
id = PluginServices.getText(this, id); |
|
117 |
initialize(); |
|
118 |
panelListener = new BandSetupListener(this); |
|
119 |
} |
|
96 |
/** |
|
97 |
* Nombre del panel |
|
98 |
*/ |
|
99 |
private String id = "bands_panel"; |
|
100 |
private BandSetupFileList fileList = null; |
|
101 |
private JTable rgbTable = null; |
|
102 |
private JScrollPane rgbBandAssignPane = null; |
|
103 |
RGBBandAsignTableModel tableModel = null; |
|
104 |
private byte mode = 3; |
|
105 |
// Ultima y penultima columnas activadas del jtable para cuando hay 2 bandas seleccionadas en el combo |
|
106 |
private int[] col = { 0, 1 }; |
|
107 |
private BandSetupListener panelListener = null; |
|
108 |
private IRasterProperties prop = null; |
|
109 |
private IRasterDataset dataset = null; |
|
110 |
private boolean visible = true; |
|
111 |
|
|
112 |
/** |
|
113 |
* This method initializes |
|
114 |
*/ |
|
115 |
public BandSetupPanel() { |
|
116 |
super(); |
|
117 |
id = PluginServices.getText(this, id); |
|
118 |
initialize(); |
|
119 |
panelListener = new BandSetupListener(this); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* This method initializes this |
|
124 |
* |
|
125 |
* @return void |
|
126 |
*/ |
|
127 |
void initialize() { |
|
128 |
// this.setPreferredSize(new Dimension(wComp, hComp)); |
|
129 |
this.setLayout(null); |
|
130 |
this.setLocation(0, 0); |
|
131 |
this.add(getFileList(), null); |
|
132 |
this.add(getRGBBandAssignPane(), null); |
|
133 |
this.addComponentListener(this); |
|
134 |
this.setComponentSize(wComp, hComp); |
|
135 |
} |
|
120 | 136 |
|
121 |
/** |
|
122 |
* This method initializes this |
|
123 |
* |
|
124 |
* @return void |
|
125 |
*/ |
|
126 |
void initialize() { |
|
127 |
// this.setPreferredSize(new Dimension(wComp, hComp)); |
|
128 |
this.setLayout(null); |
|
129 |
this.setLocation(0, 0); |
|
130 |
this.add(getFileList(), null); |
|
131 |
this.add(getRGBBandAssignPane(), null); |
|
132 |
this.addComponentListener(this); |
|
133 |
this.setComponentSize(wComp, hComp); |
|
134 |
} |
|
137 |
/** |
|
138 |
* A?ade la lista de georasterfiles a la tabla |
|
139 |
* |
|
140 |
* @param files |
|
141 |
*/ |
|
142 |
public void addFiles(IRasterDataSource mDataset) { |
|
143 |
getFileList().clear(); |
|
144 |
clear(); |
|
145 |
for (int i = 0; i < mDataset.getDatasetCount(); i++) { |
|
146 |
String fName = mDataset.getDataset(i)[0].getFName(); |
|
147 |
getFileList().addFName(fName); |
|
135 | 148 |
|
136 |
/** |
|
137 |
* A?ade la lista de georasterfiles a la tabla |
|
138 |
* |
|
139 |
* @param files |
|
140 |
*/ |
|
141 |
public void addFiles(IRasterDataSource mDataset) { |
|
142 |
getFileList().clear(); |
|
143 |
clear(); |
|
144 |
for (int i = 0; i < mDataset.getDatasetCount(); i++) { |
|
145 |
String fName = mDataset.getDataset(i)[0].getFName(); |
|
146 |
getFileList().addFName(fName); |
|
149 |
String bandName = new File(fName).getName(); |
|
150 |
String bandType = ""; |
|
147 | 151 |
|
148 |
String bandName = new File(fName).getName(); |
|
149 |
String bandType = ""; |
|
152 |
switch (mDataset.getDataset(i)[0].getDataType()[0]) { |
|
153 |
case DataBuffer.TYPE_BYTE: |
|
154 |
bandType = "8U"; |
|
155 |
break; |
|
156 |
case DataBuffer.TYPE_INT: |
|
157 |
bandType = "32"; |
|
158 |
break; |
|
159 |
case DataBuffer.TYPE_DOUBLE: |
|
160 |
bandType = "64"; |
|
161 |
break; |
|
162 |
case DataBuffer.TYPE_FLOAT: |
|
163 |
bandType = "32"; |
|
164 |
break; |
|
165 |
case DataBuffer.TYPE_SHORT: |
|
166 |
bandType = "16"; |
|
167 |
break; |
|
168 |
case DataBuffer.TYPE_USHORT: |
|
169 |
bandType = "16U"; |
|
170 |
break; |
|
171 |
case DataBuffer.TYPE_UNDEFINED: |
|
172 |
bandType = "??"; |
|
173 |
break; |
|
174 |
} |
|
150 | 175 |
|
151 |
switch (mDataset.getDataset(i)[0].getDataType()[0]) { |
|
152 |
case DataBuffer.TYPE_BYTE: |
|
153 |
bandType = "8U"; |
|
154 |
break; |
|
155 |
case DataBuffer.TYPE_INT: |
|
156 |
bandType = "32"; |
|
157 |
break; |
|
158 |
case DataBuffer.TYPE_DOUBLE: |
|
159 |
bandType = "64"; |
|
160 |
break; |
|
161 |
case DataBuffer.TYPE_FLOAT: |
|
162 |
bandType = "32"; |
|
163 |
break; |
|
164 |
case DataBuffer.TYPE_SHORT: |
|
165 |
bandType = "16"; |
|
166 |
break; |
|
167 |
case DataBuffer.TYPE_USHORT: |
|
168 |
bandType = "16U"; |
|
169 |
break; |
|
170 |
case DataBuffer.TYPE_UNDEFINED: |
|
171 |
bandType = "??"; |
|
172 |
break; |
|
173 |
} |
|
176 |
for (int b = 0; b < mDataset.getDataset(i)[0].getBandCount(); b++) |
|
177 |
addBand((b + 1) + " [" + bandType + "] " + bandName); |
|
174 | 178 |
|
175 |
for (int b = 0; b < mDataset.getDataset(i)[0].getBandCount(); b++) |
|
176 |
addBand((b + 1) + " [" + bandType + "] " + bandName); |
|
177 |
|
|
178 | 179 |
/* |
179 |
if (mDataset.getDataset(i).getBandCount() > 1) {
|
|
180 |
for (int b = 0; b < mDataset.getDataset(i).getBandCount(); b++)
|
|
181 |
addBand((b + 1) + " [" + bandType + "] " + bandName);
|
|
182 |
} else {
|
|
183 |
addBand("1 [" + bandType + "] " + bandName);
|
|
184 |
}
|
|
180 |
if (mDataset.getDataset(i).getBandCount() > 1) {
|
|
181 |
for (int b = 0; b < mDataset.getDataset(i).getBandCount(); b++)
|
|
182 |
addBand((b + 1) + " [" + bandType + "] " + bandName);
|
|
183 |
} else {
|
|
184 |
addBand("1 [" + bandType + "] " + bandName);
|
|
185 |
}
|
|
185 | 186 |
*/ |
186 |
}
|
|
187 |
readDrawedBands();
|
|
188 |
saveStatus();
|
|
189 |
}
|
|
187 |
}
|
|
188 |
readDrawedBands();
|
|
189 |
saveStatus();
|
|
190 |
}
|
|
190 | 191 |
|
191 |
/**
|
|
192 |
* Elimina un fichero de la lista
|
|
193 |
* @param file Nombre del fichero a eliminar
|
|
194 |
*/
|
|
195 |
public void removeFile(String file) {
|
|
196 |
getFileList().removeFName(file);
|
|
192 |
/**
|
|
193 |
* Elimina un fichero de la lista
|
|
194 |
* @param file Nombre del fichero a eliminar
|
|
195 |
*/
|
|
196 |
public void removeFile(String file) {
|
|
197 |
getFileList().removeFName(file);
|
|
197 | 198 |
|
198 |
for (int i = 0; i < ((DefaultTableModel) getRGBTable().getModel()).getRowCount(); i++) {
|
|
199 |
// Si el fichero borrado estaba seleccionado como banda visible. Pasaremos
|
|
200 |
// esta visibilidad a la banda inmediata superior y si esta acci?n produce
|
|
201 |
// una excepci?n (porque no hay) se pasa al inmediato inferior.
|
|
202 |
if (((String) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(i, 3)).endsWith(file)) {
|
|
203 |
try {
|
|
204 |
if (((Boolean) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(i, 0)).booleanValue()) {
|
|
205 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i - 1, 0);
|
|
206 |
}
|
|
207 |
} catch (ArrayIndexOutOfBoundsException exc) {
|
|
208 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i + 1, 0);
|
|
209 |
}
|
|
199 |
for (int i = 0; i < ((DefaultTableModel) getRGBTable().getModel()).getRowCount(); i++) {
|
|
200 |
// Si el fichero borrado estaba seleccionado como banda visible. Pasaremos
|
|
201 |
// esta visibilidad a la banda inmediata superior y si esta acci?n produce
|
|
202 |
// una excepci?n (porque no hay) se pasa al inmediato inferior.
|
|
203 |
if (((String) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(i, 3)).endsWith(file)) {
|
|
204 |
try {
|
|
205 |
if (((Boolean) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(i, 0)).booleanValue()) {
|
|
206 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i - 1, 0);
|
|
207 |
}
|
|
208 |
} catch (ArrayIndexOutOfBoundsException exc) {
|
|
209 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i + 1, 0);
|
|
210 |
}
|
|
210 | 211 |
|
211 |
try {
|
|
212 |
if (((Boolean) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(i, 1)).booleanValue()) {
|
|
213 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i - 1, 1);
|
|
214 |
}
|
|
215 |
} catch (ArrayIndexOutOfBoundsException exc) {
|
|
216 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i + 1, 1);
|
|
217 |
}
|
|
212 |
try {
|
|
213 |
if (((Boolean) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(i, 1)).booleanValue()) {
|
|
214 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i - 1, 1);
|
|
215 |
}
|
|
216 |
} catch (ArrayIndexOutOfBoundsException exc) {
|
|
217 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i + 1, 1);
|
|
218 |
}
|
|
218 | 219 |
|
219 |
try {
|
|
220 |
if (((Boolean) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(i, 2)).booleanValue()) {
|
|
221 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i - 1, 2);
|
|
222 |
}
|
|
223 |
} catch (ArrayIndexOutOfBoundsException exc) {
|
|
224 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i + 1, 2);
|
|
225 |
}
|
|
220 |
try {
|
|
221 |
if (((Boolean) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(i, 2)).booleanValue()) {
|
|
222 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i - 1, 2);
|
|
223 |
}
|
|
224 |
} catch (ArrayIndexOutOfBoundsException exc) {
|
|
225 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), i + 1, 2);
|
|
226 |
}
|
|
226 | 227 |
|
227 |
((DefaultTableModel) getRGBTable().getModel()).removeRow(i);
|
|
228 |
i--; // Ojo! que hemos eliminado una fila
|
|
229 |
}
|
|
230 |
}
|
|
231 |
panelListener.setNewBandsPositionInRendering();
|
|
232 |
}
|
|
228 |
((DefaultTableModel) getRGBTable().getModel()).removeRow(i);
|
|
229 |
i--; // Ojo! que hemos eliminado una fila
|
|
230 |
}
|
|
231 |
}
|
|
232 |
panelListener.setNewBandsPositionInRendering();
|
|
233 |
}
|
|
233 | 234 |
|
234 |
public void assignMode(byte mode) {
|
|
235 |
this.mode = mode;
|
|
236 |
}
|
|
235 |
public void assignMode(byte mode) {
|
|
236 |
this.mode = mode;
|
|
237 |
}
|
|
237 | 238 |
|
238 |
public byte getMode() {
|
|
239 |
return mode;
|
|
240 |
}
|
|
239 |
public byte getMode() {
|
|
240 |
return mode;
|
|
241 |
}
|
|
241 | 242 |
|
242 |
/**
|
|
243 |
* Cuando cambiamos el combo de seleccion de numero de bandas a visualizar
|
|
244 |
* debemos resetear la tabla de checkbox para que no haya activados m?s de los
|
|
245 |
* permitidos
|
|
246 |
* @param mode
|
|
247 |
*/
|
|
248 |
public void resetMode(int mode) {
|
|
249 |
// Reseteamos los checkbox
|
|
250 |
for (int i = 0; i < (getRGBTable().getColumnCount() - 1); i++)
|
|
251 |
for (int j = 0; j < getRGBTable().getRowCount(); j++)
|
|
252 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(false), j, i);
|
|
243 |
/**
|
|
244 |
* Cuando cambiamos el combo de seleccion de numero de bandas a visualizar
|
|
245 |
* debemos resetear la tabla de checkbox para que no haya activados m?s de los
|
|
246 |
* permitidos
|
|
247 |
* @param mode
|
|
248 |
*/
|
|
249 |
public void resetMode(int mode) {
|
|
250 |
// Reseteamos los checkbox
|
|
251 |
for (int i = 0; i < (getRGBTable().getColumnCount() - 1); i++)
|
|
252 |
for (int j = 0; j < getRGBTable().getRowCount(); j++)
|
|
253 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(false), j, i);
|
|
253 | 254 |
|
254 |
// Asignamos los valores
|
|
255 |
if (this.getNBands() >= 3) {
|
|
256 |
switch (mode) {
|
|
257 |
case 3:
|
|
258 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 2, 2);
|
|
259 |
case 2:
|
|
260 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 1, 1);
|
|
261 |
case 1:
|
|
262 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 0, 0);
|
|
263 |
}
|
|
264 |
} else if (this.getNBands() == 2) {
|
|
265 |
switch (mode) {
|
|
266 |
case 3:
|
|
267 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 1, 2);
|
|
268 |
case 2:
|
|
269 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 1, 1);
|
|
270 |
case 1:
|
|
271 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 0, 0);
|
|
272 |
}
|
|
273 |
} else if (this.getNBands() == 1) {
|
|
274 |
switch (mode) {
|
|
275 |
case 3:
|
|
276 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 0, 2);
|
|
277 |
case 2:
|
|
278 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 0, 1);
|
|
279 |
case 1:
|
|
280 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 0, 0);
|
|
281 |
}
|
|
282 |
}
|
|
255 |
// Asignamos los valores
|
|
256 |
if (this.getNBands() >= 3) {
|
|
257 |
switch (mode) {
|
|
258 |
case 3:
|
|
259 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 2, 2);
|
|
260 |
case 2:
|
|
261 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 1, 1);
|
|
262 |
case 1:
|
|
263 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 0, 0);
|
|
264 |
}
|
|
265 |
} else if (this.getNBands() == 2) {
|
|
266 |
switch (mode) {
|
|
267 |
case 3:
|
|
268 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 1, 2);
|
|
269 |
case 2:
|
|
270 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 1, 1);
|
|
271 |
case 1:
|
|
272 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 0, 0);
|
|
273 |
}
|
|
274 |
} else if (this.getNBands() == 1) {
|
|
275 |
switch (mode) {
|
|
276 |
case 3:
|
|
277 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 0, 2);
|
|
278 |
case 2:
|
|
279 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 0, 1);
|
|
280 |
case 1:
|
|
281 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(true), 0, 0);
|
|
282 |
}
|
|
283 |
}
|
|
283 | 284 |
|
284 |
col[0] = 0;
|
|
285 |
col[1] = 1;
|
|
286 |
}
|
|
285 |
col[0] = 0;
|
|
286 |
col[1] = 1;
|
|
287 |
}
|
|
287 | 288 |
|
288 |
/**
|
|
289 |
* Asigna modo 1, 2, o 3 bandas. El modo 1 solo permite seleccionar en la
|
|
290 |
* tabla un checkbox, el 2 dos checkbox en distintar bandas y el 3 tres
|
|
291 |
* checkbox tambi?n en distintas bandas.
|
|
292 |
* @param mode
|
|
293 |
*/
|
|
294 |
private void setMode(int mode) {
|
|
295 |
// Solo hay un checkbox activado
|
|
296 |
if (mode == 1) {
|
|
297 |
for (int i = 0; i < getRGBTable().getRowCount(); i++)
|
|
298 |
for (int j = 0; j < (getRGBTable().getColumnCount() - 1); j++) {
|
|
299 |
if ((i != getRGBTable().getSelectedRow()) || (j != getRGBTable().getSelectedColumn())) {
|
|
300 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(false), i, j);
|
|
301 |
}
|
|
302 |
}
|
|
289 |
/**
|
|
290 |
* Asigna modo 1, 2, o 3 bandas. El modo 1 solo permite seleccionar en la
|
|
291 |
* tabla un checkbox, el 2 dos checkbox en distintar bandas y el 3 tres
|
|
292 |
* checkbox tambi?n en distintas bandas.
|
|
293 |
* @param mode
|
|
294 |
*/
|
|
295 |
private void setMode(int mode) {
|
|
296 |
// Solo hay un checkbox activado
|
|
297 |
if (mode == 1) {
|
|
298 |
for (int i = 0; i < getRGBTable().getRowCount(); i++)
|
|
299 |
for (int j = 0; j < (getRGBTable().getColumnCount() - 1); j++) {
|
|
300 |
if ((i != getRGBTable().getSelectedRow()) || (j != getRGBTable().getSelectedColumn())) {
|
|
301 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(false), i, j);
|
|
302 |
}
|
|
303 |
}
|
|
303 | 304 |
|
304 |
// Hay dos checkbox activados
|
|
305 |
} else if (mode == 2) {
|
|
306 |
int n = 0;
|
|
305 |
// Hay dos checkbox activados
|
|
306 |
} else if (mode == 2) {
|
|
307 |
int n = 0;
|
|
307 | 308 |
|
308 |
for (int i = 0; i < (getRGBTable().getColumnCount() - 1); i++)
|
|
309 |
for (int j = 0; j < getRGBTable().getRowCount(); j++)
|
|
310 |
if (((Boolean) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(j, i)).booleanValue()) {
|
|
311 |
n++;
|
|
312 |
}
|
|
309 |
for (int i = 0; i < (getRGBTable().getColumnCount() - 1); i++)
|
|
310 |
for (int j = 0; j < getRGBTable().getRowCount(); j++)
|
|
311 |
if (((Boolean) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(j, i)).booleanValue()) {
|
|
312 |
n++;
|
|
313 |
}
|
|
313 | 314 |
|
314 |
// Si se ha seleccionado 3 bandas hay eliminar una de ellas. Siempre ser?
|
|
315 |
// la m?s antigua que se clickeo
|
|
316 |
if (n > 2) {
|
|
317 |
for (int i = 0; i < getRGBTable().getRowCount(); i++)
|
|
318 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(false), i, col[0]);
|
|
319 |
}
|
|
315 |
// Si se ha seleccionado 3 bandas hay eliminar una de ellas. Siempre ser?
|
|
316 |
// la m?s antigua que se clickeo
|
|
317 |
if (n > 2) {
|
|
318 |
for (int i = 0; i < getRGBTable().getRowCount(); i++)
|
|
319 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(new Boolean(false), i, col[0]);
|
|
320 |
}
|
|
320 | 321 |
|
321 |
// Rotamos el punto pinchado m?s antiguo para que se eliminen
|
|
322 |
// alternativamente
|
|
323 |
if ((col[0] == getRGBTable().getSelectedColumn()) || ((col[0] != getRGBTable().getSelectedColumn()) && (col[1] != getRGBTable().getSelectedColumn()))) {
|
|
324 |
col[0] = col[1];
|
|
325 |
col[1] = getRGBTable().getSelectedColumn();
|
|
326 |
}
|
|
322 |
// Rotamos el punto pinchado m?s antiguo para que se eliminen
|
|
323 |
// alternativamente
|
|
324 |
if ((col[0] == getRGBTable().getSelectedColumn()) || ((col[0] != getRGBTable().getSelectedColumn()) && (col[1] != getRGBTable().getSelectedColumn()))) {
|
|
325 |
col[0] = col[1];
|
|
326 |
col[1] = getRGBTable().getSelectedColumn();
|
|
327 |
}
|
|
327 | 328 |
|
328 |
// El modo 3 es el comportamiento original
|
|
329 |
} else if (mode == 3) {
|
|
330 |
return;
|
|
331 |
}
|
|
332 |
}
|
|
329 |
// El modo 3 es el comportamiento original
|
|
330 |
} else if (mode == 3) {
|
|
331 |
return;
|
|
332 |
}
|
|
333 |
}
|
|
333 | 334 |
|
334 |
/** |
|
335 |
* Obtiene el panel que contiene la lista de ficheros por banda. |
|
336 |
* @return Panel FileList |
|
337 |
*/ |
|
338 |
public BandSetupFileList getFileList() { |
|
339 |
if (fileList == null) { |
|
340 |
fileList = new BandSetupFileList(); |
|
341 |
} |
|
335 |
/** |
|
336 |
* Obtiene el panel que contiene la lista de ficheros por banda. |
|
337 |
* @return Panel FileList |
|
338 |
*/ |
|
339 |
public BandSetupFileList getFileList() { |
|
340 |
if (fileList == null) { |
|
341 |
fileList = new BandSetupFileList(); |
|
342 |
} |
|
343 |
return fileList; |
|
344 |
} |
|
342 | 345 |
|
343 |
return fileList; |
|
344 |
} |
|
346 |
/** |
|
347 |
* This method initializes jTable |
|
348 |
* @return javax.swing.JTable |
|
349 |
*/ |
|
350 |
private JScrollPane getRGBBandAssignPane() { |
|
351 |
if (rgbBandAssignPane == null) { |
|
352 |
rgbBandAssignPane = new JScrollPane(getRGBTable()); |
|
345 | 353 |
|
346 |
/** |
|
347 |
* This method initializes jTable |
|
348 |
* @return javax.swing.JTable |
|
349 |
*/ |
|
350 |
private JScrollPane getRGBBandAssignPane() { |
|
351 |
if (rgbBandAssignPane == null) { |
|
352 |
rgbBandAssignPane = new JScrollPane(getRGBTable()); |
|
354 |
TableColumn column = null; |
|
353 | 355 |
|
354 |
TableColumn column = null; |
|
356 |
for (int i = 0; i < 3; i++) { |
|
357 |
column = getRGBTable().getColumnModel().getColumn(i); |
|
358 |
column.setCellRenderer(new RadioColumnRenderer()); |
|
359 |
column.setCellEditor(new RadioColumnEditor()); |
|
360 |
column.setMaxWidth(22); |
|
361 |
column.setMinWidth(22); |
|
362 |
} |
|
363 |
} |
|
355 | 364 |
|
356 |
for (int i = 0; i < 3; i++) { |
|
357 |
column = getRGBTable().getColumnModel().getColumn(i); |
|
358 |
column.setCellRenderer(new RadioColumnRenderer()); |
|
359 |
column.setCellEditor(new RadioColumnEditor()); |
|
360 |
column.setMaxWidth(22); |
|
361 |
column.setMinWidth(22); |
|
362 |
} |
|
363 |
} |
|
365 |
return rgbBandAssignPane; |
|
366 |
} |
|
364 | 367 |
|
365 |
return rgbBandAssignPane; |
|
366 |
} |
|
368 |
/** |
|
369 |
* Obtiene la Tabla |
|
370 |
* @return Tabla de bandas de la imagen |
|
371 |
*/ |
|
372 |
public JTable getRGBTable() { |
|
373 |
if (rgbTable == null) { |
|
374 |
tableModel = new RGBBandAsignTableModel(); |
|
375 |
tableModel.addTableModelListener(this); |
|
376 |
rgbTable = new JTable(tableModel); |
|
377 |
rgbTable.setPreferredScrollableViewportSize(new Dimension(328, 72)); |
|
378 |
} |
|
379 |
return rgbTable; |
|
380 |
} |
|
367 | 381 |
|
368 |
/** |
|
369 |
* Obtiene la Tabla |
|
370 |
* @return Tabla de bandas de la imagen |
|
371 |
*/ |
|
372 |
public JTable getRGBTable() { |
|
373 |
if (rgbTable == null) { |
|
374 |
tableModel = new RGBBandAsignTableModel(); |
|
375 |
tableModel.addTableModelListener(this); |
|
376 |
rgbTable = new JTable(tableModel); |
|
377 |
rgbTable.setPreferredScrollableViewportSize(new Dimension(328, 72)); |
|
378 |
} |
|
379 |
return rgbTable; |
|
380 |
} |
|
382 |
/** |
|
383 |
* Asigna al combo de n?mero de bandas a mostrar el valor correspondiente |
|
384 |
* dependiendo del n?mero de bandas de la imagen. |
|
385 |
*/ |
|
386 |
public void setList() { |
|
387 |
String[] l = null; |
|
381 | 388 |
|
382 |
/** |
|
383 |
* Asigna al combo de n?mero de bandas a mostrar el valor correspondiente |
|
384 |
* dependiendo del n?mero de bandas de la imagen. |
|
385 |
*/ |
|
386 |
public void setList() { |
|
387 |
String[] l = null; |
|
389 |
if (this.getNBands() == 1) { |
|
390 |
l = new String[1]; |
|
391 |
l[0] = "1"; |
|
392 |
} |
|
388 | 393 |
|
389 |
if (this.getNBands() == 1) { |
|
390 |
l = new String[1]; |
|
391 |
l[0] = "1"; |
|
392 |
} |
|
394 |
if (this.getNBands() == 2) { |
|
395 |
l = new String[2]; |
|
396 |
l[0] = "1"; |
|
397 |
l[1] = "2"; |
|
398 |
} |
|
393 | 399 |
|
394 |
if (this.getNBands() == 2) { |
|
395 |
l = new String[2]; |
|
396 |
l[0] = "1"; |
|
397 |
l[1] = "2"; |
|
398 |
} |
|
400 |
if (this.getNBands() == 3) { |
|
401 |
l = new String[3]; |
|
402 |
l[0] = "1"; |
|
403 |
l[1] = "2"; |
|
404 |
l[2] = "3"; |
|
405 |
} |
|
399 | 406 |
|
400 |
if (this.getNBands() == 3) { |
|
401 |
l = new String[3]; |
|
402 |
l[0] = "1"; |
|
403 |
l[1] = "2"; |
|
404 |
l[2] = "3"; |
|
405 |
} |
|
407 |
if (this.getNBands() > 0) { |
|
408 |
getFileList().setList(l); |
|
409 |
} |
|
410 |
} |
|
406 | 411 |
|
407 |
if (this.getNBands() > 0) { |
|
408 |
getFileList().setList(l); |
|
409 |
} |
|
410 |
} |
|
412 |
/** |
|
413 |
* A?ade una banda a la tabla bandas de la imagen asignandole un nombre y |
|
414 |
* valor a los checkbox |
|
415 |
* @param bandName Nombre de la banda |
|
416 |
*/ |
|
417 |
private void addBand(String bandName) { |
|
418 |
Vector v = new Vector(); |
|
419 |
v.add(new Boolean(false)); |
|
420 |
v.add(new Boolean(false)); |
|
421 |
v.add(new Boolean(false)); |
|
422 |
v.add(bandName); |
|
423 |
((DefaultTableModel) getRGBTable().getModel()).addRow(v); |
|
424 |
} |
|
411 | 425 |
|
412 |
/** |
|
413 |
* A?ade una banda a la tabla bandas de la imagen asignandole un nombre y |
|
414 |
* valor a los checkbox |
|
415 |
* @param bandName Nombre de la banda |
|
416 |
*/ |
|
417 |
private void addBand(String bandName) { |
|
418 |
Vector v = new Vector(); |
|
419 |
v.add(new Boolean(false)); |
|
420 |
v.add(new Boolean(false)); |
|
421 |
v.add(new Boolean(false)); |
|
422 |
v.add(bandName); |
|
423 |
((DefaultTableModel) getRGBTable().getModel()).addRow(v); |
|
424 |
} |
|
426 |
/** |
|
427 |
* Elimina todas las entradas de la tabla de bandas. |
|
428 |
*/ |
|
429 |
private void clear() { |
|
430 |
int rows = ((DefaultTableModel) getRGBTable().getModel()).getRowCount(); |
|
431 |
if (rows > 0) { |
|
432 |
for (int i = 0; i < rows; i++) |
|
433 |
((DefaultTableModel) getRGBTable().getModel()).removeRow(0); |
|
434 |
} |
|
435 |
} |
|
425 | 436 |
|
426 |
/** |
|
427 |
* Elimina todas las entradas de la tabla de bandas. |
|
428 |
*/ |
|
429 |
private void clear() { |
|
430 |
int rows = ((DefaultTableModel) getRGBTable().getModel()).getRowCount(); |
|
431 |
if (rows > 0) { |
|
432 |
for (int i = 0; i < rows; i++) |
|
433 |
((DefaultTableModel) getRGBTable().getModel()).removeRow(0); |
|
434 |
} |
|
435 |
} |
|
437 |
/** |
|
438 |
* Obtiene el n?mero de bandas de la lista |
|
439 |
* |
|
440 |
* @return |
|
441 |
*/ |
|
442 |
public int getNBands() { |
|
443 |
return ((DefaultTableModel) getRGBTable().getModel()).getRowCount(); |
|
444 |
} |
|
436 | 445 |
|
437 |
/** |
|
438 |
* Obtiene el n?mero de bandas de la lista |
|
439 |
* |
|
440 |
* @return |
|
441 |
*/ |
|
442 |
public int getNBands() { |
|
443 |
return ((DefaultTableModel) getRGBTable().getModel()).getRowCount(); |
|
444 |
} |
|
446 |
/** |
|
447 |
* Obtiene el nombre de la banda de la posici?n i de la tabla |
|
448 |
* |
|
449 |
* @param i |
|
450 |
* @return |
|
451 |
*/ |
|
452 |
public String getBandName(int i) { |
|
453 |
String s = (String) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(i, 3); |
|
454 |
return s.substring(s.lastIndexOf("[8U]") + 5, s.length()); |
|
455 |
} |
|
445 | 456 |
|
446 |
/** |
|
447 |
* Obtiene el nombre de la banda de la posici?n i de la tabla |
|
448 |
* |
|
449 |
* @param i |
|
450 |
* @return |
|
451 |
*/ |
|
452 |
public String getBandName(int i) { |
|
453 |
String s = (String) ((DefaultTableModel) getRGBTable().getModel()).getValueAt(i, 3); |
|
454 |
return s.substring(s.lastIndexOf("[8U]") + 5, s.length()); |
|
455 |
} |
|
457 |
/** |
|
458 |
* Mantiene la asignaci?n entre R, G o B y la banda de la imagen que le |
|
459 |
* corresponde |
|
460 |
* |
|
461 |
* @param nBand Banda de la imagen que corresponde |
|
462 |
* @param flag R, G o B se selecciona por medio de un flag que los identifica |
|
463 |
*/ |
|
464 |
public void assignBand(int nBand, int flag) { |
|
465 |
Boolean t = new Boolean(true); |
|
466 |
try { |
|
467 |
if ((flag & RED_BAND) == RED_BAND) |
|
468 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(t, nBand, 0); |
|
456 | 469 |
|
457 |
/** |
|
458 |
* Mantiene la asignaci?n entre R, G o B y la banda de la imagen que le |
|
459 |
* corresponde |
|
460 |
* |
|
461 |
* @param nBand Banda de la imagen que corresponde |
|
462 |
* @param flag R, G o B se selecciona por medio de un flag que los identifica |
|
463 |
*/ |
|
464 |
public void assignBand(int nBand, int flag) { |
|
465 |
Boolean t = new Boolean(true); |
|
466 |
try { |
|
467 |
if ((flag & RED_BAND) == RED_BAND) |
|
468 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(t, nBand, 0); |
|
470 |
if ((flag & GREEN_BAND) == GREEN_BAND) |
|
471 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(t, nBand, 1); |
|
469 | 472 |
|
470 |
if ((flag & GREEN_BAND) == GREEN_BAND) |
|
471 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(t, nBand, 1); |
|
473 |
if ((flag & BLUE_BAND) == BLUE_BAND) |
|
474 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(t, nBand, 2); |
|
475 |
} catch (ArrayIndexOutOfBoundsException e) { |
|
472 | 476 |
|
473 |
if ((flag & BLUE_BAND) == BLUE_BAND) |
|
474 |
((DefaultTableModel) getRGBTable().getModel()).setValueAt(t, nBand, 2); |
|
475 |
} catch (ArrayIndexOutOfBoundsException e) { |
|
477 |
} |
|
478 |
} |
|
476 | 479 |
|
477 |
} |
|
478 |
} |
|
480 |
/** |
|
481 |
* Obtiene la correspondencia entre el R, G o B y la banda asignada |
|
482 |
* |
|
483 |
* @param flag R, G o B se selecciona por medio de un flag que los identifica |
|
484 |
* @return Banda de la imagen asignada al flag pasado por par?metro |
|
485 |
*/ |
|
486 |
public int getAssignedBand(int flag) { |
|
487 |
DefaultTableModel model = ((DefaultTableModel) getRGBTable().getModel()); |
|
488 |
if ((flag & RED_BAND) == RED_BAND) { |
|
489 |
for (int nBand = 0; nBand < getRGBTable().getRowCount(); nBand++) |
|
490 |
if (((Boolean) model.getValueAt(nBand, 0)).booleanValue()) |
|
491 |
return nBand; |
|
492 |
} |
|
479 | 493 |
|
480 |
/** |
|
481 |
* Obtiene la correspondencia entre el R, G o B y la banda asignada |
|
482 |
* |
|
483 |
* @param flag R, G o B se selecciona por medio de un flag que los identifica |
|
484 |
* @return Banda de la imagen asignada al flag pasado por par?metro |
|
485 |
*/ |
|
486 |
public int getAssignedBand(int flag) { |
|
487 |
DefaultTableModel model = ((DefaultTableModel) getRGBTable().getModel()); |
|
488 |
if ((flag & RED_BAND) == RED_BAND) { |
|
489 |
for (int nBand = 0; nBand < getRGBTable().getRowCount(); nBand++) |
|
490 |
if (((Boolean) model.getValueAt(nBand, 0)).booleanValue()) |
|
491 |
return nBand; |
|
492 |
} |
|
494 |
if ((flag & GREEN_BAND) == GREEN_BAND) { |
|
495 |
for (int nBand = 0; nBand < getRGBTable().getRowCount(); nBand++) |
|
496 |
if (((Boolean) model.getValueAt(nBand, 1)).booleanValue()) |
|
497 |
return nBand; |
|
498 |
} |
|
493 | 499 |
|
494 |
if ((flag & GREEN_BAND) == GREEN_BAND) {
|
|
495 |
for (int nBand = 0; nBand < getRGBTable().getRowCount(); nBand++)
|
|
496 |
if (((Boolean) model.getValueAt(nBand, 1)).booleanValue())
|
|
497 |
return nBand;
|
|
498 |
}
|
|
500 |
if ((flag & BLUE_BAND) == BLUE_BAND) {
|
|
501 |
for (int nBand = 0; nBand < getRGBTable().getRowCount(); nBand++)
|
|
502 |
if (((Boolean) model.getValueAt(nBand, 2)).booleanValue())
|
|
503 |
return nBand;
|
|
504 |
}
|
|
499 | 505 |
|
500 |
if ((flag & BLUE_BAND) == BLUE_BAND) { |
|
501 |
for (int nBand = 0; nBand < getRGBTable().getRowCount(); nBand++) |
|
502 |
if (((Boolean) model.getValueAt(nBand, 2)).booleanValue()) |
|
503 |
return nBand; |
|
504 |
} |
|
506 |
return -1; |
|
507 |
} |
|
505 | 508 |
|
506 |
return -1; |
|
507 |
} |
|
509 |
/* |
|
510 |
* (non-Javadoc) |
|
511 |
* @see javax.swing.event.TableModelListener#tableChanged(javax.swing.event.TableModelEvent) |
|
512 |
*/ |
|
513 |
public void tableChanged(TableModelEvent e) { |
|
514 |
getRGBTable().revalidate(); |
|
515 |
rgbBandAssignPane.revalidate(); |
|
516 |
revalidate(); |
|
517 |
} |
|
508 | 518 |
|
509 |
/* |
|
510 |
* (non-Javadoc) |
|
511 |
* @see javax.swing.event.TableModelListener#tableChanged(javax.swing.event.TableModelEvent) |
|
512 |
*/ |
|
513 |
public void tableChanged(TableModelEvent e) { |
|
514 |
getRGBTable().revalidate(); |
|
515 |
rgbBandAssignPane.revalidate(); |
|
516 |
revalidate(); |
|
517 |
} |
|
519 |
class RadioColumnEditor extends AbstractCellEditor implements TableCellEditor { |
|
520 |
final private static long serialVersionUID = -3370601314380922368L; |
|
521 |
public JRadioButton theRadioButton; |
|
518 | 522 |
|
519 |
class RadioColumnEditor extends AbstractCellEditor implements TableCellEditor { |
|
520 |
final private static long serialVersionUID = -3370601314380922368L; |
|
521 |
public JRadioButton theRadioButton; |
|
523 |
public RadioColumnEditor() { |
|
524 |
super(); |
|
525 |
theRadioButton = new JRadioButton(); |
|
526 |
theRadioButton.addActionListener(new ActionListener() { |
|
527 |
public void actionPerformed(ActionEvent event) { |
|
528 |
fireEditingStopped(); |
|
529 |
setMode(mode); |
|
530 |
onlyApply(); |
|
531 |
} |
|
532 |
}); |
|
533 |
} |
|
522 | 534 |
|
523 |
public RadioColumnEditor() { |
|
524 |
super(); |
|
525 |
theRadioButton = new JRadioButton(); |
|
526 |
theRadioButton.addActionListener(new ActionListener() { |
|
527 |
public void actionPerformed(ActionEvent event) { |
|
528 |
fireEditingStopped(); |
|
529 |
setMode(mode); |
|
530 |
onlyApply(); |
|
531 |
} |
|
532 |
}); |
|
533 |
} |
|
535 |
public Component getTableCellEditorComponent(JTable table, Object obj, boolean isSelected, int row, int col) { |
|
536 |
theRadioButton.setHorizontalAlignment(SwingUtilities.CENTER); |
|
534 | 537 |
|
535 |
public Component getTableCellEditorComponent(JTable table, Object obj, boolean isSelected, int row, int col) {
|
|
536 |
theRadioButton.setHorizontalAlignment(SwingUtilities.CENTER);
|
|
538 |
Boolean lValueAsBoolean = (Boolean) obj;
|
|
539 |
theRadioButton.setSelected(lValueAsBoolean.booleanValue());
|
|
537 | 540 |
|
538 |
Boolean lValueAsBoolean = (Boolean) obj;
|
|
539 |
theRadioButton.setSelected(lValueAsBoolean.booleanValue());
|
|
541 |
return theRadioButton;
|
|
542 |
}
|
|
540 | 543 |
|
541 |
return theRadioButton; |
|
542 |
} |
|
544 |
public Object getCellEditorValue() { |
|
545 |
return new Boolean(theRadioButton.isSelected()); |
|
546 |
} |
|
547 |
} |
|
543 | 548 |
|
544 |
public Object getCellEditorValue() { |
|
545 |
return new Boolean(theRadioButton.isSelected()); |
|
546 |
} |
|
547 |
} |
|
549 |
class RadioColumnRenderer extends JRadioButton implements TableCellRenderer { |
|
550 |
final private static long serialVersionUID = -3370601314380922368L; |
|
548 | 551 |
|
549 |
class RadioColumnRenderer extends JRadioButton implements TableCellRenderer { |
|
550 |
final private static long serialVersionUID = -3370601314380922368L; |
|
552 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
|
553 |
if (value == null) { |
|
554 |
this.setSelected(false); |
|
555 |
} |
|
551 | 556 |
|
552 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
|
553 |
if (value == null) { |
|
554 |
this.setSelected(false); |
|
555 |
} |
|
557 |
Boolean ValueAsBoolean = (Boolean) value; |
|
558 |
this.setSelected(ValueAsBoolean.booleanValue()); |
|
559 |
this.setHorizontalAlignment(SwingConstants.CENTER); |
|
556 | 560 |
|
557 |
Boolean ValueAsBoolean = (Boolean) value;
|
|
558 |
this.setSelected(ValueAsBoolean.booleanValue());
|
|
559 |
this.setHorizontalAlignment(SwingConstants.CENTER);
|
|
561 |
return this;
|
|
562 |
}
|
|
563 |
}
|
|
560 | 564 |
|
561 |
return this; |
|
562 |
} |
|
563 |
} |
|
565 |
class RGBBandAsignTableModel extends DefaultTableModel { |
|
566 |
final private static long serialVersionUID = -3370601314380922368L; |
|
564 | 567 |
|
565 |
class RGBBandAsignTableModel extends DefaultTableModel { |
|
566 |
final private static long serialVersionUID = -3370601314380922368L; |
|
568 |
public RGBBandAsignTableModel() { |
|
569 |
super(new Object[0][4], columnNames); |
|
570 |
} |
|
567 | 571 |
|
568 |
public RGBBandAsignTableModel() { |
|
569 |
super(new Object[0][4], columnNames); |
|
570 |
} |
|
572 |
public Class getColumnClass(int c) { |
|
573 |
if (c < 3) { |
|
574 |
return Boolean.class; |
|
575 |
} |
|
571 | 576 |
|
572 |
public Class getColumnClass(int c) { |
|
573 |
if (c < 3) { |
|
574 |
return Boolean.class; |
|
575 |
} |
|
577 |
return String.class; |
|
578 |
} |
|
576 | 579 |
|
577 |
return String.class; |
|
578 |
} |
|
580 |
public void setValueAt(Object value, int row, int col) { |
|
581 |
if ((col < 3) && ((Boolean) value).booleanValue()) { |
|
582 |
for (int i = 0; i < getRowCount(); i++) { |
|
583 |
if (i != row) { |
|
584 |
setValueAt(new Boolean(false), i, col); |
|
585 |
} |
|
586 |
} |
|
587 |
} |
|
579 | 588 |
|
580 |
public void setValueAt(Object value, int row, int col) { |
|
581 |
if ((col < 3) && ((Boolean) value).booleanValue()) { |
|
582 |
for (int i = 0; i < getRowCount(); i++) { |
|
583 |
if (i != row) { |
|
584 |
setValueAt(new Boolean(false), i, col); |
|
585 |
} |
|
586 |
} |
|
587 |
} |
|
589 |
super.setValueAt(value, row, col); |
|
590 |
} |
|
588 | 591 |
|
589 |
super.setValueAt(value, row, col); |
|
590 |
} |
|
592 |
public void addNew() { |
|
593 |
super.addRow(new Object[] { new Boolean(false), new Boolean(false), new Boolean(false), "" }); |
|
594 |
} |
|
595 |
} |
|
591 | 596 |
|
592 |
public void addNew() { |
|
593 |
super.addRow(new Object[] { new Boolean(false), new Boolean(false), new Boolean(false), "" }); |
|
594 |
} |
|
595 |
} |
|
597 |
public void setComponentSize(int w, int h) { |
|
598 |
wComp = w; |
|
599 |
hComp = h; |
|
600 |
wFileList = wComp - 18; |
|
601 |
hFileList = (int) Math.round(hComp * 0.46); |
|
602 |
wBand = wFileList; |
|
603 |
hBand = hComp - hFileList - 20; |
|
596 | 604 |
|
597 |
public void setComponentSize(int w, int h) { |
|
598 |
wComp = w; |
|
599 |
hComp = h; |
|
600 |
wFileList = wComp - 18; |
|
601 |
hFileList = (int) Math.round(hComp * 0.46); |
|
602 |
wBand = wFileList; |
|
603 |
hBand = hComp - hFileList - 20; |
|
605 |
this.setPreferredSize(new Dimension(wComp, hComp)); |
|
606 |
this.setSize(wComp, hComp); |
|
607 |
rgbBandAssignPane.setBounds(10, hFileList + 12, wBand, hBand); |
|
608 |
getFileList().setBounds(9, 9, wFileList, hFileList); |
|
604 | 609 |
|
605 |
this.setPreferredSize(new Dimension(wComp, hComp)); |
|
606 |
this.setSize(wComp, hComp); |
|
607 |
rgbBandAssignPane.setBounds(10, hFileList + 12, wBand, hBand); |
|
608 |
fileList.setBounds(9, 9, wFileList, hFileList); |
|
610 |
} |
|
609 | 611 |
|
610 |
} |
|
612 |
/** |
|
613 |
* Redimensiona el panel cuando se redimensiona el contenedor de ?ste |
|
614 |
*/ |
|
615 |
public void componentResized(ComponentEvent e) { |
|
616 |
if (e.getSource() == this) { |
|
617 |
int nWidth = this.getSize().width; |
|
618 |
int nHeight = this.getSize().height; |
|
619 |
int difWidth = nWidth - 445; |
|
620 |
int difHeight = nHeight - 239; |
|
621 |
getFileList().setResize(difWidth, difHeight); |
|
622 |
rgbBandAssignPane.setBounds(10, 123 + difHeight / 2, 427 + difWidth, 104 + difHeight / 2); |
|
611 | 623 |
|
612 |
/** |
|
613 |
* Redimensiona el panel cuando se redimensiona el contenedor de ?ste |
|
614 |
*/ |
|
615 |
public void componentResized(ComponentEvent e) { |
|
616 |
if (e.getSource() == this) { |
|
617 |
int nWidth = this.getSize().width; |
|
618 |
int nHeight = this.getSize().height; |
|
619 |
int difWidth = nWidth - 445; |
|
620 |
int difHeight = nHeight - 239; |
|
621 |
this.fileList.setResize(difWidth, difHeight); |
|
622 |
this.rgbBandAssignPane.setBounds(10, 123 + difHeight / 2, 427 + difWidth, 104 + difHeight / 2); |
|
624 |
} |
|
625 |
} |
|
623 | 626 |
|
624 |
} |
|
625 |
} |
|
626 | 627 |
|
628 |
/* |
|
629 |
* (non-Javadoc) |
|
630 |
* @see org.gvsig.rastertools.properties.dialog.IRegistrablePanel#setLayer(com.iver.cit.gvsig.fmap.layers.FLyrDefault) |
|
631 |
*/ |
|
632 |
public void setLayer(FLayer lyr) { |
|
633 |
fLayer = lyr; |
|
627 | 634 |
|
628 |
/* |
|
629 |
* (non-Javadoc) |
|
630 |
* @see org.gvsig.rastertools.properties.dialog.IRegistrablePanel#setLayer(com.iver.cit.gvsig.fmap.layers.FLyrDefault) |
|
631 |
*/ |
|
632 |
public void setLayer(FLayer lyr) { |
|
633 |
fLayer = lyr; |
|
634 |
clear(); |
|
635 |
getFileList().clear(); |
|
635 |
actionEnabled(); |
|
636 |
|
|
637 |
clear(); |
|
638 |
getFileList().clear(); |
|
636 | 639 |
|
637 |
if (lyr instanceof IRasterProperties)
|
|
638 |
prop = (IRasterProperties) lyr;
|
|
640 |
if (lyr instanceof IRasterProperties)
|
|
641 |
prop = (IRasterProperties) lyr;
|
|
639 | 642 |
|
640 |
if (lyr instanceof IRasterRendering) {
|
|
641 |
if (((IRasterRendering) lyr).existColorTable()) {
|
|
642 |
panelListener.init(null, null, lyr);
|
|
643 |
this.setEnabled(false);
|
|
644 |
return;
|
|
645 |
}
|
|
646 |
}
|
|
643 |
if (lyr instanceof IRasterRendering) {
|
|
644 |
if (((IRasterRendering) lyr).existColorTable()) {
|
|
645 |
panelListener.init(null, null, lyr);
|
|
646 |
// this.setEnabled(false);
|
|
647 |
return;
|
|
648 |
}
|
|
649 |
}
|
|
647 | 650 |
|
648 |
this.setEnabled(true);
|
|
651 |
// this.setEnabled(true);
|
|
649 | 652 |
|
650 |
if (lyr instanceof IRasterDataset) {
|
|
651 |
dataset = (IRasterDataset) lyr;
|
|
652 |
addFiles(dataset.getDataSource());
|
|
653 |
}
|
|
653 |
if (lyr instanceof IRasterDataset) {
|
|
654 |
dataset = (IRasterDataset) lyr;
|
|
655 |
addFiles(dataset.getDataSource());
|
|
656 |
}
|
|
654 | 657 |
|
655 |
panelListener.init(dataset, prop, lyr); |
|
656 |
} |
|
658 |
panelListener.init(dataset, prop, lyr); |
|
659 |
|
|
660 |
|
|
661 |
} |
|
657 | 662 |
|
658 |
/** |
|
659 |
* Lee desde el renderizador las bandas que se han dibujado y en que posici?n se ha hecho. |
|
660 |
*/ |
|
661 |
public void readDrawedBands() { |
|
662 |
if (prop.getRender() != null) { |
|
663 |
int[] renderBands = prop.getRender().getRenderBands(); |
|
664 |
for (int i = 0; i < renderBands.length; i++) { |
|
665 |
if (renderBands[i] >= 0) { |
|
666 |
switch (i) { |
|
667 |
case 0: |
|
668 |
this.assignBand(renderBands[i], RasterDataset.RED_BAND); |
|
669 |
break; |
|
670 |
case 1: |
|
671 |
this.assignBand(renderBands[i], RasterDataset.GREEN_BAND); |
|
672 |
break; |
|
673 |
case 2: |
|
674 |
this.assignBand(renderBands[i], RasterDataset.BLUE_BAND); |
|
675 |
break; |
|
676 |
} |
|
677 |
} |
|
678 |
} |
|
679 |
} |
|
680 |
} |
|
663 |
private void actionEnabled() { |
|
664 |
boolean enabled = true; |
|
665 |
|
|
666 |
FLyrRasterSE fLyrRasterSE = ((FLyrRasterSE) fLayer); |
|
667 |
|
|
668 |
if (!fLyrRasterSE.isActionEnabled(IRasterLayerActions.PROPERTIES_BANDS_FILE_LIST)) |
|
669 |
enabled = false; |
|
670 |
getFileList().setEnabled(enabled); |
|
681 | 671 |
|
682 |
/* |
|
683 |
* (non-Javadoc) |
|
684 |
* @see org.gvsig.rastertools.properties.dialog.IRegistrablePanel#accept() |
|
685 |
*/ |
|
686 |
public void accept() { |
|
687 |
onlyApply(); |
|
688 |
} |
|
672 |
enabled = true; |
|
673 |
if (!fLyrRasterSE.isActionEnabled(IRasterLayerActions.PROPERTIES_BANDS_RGB)) |
|
674 |
enabled = false; |
|
675 |
getRGBTable().setEnabled(enabled); |
|
676 |
|
|
677 |
if (!fLyrRasterSE.isActionEnabled(IRasterLayerActions.PROPERTIES_BANDS_FILE_LIST) && |
|
678 |
!fLyrRasterSE.isActionEnabled(IRasterLayerActions.PROPERTIES_BANDS_RGB)) |
|
679 |
setVisiblePanel(false); |
|
680 |
else |
|
681 |
setVisiblePanel(true); |
|
682 |
} |
|
683 |
|
|
684 |
/** |
|
685 |
* Lee desde el renderizador las bandas que se han dibujado y en que posici?n se ha hecho. |
|
686 |
*/ |
|
687 |
public void readDrawedBands() { |
|
688 |
if (prop.getRender() != null) { |
|
689 |
int[] renderBands = prop.getRender().getRenderBands(); |
|
690 |
for (int i = 0; i < renderBands.length; i++) { |
|
691 |
if (renderBands[i] >= 0) { |
|
692 |
switch (i) { |
|
693 |
case 0: |
|
694 |
this.assignBand(renderBands[i], RasterDataset.RED_BAND); |
|
695 |
break; |
|
696 |
case 1: |
|
697 |
this.assignBand(renderBands[i], RasterDataset.GREEN_BAND); |
|
698 |
break; |
|
699 |
case 2: |
|
700 |
this.assignBand(renderBands[i], RasterDataset.BLUE_BAND); |
|
701 |
break; |
|
702 |
} |
|
703 |
} |
|
704 |
} |
|
705 |
} |
|
706 |
} |
|
689 | 707 |
|
690 |
/**
|
|
691 |
* Aplica y guarda los cambios del panel
|
|
692 |
*/
|
|
693 |
public void apply() {
|
|
694 |
onlyApply();
|
|
695 |
saveStatus();
|
|
696 |
}
|
|
708 |
/*
|
|
709 |
* (non-Javadoc)
|
|
710 |
* @see org.gvsig.rastertools.properties.dialog.IRegistrablePanel#accept()
|
|
711 |
*/
|
|
712 |
public void accept() {
|
|
713 |
onlyApply();
|
|
714 |
}
|
|
697 | 715 |
|
698 |
/**
|
|
699 |
* Aplicar los cambios sin guardar su estado
|
|
700 |
*/
|
|
701 |
public void onlyApply() {
|
|
702 |
if (RasterPropertiesTocMenuEntry.enableEvents)
|
|
703 |
panelListener.apply();
|
|
704 |
}
|
|
716 |
/**
|
|
717 |
* Aplica y guarda los cambios del panel
|
|
718 |
*/
|
|
719 |
public void apply() {
|
|
720 |
onlyApply();
|
|
721 |
saveStatus();
|
|
722 |
}
|
|
705 | 723 |
|
706 |
/** |
|
707 |
* Guarda el estado actual del panel |
|
708 |
*/ |
|
709 |
private void saveStatus() { |
|
710 |
ArrayList aux = new ArrayList(); |
|
711 |
int[] renderBands = prop.getRender().getRenderBands(); |
|
712 |
for (int i = 0; i < renderBands.length; i++) { |
|
713 |
aux.add(new Integer(renderBands[i])); |
|
714 |
} |
|
724 |
/** |
|
725 |
* Aplicar los cambios sin guardar su estado |
|
726 |
*/ |
|
727 |
public void onlyApply() { |
|
728 |
if (RasterPropertiesTocMenuEntry.enableEvents) |
|
729 |
panelListener.apply(); |
|
730 |
} |
|
715 | 731 |
|
716 |
RegistrableTabPanel.initialProperties.put("renderBands", aux); |
|
717 |
} |
|
732 |
/** |
|
733 |
* Guarda el estado actual del panel |
|
734 |
*/ |
|
735 |
private void saveStatus() { |
|
736 |
ArrayList aux = new ArrayList(); |
|
737 |
int[] renderBands = prop.getRender().getRenderBands(); |
|
738 |
for (int i = 0; i < renderBands.length; i++) { |
|
739 |
aux.add(new Integer(renderBands[i])); |
|
740 |
} |
|
718 | 741 |
|
742 |
RegistrableTabPanel.initialProperties.put("renderBands", aux); |
|
743 |
} |
|
719 | 744 |
|
720 |
/** |
|
721 |
* Deja la capa en el ?ltimo estado guardado y la refresca |
|
722 |
*/ |
|
723 |
public void restoreStatus() { |
|
724 | 745 |
|
725 |
ArrayList aux = (ArrayList) RegistrableTabPanel.initialProperties.get("renderBands"); |
|
746 |
/** |
|
747 |
* Deja la capa en el ?ltimo estado guardado y la refresca |
|
748 |
*/ |
|
749 |
public void restoreStatus() { |
|
726 | 750 |
|
727 |
int[] renderBands = new int[aux.size()]; |
|
728 |
for (int i = 0; i < aux.size(); i++) { |
|
729 |
renderBands[i] = ((Integer) aux.get(i)).intValue(); |
|
730 |
} |
|
751 |
ArrayList aux = (ArrayList) RegistrableTabPanel.initialProperties.get("renderBands"); |
|
731 | 752 |
|
732 |
prop.getRender().setRenderBands(renderBands); |
|
753 |
int[] renderBands = new int[aux.size()]; |
|
754 |
for (int i = 0; i < aux.size(); i++) { |
|
755 |
renderBands[i] = ((Integer) aux.get(i)).intValue(); |
|
756 |
} |
|
733 | 757 |
|
734 |
if (fLayer != null) |
|
735 |
fLayer.getMapContext().invalidate(); |
|
736 |
} |
|
758 |
prop.getRender().setRenderBands(renderBands); |
|
737 | 759 |
|
738 |
/* |
|
739 |
* (non-Javadoc) |
|
740 |
* @see org.gvsig.rastertools.properties.dialog.IRegistrablePanel#cancel() |
|
741 |
*/ |
|
742 |
public void cancel() { |
|
743 |
restoreStatus(); |
|
744 |
} |
|
760 |
if (fLayer != null) |
|
761 |
fLayer.getMapContext().invalidate(); |
|
762 |
} |
|
745 | 763 |
|
746 |
/*
|
|
747 |
* (non-Javadoc)
|
|
748 |
* @see org.gvsig.rastertools.properties.dialog.IRegistrablePanel#getID()
|
|
749 |
*/
|
|
750 |
public String getID() {
|
|
751 |
return id;
|
|
752 |
}
|
|
764 |
/*
|
|
765 |
* (non-Javadoc)
|
|
766 |
* @see org.gvsig.rastertools.properties.dialog.IRegistrablePanel#cancel()
|
|
767 |
*/
|
|
768 |
public void cancel() {
|
|
769 |
restoreStatus();
|
|
770 |
}
|
|
753 | 771 |
|
754 |
/** |
|
755 |
* Activa y desactiva el control |
|
756 |
* @param enabled true para activar y false para desactivar |
|
757 |
*/ |
|
758 |
public void setEnabled(boolean enabled) { |
|
759 |
if (panelListener != null) |
|
760 |
panelListener.setEnabledPanelAction(enabled); |
|
761 |
this.getRGBTable().setEnabled(enabled); |
|
762 |
this.getRGBBandAssignPane().setEnabled(enabled); |
|
763 |
getFileList().setEnabled(enabled); |
|
764 |
} |
|
765 |
|
|
766 |
/* |
|
767 |
* (non-Javadoc) |
|
768 |
* @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#setVisiblePanel(boolean) |
|
769 |
*/ |
|
772 |
/* |
|
773 |
* (non-Javadoc) |
|
774 |
* @see org.gvsig.rastertools.properties.dialog.IRegistrablePanel#getID() |
|
775 |
*/ |
|
776 |
public String getID() { |
|
777 |
return id; |
|
778 |
} |
|
779 |
|
|
780 |
/** |
|
781 |
* Activa y desactiva el control |
|
782 |
* @param enabled true para activar y false para desactivar |
|
783 |
*/ |
|
784 |
public void setEnabled(boolean enabled) { |
|
785 |
if (panelListener != null) |
|
786 |
panelListener.setEnabledPanelAction(enabled); |
|
787 |
getRGBTable().setEnabled(enabled); |
|
788 |
getRGBBandAssignPane().setEnabled(enabled); |
|
789 |
getFileList().setEnabled(enabled); |
|
790 |
} |
|
791 |
|
|
792 |
/* |
|
793 |
* (non-Javadoc) |
|
794 |
* @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#setVisiblePanel(boolean) |
|
795 |
*/ |
|
770 | 796 |
public void setVisiblePanel(boolean visible) { |
771 |
this.visible = visible;
|
|
772 |
}
|
|
797 |
this.visible = visible;
|
|
798 |
}
|
|
773 | 799 |
|
774 |
/*
|
|
775 |
* (non-Javadoc)
|
|
776 |
* @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#isVisiblePanel()
|
|
777 |
*/
|
|
778 |
public boolean isVisiblePanel() {
|
|
779 |
return visible;
|
|
780 |
}
|
|
781 |
|
|
782 |
/*
|
|
783 |
* (non-Javadoc)
|
|
784 |
* @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#getLayerClass()
|
|
785 |
*/
|
|
786 |
public Class getLayerClass() {
|
|
787 |
return FLyrRasterSE.class;
|
|
788 |
}
|
|
800 |
/*
|
|
801 |
* (non-Javadoc)
|
|
802 |
* @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#isVisiblePanel()
|
|
803 |
*/
|
|
804 |
public boolean isVisiblePanel() {
|
|
805 |
return visible;
|
|
806 |
}
|
|
807 |
|
|
808 |
/*
|
|
809 |
* (non-Javadoc)
|
|
810 |
* @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#getLayerClass()
|
|
811 |
*/
|
|
812 |
public Class getLayerClass() {
|
|
813 |
return FLyrRasterSE.class;
|
|
814 |
}
|
|
789 | 815 |
|
790 |
public void selectTab(String id) {}
|
|
791 |
public void componentHidden(ComponentEvent e) {}
|
|
792 |
public void componentShown(ComponentEvent e) {}
|
|
793 |
public void componentMoved(ComponentEvent e) {}
|
|
816 |
public void selectTab(String id) {}
|
|
817 |
public void componentHidden(ComponentEvent e) {}
|
|
818 |
public void componentShown(ComponentEvent e) {}
|
|
819 |
public void componentMoved(ComponentEvent e) {}
|
|
794 | 820 |
} |
Also available in: Unified diff