Revision 11151 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/HistogramPanelListener.java
HistogramPanelListener.java | ||
---|---|---|
19 | 19 |
package org.gvsig.rastertools.histogram; |
20 | 20 |
|
21 | 21 |
import java.awt.Color; |
22 |
import java.awt.Component; |
|
23 | 22 |
import java.awt.event.ActionEvent; |
24 | 23 |
import java.awt.event.ActionListener; |
25 | 24 |
import java.beans.PropertyChangeEvent; |
... | ... | |
27 | 26 |
import java.io.File; |
28 | 27 |
import java.io.IOException; |
29 | 28 |
import java.io.RandomAccessFile; |
30 |
import java.nio.channels.FileChannel; |
|
31 | 29 |
import java.nio.channels.WritableByteChannel; |
32 | 30 |
import java.util.ArrayList; |
33 | 31 |
|
34 |
import javax.swing.JButton; |
|
35 | 32 |
import javax.swing.JComboBox; |
36 |
import javax.swing.JFileChooser; |
|
37 |
import javax.swing.JOptionPane; |
|
38 | 33 |
import javax.swing.table.DefaultTableModel; |
39 | 34 |
|
40 | 35 |
import org.gvsig.gui.beans.graphic.GraphicEvent; |
41 | 36 |
import org.gvsig.gui.beans.graphic.GraphicListener; |
42 | 37 |
import org.gvsig.gui.beans.incrementabletask.IncrementableTask; |
43 | 38 |
import org.gvsig.raster.util.Histogram; |
39 |
import org.gvsig.raster.util.HistogramClass; |
|
44 | 40 |
import org.gvsig.raster.util.IHistogramable; |
45 | 41 |
import org.gvsig.rastertools.histogram.ui.HistogramPanel; |
46 |
|
|
47 |
import com.hardcode.driverManager.DriverLoadException; |
|
48 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
49 |
import com.hardcode.gdbms.engine.data.DataSource; |
|
50 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
|
51 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
|
52 |
import com.hardcode.gdbms.engine.values.Value; |
|
53 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
54 |
import com.iver.andami.PluginServices; |
|
55 |
import com.iver.cit.gvsig.ProjectExtension; |
|
56 |
import com.iver.cit.gvsig.fmap.drivers.shp.DbaseFileHeaderNIO; |
|
57 |
import com.iver.cit.gvsig.fmap.drivers.shp.DbaseFileWriterNIO; |
|
58 |
import com.iver.cit.gvsig.fmap.edition.EditableAdapter; |
|
59 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
|
60 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
61 |
import com.iver.cit.gvsig.project.ProjectFactory; |
|
62 |
import com.iver.cit.gvsig.project.documents.table.ProjectTable; |
|
63 |
import com.iver.cit.gvsig.project.documents.table.gui.Table; |
|
64 | 42 |
/** |
65 | 43 |
* Listener para eventos del panel de histograma |
66 | 44 |
* |
... | ... | |
143 | 121 |
|
144 | 122 |
//-------------------------------------- |
145 | 123 |
// Boton Crear Tabla |
124 |
/* |
|
146 | 125 |
JButton table = getHistogramPanel().getBCreateTable(); |
147 | 126 |
if (e.getSource() == table) { |
148 | 127 |
try { |
... | ... | |
228 | 207 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),getHistogramPanel().getName() + " " + PluginServices.getText(this,"table_not_create")); |
229 | 208 |
} |
230 | 209 |
} |
210 |
*/ |
|
231 | 211 |
} |
232 | 212 |
|
233 | 213 |
/** |
... | ... | |
271 | 251 |
* Actualiza la grafica con los datos que ya teniamos del histograma. |
272 | 252 |
*/ |
273 | 253 |
private void updateGraphic() { |
274 |
long[][] auxHistogram = getLastHistogram().getHistogramByType(Histogram.getType(getHistogramPanel().getJComboBoxTipo().getSelectedIndex()));
|
|
275 |
if (auxHistogram == null) return;
|
|
254 |
HistogramClass[][] histogramClass = getLastHistogram().getHistogramByType(Histogram.getType(getHistogramPanel().getJComboBoxTipo().getSelectedIndex()));
|
|
255 |
if (histogramClass == null) return;
|
|
276 | 256 |
|
257 |
double[][][] datos = new double[histogramClass.length][histogramClass[0].length][2]; |
|
258 |
for (int iBand=0; iBand < histogramClass.length; iBand++) { |
|
259 |
for (int i=0; i<histogramClass[iBand].length; i++) { |
|
260 |
datos[iBand][i][0] = histogramClass[iBand][i].getMin(); |
|
261 |
datos[iBand][i][1] = histogramClass[iBand][i].getNPixels(); |
|
262 |
} |
|
263 |
} |
|
264 |
|
|
265 |
// long[][] auxHistogram = getLastHistogram().getHistogramByType(Histogram.getType(getHistogramPanel().getJComboBoxTipo().getSelectedIndex())); |
|
266 |
// if (auxHistogram == null) return; |
|
267 |
|
|
277 | 268 |
int first = (int) getHistogramPanel().getBoxesValues()[1]; |
278 | 269 |
int end = (int) getHistogramPanel().getBoxesValues()[0]; |
279 | 270 |
|
... | ... | |
282 | 273 |
if (showBands[i]) bandCount++; |
283 | 274 |
} |
284 | 275 |
|
285 |
int[][] newHistogram = new int[bandCount][end - first];
|
|
276 |
double[][][] newHistogram = new double[bandCount][end - first][2];
|
|
286 | 277 |
String[] bandNames = new String[bandCount]; |
287 | 278 |
|
288 |
bandCount = auxHistogram.length;
|
|
279 |
bandCount = datos.length;
|
|
289 | 280 |
|
290 | 281 |
int numBand = 0; |
291 |
for (int iBand = 0; iBand < auxHistogram.length; iBand++) {
|
|
282 |
for (int iBand = 0; iBand < datos.length; iBand++) {
|
|
292 | 283 |
if (!showBands[iBand]) continue; |
293 | 284 |
|
294 |
for (int j=first; j<end; j++) |
|
295 |
newHistogram[numBand][j-first] = (int) auxHistogram[iBand][j]; |
|
285 |
for (int j=first; j<end; j++) { |
|
286 |
newHistogram[numBand][j-first][0] = datos[iBand][j][0]; |
|
287 |
newHistogram[numBand][j-first][1] = datos[iBand][j][1]; |
|
288 |
} |
|
296 | 289 |
bandNames[numBand] = (String) ((DefaultTableModel) getHistogramPanel().getJTableBands().getModel()).getValueAt(iBand, 1); |
297 | 290 |
|
298 | 291 |
getHistogramPanel().getGraphicContainer().setBandColor(numBand, bandsColor[iBand % bandsColor.length]); |
Also available in: Unified diff