Revision 11068 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/HistogramPanelListener.java

View differences:

HistogramPanelListener.java
90 90
  		Color.gray,
91 91
  		Color.magenta,
92 92
  		Color.yellow,
93
  		Color.orange};
94
		
93
  		Color.orange,
94
  		Color.pink,
95
  		Color.lightGray};
96

  
95 97
	public HistogramPanelListener(HistogramPanel p){
96 98
		histogramPanel = p;
97 99
	}
98
	
100

  
99 101
	public void setControlListeners(){
100 102
		histogramPanel.getGraphicContainer().addValueChangedListener(this);
101 103
	}
102
	
104

  
105
	/**
106
	 * Actualizar cuadro de estad?sticas
107
	 */
103 108
	private void updateStatistic() {
104 109
		int first = (int) histogramPanel.getBoxesValues()[1];
105 110
		int end = (int) histogramPanel.getBoxesValues()[0];
106 111

  
107
		histogramPanel.setStatistic(lastHistogram.getBasicStats((int) first, (int) end, showBands));
112
		histogramPanel.setStatistic(getLastHistogram().getBasicStats((int) first, (int) end, showBands));
108 113
	}
109 114

  
115
	/**
116
	 * Tratamiento de todos los eventos visuales.
117
	 */
110 118
	public void actionPerformed(ActionEvent e) {
111 119
		if (!eventsEnabled) return;
112 120
		//--------------------------------------
......
178 186
					DbaseFileHeaderNIO myHeader;
179 187
					Value[] record;
180 188
		        	
181
					long histogram[][]= lastHistogram.getHistogram();
189
					long histogram[][]= getLastHistogram().getHistogram();
182 190
					int numBands = histogram.length;
183 191
					int numRecors = histogram[0].length;
184 192
		        	
......
245 253
		}
246 254
	}
247 255

  
256
	/**
257
	 * Actualizar la variable de las bandas visibles y su componente visual.
258
	 */
248 259
	private void refreshBands() {
249 260
		histogramPanel.refreshBands();
250
		showBands = new boolean[getHistogram().getNumBands()];
261
		showBands = new boolean[getLastHistogram().getNumBands()];
251 262
		for (int i = 0; i < showBands.length; i++)
252 263
			showBands[i] = true;
253 264
	}
254 265
	
266
	/**
267
	 * Lanza los dos threads para procesar el histograma y visualizar la
268
	 * ventana de incremento
269
	 */
255 270
	public void showHistogram() {
256 271
		if (histogramPanel.getJComboBoxOrigen().getSelectedIndex() < 0) return;
257 272

  
......
264 279
		histogramProcess.start();
265 280
		incrementableTask.start();
266 281
	}
267
	
282

  
268 283
	/**
269 284
	 * A?ade o elimina una banda de la visualizaci?n. Si la banda se est? visualizando
270 285
	 * se elimina y si no entonces se muestra
......
275 290
		showBands[band] = !showBands[band];
276 291
	}
277 292

  
293
	/**
294
	 * Actualiza la grafica con los datos que ya teniamos del histograma.
295
	 */
278 296
	private void updateGraphic() {
279
		long[][] auxHistogram = lastHistogram.getHistogramByType(Histogram.getType(histogramPanel.getJComboBoxTipo().getSelectedIndex()));
297
		long[][] auxHistogram = getLastHistogram().getHistogramByType(Histogram.getType(histogramPanel.getJComboBoxTipo().getSelectedIndex()));
280 298
		if (auxHistogram == null) return;
281 299

  
282 300
		int first = (int) histogramPanel.getBoxesValues()[1];
......
300 318
				newHistogram[numBand][j-first] = (int) auxHistogram[iBand][j];
301 319
			bandNames[numBand] = iBand + "";
302 320

  
303
			histogramPanel.getGraphicContainer().setBandColor(numBand, bandsColor[iBand]);
321
			histogramPanel.getGraphicContainer().setBandColor(numBand, bandsColor[iBand % bandsColor.length]);
304 322

  
305 323
			numBand++;
306 324
		}
......
309 327
		updateStatistic();
310 328
	}
311 329

  
330
	/**
331
	 * Definir el nuevo histograma, metodo pu?blico para ser invocado desde
332
	 * histogramProcess
333
	 * @param histograma nuevo
334
	 */
312 335
	public void setNewHistogram(Histogram value) {
313 336
		histogramPanel.panelInizialited = false;
314 337
		eventsEnabled = false;
......
324 347
		histogramPanel.panelInizialited = true;
325 348
	}
326 349

  
327
	public Histogram getHistogram() {
350
	/**
351
	 * Obtener ?ltimo histograma
352
	 * @return Histogram
353
	 */
354
	public Histogram getLastHistogram() {
328 355
		return lastHistogram;
329 356
	}
330 357

  
358
	/**
359
	 * Eventos de los BoxValues
360
	 */
331 361
	public void actionValueChanged(GraphicEvent e) {
332 362
		updateGraphic();
333 363
	}
334 364
	
335
	private WritableByteChannel getWriteChannel(String path)throws IOException {
365
	/**
366
	 * Proceso para guardar una estadistica en un fichero.
367
	 * @param path
368
	 * @return
369
	 * @throws IOException
370
	 */
371
	private WritableByteChannel getWriteChannel(String path) throws IOException {
336 372
		WritableByteChannel channel;
337 373
		
338 374
		File f = new File(path);

Also available in: Unified diff