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

View differences:

HistogramPanelListener.java
20 20

  
21 21
import java.awt.event.ActionEvent;
22 22
import java.awt.event.ActionListener;
23
import java.awt.event.FocusEvent;
24
import java.awt.event.FocusListener;
25 23
import java.awt.event.KeyEvent;
26 24
import java.awt.event.KeyListener;
27
import java.awt.event.MouseEvent;
28
import java.awt.event.MouseListener;
29
import java.awt.event.MouseMotionListener;
30 25

  
31
import javax.swing.JLabel;
32
import javax.swing.event.TableModelEvent;
26
import javax.swing.JButton;
27
import javax.swing.JComboBox;
33 28

  
34 29
import org.gvsig.rastertools.histogram.Histogram;
35 30
/**
......
39 34
 * @author Nacho Brodin (brodin_ign@gva.es)
40 35
 * @author Borja Sanchez Zamorano (borja.sanchez@iver.es)
41 36
 */
42
public class HistogramPanelListener implements ActionListener, KeyListener, FocusListener {
37
public class HistogramPanelListener implements ActionListener, KeyListener {
43 38

  
44 39
	private HistogramPanel			panel = null;
45 40
	/**
......
64 59
		panel.getGraphicContainer().getLessButtonControlRight().addActionListener(this);
65 60
		panel.getGraphicContainer().getTextControlRight().addKeyListener(this);
66 61
		panel.getGraphicContainer().getTextControlLeft().addKeyListener(this);
67
		panel.getGraphicContainer().getTextControlRight().addFocusListener(this);
68
		panel.getGraphicContainer().getTextControlLeft().addFocusListener(this);
69 62
	}
70 63

  
64
	
65
	public void keyPressed(KeyEvent e) {
66
		if (e.getKeyCode() == 10) {
67
			updateStatistic();
68
		}
69
	}
70

  
71
	private void updateStatistic() {
72
		// TODO Actualizar tabla de los histogramas.
73
		System.out.println("Botones + o - apretados, actualizar tabla");
74
//		panel.setStatistic(GridStatistic.getBasicStatsFromHistogram(getLastHistogram(), (int)panel.getBoxesValues()[1], (int)panel.getBoxesValues()[0], panel.showBands));
75
	}
76

  
71 77
	public void actionPerformed(ActionEvent e) {
72
/*		
73
		//--------------------------------------
74 78
		//Botones de m?s y menos
75
		if(	e.getSource() == panel.getPHistogram().getPlusButtonControlLeft() ||
76
			e.getSource() == panel.getPHistogram().getLessButtonControlLeft() ||
77
			e.getSource() == panel.getPHistogram().getPlusButtonControlRight() ||
78
			e.getSource() == panel.getPHistogram().getLessButtonControlRight()){
79
			panel.setStatistic(Statistic.getBasicStatsFromHistogram(panel.getLastHistogram(),
80
																	(int)panel.getBoxesValues()[1], 
81
																	(int)panel.getBoxesValues()[0],
82
																	panel.showBands));
79
		if (e.getSource() == panel.getGraphicContainer().getPlusButtonControlLeft()  ||
80
				e.getSource() == panel.getGraphicContainer().getLessButtonControlLeft()  ||
81
				e.getSource() == panel.getGraphicContainer().getPlusButtonControlRight() ||
82
				e.getSource() == panel.getGraphicContainer().getLessButtonControlRight() ) {
83
			updateStatistic();
83 84
			return;
84 85
		}
85
			
86

  
86 87
		
87 88
		//--------------------------------------
88 89
		//Cambiar las bandas en el combo
89 90
		JComboBox cbb = panel.getJComboBands();
90
		if(comboEventEnable && e.getSource() == cbb){
91
			if(cbb.getSelectedIndex() == 0){
91
		if (comboEventEnable && e.getSource() == cbb){
92
			if(cbb.getSelectedIndex() == 0) {
92 93
				boolean[] list = panel.getBandListShowInChart();
93
				for(int i = 0; i < list.length; i++)
94
				for (int i = 0; i < list.length; i++)
94 95
					list[i] = true;
95 96
				panel.setBandListShowInChart(list);
96
			}else if(cbb.getSelectedItem().equals("R") || cbb.getSelectedItem().equals("Band 0"))
97
			} else if(cbb.getSelectedItem().equals("R") || cbb.getSelectedItem().equals("Band 0"))
97 98
				panel.addOrRemoveGraphicBand(0);
98 99
			else if(cbb.getSelectedItem().equals("G") || cbb.getSelectedItem().equals("Band 1"))
99 100
				panel.addOrRemoveGraphicBand(1);
100 101
			else if(cbb.getSelectedItem().equals("B") || cbb.getSelectedItem().equals("Band 2"))
101 102
				panel.addOrRemoveGraphicBand(2);
102
			else{
103
				for(int i = 3; i < HistogramPanel.MAXBANDS; i++){
104
					if(cbb.getSelectedItem().equals("Band "+i))
103
			else {
104
				for (int i = 3; i < HistogramPanel.MAXBANDS; i++) {
105
					if (cbb.getSelectedItem().equals("Band "+i))
105 106
						panel.addOrRemoveGraphicBand(i);
106 107
				}
107 108
			}
......
125 126
				panel.setRGBInBandList();
126 127
			
127 128
			//En caso de que el histograma se monte a partir de los datos reales ponemos el n?mero de bandas en el combo
128
			if(cbo.getSelectedIndex() == 1 || cbo.getSelectedIndex() == 2)
129
				panel.setBands(panel.getHistogram().getGrid().getBandCount());			
129
//			if (cbo.getSelectedIndex() == 1 || cbo.getSelectedIndex() == 2)
130
//				panel.setBands(getHistogram().getGrid().getGrid().getBandCount());			
130 131
		}
131 132
				
132 133
		//--------------------------------------
133 134
		//Selecci?n de histograma acumulado y no acumulado
134 135
		JComboBox cbt = panel.getJComboBoxTipo();
135
		if(comboEventEnable && e.getSource() == cbt)
136
		if (comboEventEnable && e.getSource() == cbt)
136 137
			panel.setType(cbt.getSelectedIndex());
137 138
	
138
		if(comboEventEnable)
139
			panel.showHistogram();
140
*/
139
//		if(comboEventEnable)
140
//			panel.showHistogram();
141

  
141 142
	}
142 143

  
143 144
	/**
......
166 167
			lastHistogram = getHistogram().getFullHistogram();
167 168
		else if(panel.getType() == 1)
168 169
			lastHistogram = getHistogram().getFullAccumulatedHistogram();
169
		
170
/*		setStatistic(Statistic.getBasicStatsFromHistogram(	lastHistogram, 
171
															(int)getBoxesValues()[1], 
172
															(int)getBoxesValues()[0], 
173
															showBands));
174
*/
170

  
171
		this.updateStatistic();
172

  
175 173
		//Si el histograma es grande lo recortamos para mostrarlo porque jfreeChart se vuelve
176 174
		//inestable al poner muchos elementos en las X
177 175
		
......
217 215
	public Histogram getHistogram() {
218 216
		return histogram;
219 217
	}
220
	
221
	public void keyPressed(KeyEvent e) {
222
/*		if(e.getKeyCode() == 10){
223
			panel.setStatistic(Statistic.getBasicStatsFromHistogram(panel.getLastHistogram(),
224
																	(int)panel.getBoxesValues()[1], 
225
																	(int)panel.getBoxesValues()[0],
226
																	panel.showBands));
227
			
228
		}*/
229
	}
230 218

  
231 219
	public void keyReleased(KeyEvent e) {
232
		// TODO Auto-generated method stub
233
		
234 220
	}
235 221

  
236 222
	public void keyTyped(KeyEvent e) {
237
		// TODO Auto-generated method stub
238
		
239 223
	}
240

  
241
	public void focusGained(FocusEvent e) {
242
		// TODO Auto-generated method stub
243
		
244
	}
245

  
246
	public void focusLost(FocusEvent e) {
247
		// TODO Auto-generated method stub
248
		
249
	}
250 224
}

Also available in: Unified diff