Revision 6703 org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.mapcontext.raster.swing/org.gvsig.fmap.mapcontext.raster.swing.impl/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/impl/bands/BandsPanelController.java
BandsPanelController.java | ||
---|---|---|
112 | 112 |
tblBands.setColumnModel(new DefaultTableColumnModel()); |
113 | 113 |
TableColumnModel columnModel = tblBands.getColumnModel(); |
114 | 114 |
columnModel.setColumnSelectionAllowed(false); |
115 |
for (int i=0; i<model.getColumnCount(); i++) {
|
|
115 |
for (int i = 0; i < model.getColumnCount(); i++) {
|
|
116 | 116 |
TableColumn tableColumn = new TableColumn(i); |
117 | 117 |
tableColumn.setIdentifier(model.getColumnName(i)); |
118 | 118 |
tableColumn.setHeaderValue(model.getColumnName(i)); |
119 | 119 |
columnModel.addColumn(tableColumn); |
120 | 120 |
} |
121 | 121 |
|
122 |
//FIXME: esto ser?a lo que habr?a que cambiar si se desea implementar otros espacios de color |
|
122 |
// FIXME: esto ser?a lo que habr?a que cambiar si se desea implementar |
|
123 |
// otros espacios de color |
|
123 | 124 |
columnModel.getColumn(0).setCellEditor(new ColorInterpretationCellEditor(BandsTableModel.RGBColorSpace)); |
124 | 125 |
columnModel.getColumn(0).setCellRenderer(new ColorInterpretationCellRenderer()); |
125 | 126 |
|
126 | 127 |
columnModel.getColumn(1).setCellRenderer(new NoDataCellRenderer()); |
127 |
// columnModel.getColumn(1).setCellEditor(new NoDataCellEditor());
|
|
128 |
// columnModel.getColumn(1).setCellEditor(new NoDataCellEditor());
|
|
128 | 129 |
|
129 | 130 |
columnModel.getColumn(2).setCellRenderer(new DataTypeCellRenderer()); |
130 | 131 |
|
131 |
|
|
132 |
|
|
133 | 132 |
} |
134 | 133 |
|
135 | 134 |
private void translate() { |
... | ... | |
166 | 165 |
LOG.warn("Can't get legend from '" + layer + "' layer.", e); |
167 | 166 |
} |
168 | 167 |
ColorInterpretation colorInterpretation = null; |
169 |
if(legend!=null){
|
|
168 |
if (legend != null) {
|
|
170 | 169 |
colorInterpretation = legend.getColorInterpretation(); |
171 | 170 |
} |
172 | 171 |
RasterStore store = this.layer.getRasterStore(); |
... | ... | |
179 | 178 |
* @param model |
180 | 179 |
*/ |
181 | 180 |
private void addBands(RasterStore store, ColorInterpretation colorInterpretation) { |
182 |
BandsTableModel model = ((BandsTableModel)tblBands.getModel()); |
|
181 |
BandsTableModel model = ((BandsTableModel) tblBands.getModel());
|
|
183 | 182 |
for (int i = 0; i < store.getBands(); i++) { |
184 | 183 |
BandDescriptor bandDescriptor = store.getBandDescriptor(i); |
185 | 184 |
|
186 | 185 |
RasterStoreBand rasterStoreBand = new RasterStoreBand(bandDescriptor.getStore(), bandDescriptor.getBand()); |
187 | 186 |
NoData noData = bandDescriptor.getNoData(); |
188 |
if(noData!=null){
|
|
187 |
if (noData != null) {
|
|
189 | 188 |
rasterStoreBand.setNoDataNumber(noData.getValue()); |
190 | 189 |
} |
191 | 190 |
rasterStoreBand.setBandName(bandDescriptor.getName()); |
192 | 191 |
rasterStoreBand.setDataType(bandDescriptor.getDataType()); |
193 | 192 |
|
194 |
if(colorInterpretation!=null){
|
|
193 |
if (colorInterpretation != null) {
|
|
195 | 194 |
rasterStoreBand.setBandColorInterpretation(colorInterpretation.get(i)); |
196 | 195 |
} else { |
197 | 196 |
rasterStoreBand.setBandColorInterpretation(ColorInterpretation.UNDEFINED_BAND); |
... | ... | |
208 | 207 |
RasterLayer rasterLayer = (RasterLayer) layer; |
209 | 208 |
RasterStore store = rasterLayer.getRasterStore(); |
210 | 209 |
store.clearAdditionalBands(); |
211 |
BandsTableModel model = (BandsTableModel)tblBands.getModel(); |
|
210 |
BandsTableModel model = (BandsTableModel) tblBands.getModel();
|
|
212 | 211 |
RasterLegendManager rasterLegendManager = RasterLegendLocator.getRasterLegendManager(); |
213 | 212 |
BufferManager bufferManager = BufferLocator.getBufferManager(); |
214 | 213 |
List<String> colorInterpretations = new ArrayList(); |
... | ... | |
224 | 223 |
ThreadSafeDialogsManager dlgManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
225 | 224 |
String message = "_cant_add_band_XbandX_from_store_XsourceX_to_store_XtargetX"; |
226 | 225 |
String title = "_error_adding_bands"; |
227 |
dlgManager.messageDialog( |
|
228 |
message, |
|
229 |
new String[] { |
|
230 |
String.valueOf(band), |
|
231 |
subStore.getName(), |
|
232 |
store.getName() }, |
|
233 |
title, JOptionPane.WARNING_MESSAGE); |
|
226 |
dlgManager.messageDialog(message, |
|
227 |
new String[] { String.valueOf(band), subStore.getName(), store.getName() }, title, |
|
228 |
JOptionPane.WARNING_MESSAGE); |
|
234 | 229 |
LOG.warn(message, e); |
235 | 230 |
return false; |
236 | 231 |
} |
... | ... | |
238 | 233 |
BandDescriptor bandDescriptor = store.getBandDescriptor(index); |
239 | 234 |
NoData noData = bandDescriptor.getNoData(); |
240 | 235 |
Number value = null; |
241 |
// try { |
|
242 |
value = rasterStoreBand.getNoDataNumber(); |
|
236 |
value = rasterStoreBand.getNoDataNumber(); |
|
243 | 237 |
|
244 |
// value = (Number)bufferManager.coerce(rasterStoreBand.getDataType(), rasterStoreBand.getNoData()); |
|
245 |
// } catch (CoercionException e) { |
|
246 |
// ThreadSafeDialogsManager dlgManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
247 |
// String message = "_it_cant_be_reconized_XvalueX_as_a_XdatatypenameX."; |
|
248 |
// String title = "_error_adding_bands"; |
|
249 |
// dlgManager.messageDialog( |
|
250 |
// message, |
|
251 |
// new String[] { |
|
252 |
// String.valueOf(band), |
|
253 |
// subStore.getName(), |
|
254 |
// store.getName() }, |
|
255 |
// title, JOptionPane.WARNING_MESSAGE); |
|
256 |
// LOG.warn(message, e); |
|
257 |
// return false; |
|
258 |
// } |
|
259 |
if(noData==null){ |
|
238 |
if (noData == null) { |
|
260 | 239 |
noData = bufferManager.createNoData(value, null); |
261 | 240 |
} else { |
262 |
noData.setValue((Number)value); |
|
241 |
noData.setValue((Number) value);
|
|
263 | 242 |
} |
264 | 243 |
bandDescriptor.setNoData(noData); |
265 | 244 |
colorInterpretations.add(rasterStoreBand.getBandColorInterpretation()); |
266 | 245 |
} |
267 | 246 |
|
268 |
|
|
269 | 247 |
ColorInterpretation colorInterpretation = null; |
270 | 248 |
colorInterpretation = |
271 | 249 |
rasterLegendManager.createColorInterpretation(colorInterpretations.toArray(new String[0])); |
... | ... | |
333 | 311 |
public void valueChanged(ListSelectionEvent e) { |
334 | 312 |
if (e.getSource() == tblBands.getSelectionModel()) { |
335 | 313 |
if (tblBands.getSelectedRow() >= 0) { |
336 |
if (this.layer.getRasterStore() != ((BandsTableModel) tblBands.getModel()).getElementAt(tblBands.getSelectedRow()).getStore()) { |
|
314 |
if (this.layer.getRasterStore() != ((BandsTableModel) tblBands.getModel()).getElementAt( |
|
315 |
tblBands.getSelectedRow()).getStore()) { |
|
337 | 316 |
btnRemove.setEnabled(true); |
338 | 317 |
} else { |
339 | 318 |
btnRemove.setEnabled(false); |
... | ... | |
370 | 349 |
return fileChooser; |
371 | 350 |
} |
372 | 351 |
|
352 |
/** |
|
353 |
* @author fdiaz |
|
354 |
* |
|
355 |
*/ |
|
373 | 356 |
public class MyFileFilter extends FileFilter { |
374 | 357 |
|
375 | 358 |
public FilesystemFileFilter filter = null; |
376 | 359 |
|
360 |
/** |
|
361 |
* @param params |
|
362 |
*/ |
|
377 | 363 |
public MyFileFilter(FilesystemFileFilter params) { |
378 | 364 |
this.filter = params; |
379 | 365 |
} |
... | ... | |
396 | 382 |
return filter.getDescription(); |
397 | 383 |
} |
398 | 384 |
|
385 |
/** |
|
386 |
* @return |
|
387 |
*/ |
|
399 | 388 |
public String getName() { |
400 | 389 |
return filter.getDataStoreProviderName(); |
401 | 390 |
} |
Also available in: Unified diff