root / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / scatterplot / gui / ScatterPlotPanel.java @ 17621
History | View | Annotate | Download (7.79 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 Instituto de Desarrollo Regional and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
|
34 |
* Campus Universitario s/n
|
35 |
* 02071 Alabacete
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 967 599 200
|
39 |
*/
|
40 |
|
41 |
package org.gvsig.remotesensing.scatterplot.gui; |
42 |
|
43 |
|
44 |
import java.awt.BorderLayout; |
45 |
import java.awt.Dimension; |
46 |
import java.awt.event.ActionEvent; |
47 |
import java.awt.event.ActionListener; |
48 |
|
49 |
import javax.swing.BorderFactory; |
50 |
import javax.swing.DefaultComboBoxModel; |
51 |
import javax.swing.JButton; |
52 |
import javax.swing.JLabel; |
53 |
import javax.swing.JPanel; |
54 |
import javax.swing.border.EmptyBorder; |
55 |
import javax.swing.border.TitledBorder; |
56 |
|
57 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
58 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
59 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
60 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
61 |
import org.gvsig.raster.buffer.BufferFactory; |
62 |
|
63 |
import com.iver.andami.PluginServices; |
64 |
import com.iver.cit.gvsig.fmap.MapControl; |
65 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
66 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
67 |
import com.iver.utiles.swing.JComboBox; |
68 |
|
69 |
/**
|
70 |
* Clase que define la interfaz que gestiona el grafico de dispersion.
|
71 |
* Permite la seleccion de las bandas por parte del usuario y el acceso
|
72 |
* al gestor de ROis del grafico.
|
73 |
*
|
74 |
* @author Alejandro Mu?oz Sanchez (alejandro.munoz@uclm.es)
|
75 |
* @see org.gvsig.remotesensing.scatterplot.gui.ChartScaterPlotPanel
|
76 |
* @version 4/12/2007
|
77 |
*/
|
78 |
|
79 |
public class ScatterPlotPanel extends DefaultButtonsPanel implements ActionListener { |
80 |
|
81 |
private static final long serialVersionUID = 1L; |
82 |
private MapControl mapControl = null; |
83 |
private FLayer fLayer = null; |
84 |
private View view = null; |
85 |
private JComboBox comboX= null; |
86 |
private JComboBox comboY= null; |
87 |
private ChartScaterPlotPanel panelGrafico = null; |
88 |
private JPanel selectionBandPanel= null; |
89 |
private JButton jbuttomGestor = null; |
90 |
|
91 |
|
92 |
/**
|
93 |
* Constructor del panel
|
94 |
**/
|
95 |
public ScatterPlotPanel(ScatterPlotDialog scatterDialog) {
|
96 |
super();
|
97 |
initialize(); |
98 |
} |
99 |
|
100 |
|
101 |
/**
|
102 |
* Acciones de inicializacion
|
103 |
**/
|
104 |
private void initialize() { |
105 |
setLayout(new BorderLayout(5,5)); |
106 |
setBorder(new EmptyBorder(11,15,11,15)); |
107 |
} |
108 |
|
109 |
|
110 |
/**
|
111 |
* Asignacion del layer al que esta asociado el diagrama
|
112 |
* */
|
113 |
public void setFLayer(FLayer layer) { |
114 |
|
115 |
fLayer = layer; |
116 |
if (view==null){ |
117 |
view = (View) PluginServices.getMDIManager().getActiveWindow();
|
118 |
mapControl = view.getMapControl(); |
119 |
BorderLayout bd= new BorderLayout(); |
120 |
bd.setVgap(3);
|
121 |
this.setLayout(bd);
|
122 |
// Quitar la contruccion del panel de aqui
|
123 |
add(getPanelGrafico(),BorderLayout.CENTER);
|
124 |
add(getBandPanel(), BorderLayout.SOUTH);
|
125 |
} |
126 |
|
127 |
} |
128 |
|
129 |
|
130 |
|
131 |
/**
|
132 |
* @return Panel con los combos de seleccion de bandas y y botton de
|
133 |
* acceso al gestor de ChartROIs
|
134 |
* */
|
135 |
public JPanel getBandPanel(){ |
136 |
|
137 |
if(selectionBandPanel==null){ |
138 |
selectionBandPanel = new JPanel(); |
139 |
TitledBorder topBorder = BorderFactory.createTitledBorder(PluginServices.getText(this,"bandas")); |
140 |
topBorder.setTitlePosition(TitledBorder.TOP);
|
141 |
selectionBandPanel.setBorder(topBorder); |
142 |
|
143 |
JPanel panelX= new JPanel(); |
144 |
panelX.add(new JLabel(PluginServices.getText(this,"bandax"))); |
145 |
panelX.add(getComboX()); |
146 |
selectionBandPanel.add(panelX); |
147 |
|
148 |
JPanel panelY= new JPanel(); |
149 |
panelY.add(new JLabel(PluginServices.getText(this,"banday"))); |
150 |
panelY.add(getComboY()); |
151 |
selectionBandPanel.add(panelY); |
152 |
|
153 |
JPanel panelButtom= new JPanel(); |
154 |
panelButtom.setSize(new Dimension(30,50)); |
155 |
panelButtom.add(getJbuttomGestor()); |
156 |
selectionBandPanel.add(panelButtom); |
157 |
|
158 |
} |
159 |
return selectionBandPanel;
|
160 |
|
161 |
} |
162 |
|
163 |
|
164 |
public MapControl getMapControl() {
|
165 |
return mapControl;
|
166 |
} |
167 |
|
168 |
|
169 |
|
170 |
public FLayer getLayer(){
|
171 |
return fLayer;
|
172 |
} |
173 |
|
174 |
|
175 |
public void aplicar(){ |
176 |
mapControl.getMapContext().getGraphicsLayer().clearAllGraphics(); |
177 |
|
178 |
// acciones al aplicar
|
179 |
} |
180 |
|
181 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
182 |
// Bot?n de Aceptar
|
183 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
184 |
aplicar(); |
185 |
} |
186 |
|
187 |
// Bot?n de Aplicar
|
188 |
if (e.getButton() == ButtonsPanel.BUTTON_APPLY) {
|
189 |
aplicar(); |
190 |
} |
191 |
|
192 |
// Bot?n de Cerrar
|
193 |
if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
|
194 |
} |
195 |
|
196 |
} |
197 |
|
198 |
/**
|
199 |
* Combo banda X
|
200 |
* */
|
201 |
public JComboBox getComboX() { |
202 |
if(comboX==null){ |
203 |
DefaultComboBoxModel defComboBand=new DefaultComboBoxModel(getBand()); |
204 |
comboX= new JComboBox(defComboBand); |
205 |
comboX.setSelectedIndex(0);
|
206 |
comboX.addActionListener(this);
|
207 |
|
208 |
} |
209 |
return comboX;
|
210 |
} |
211 |
|
212 |
|
213 |
|
214 |
/**
|
215 |
* Combo banda Y
|
216 |
* */
|
217 |
public JComboBox getComboY() { |
218 |
|
219 |
if(comboY==null){ |
220 |
DefaultComboBoxModel defComboBand=new DefaultComboBoxModel(getBand()); |
221 |
comboY= new JComboBox(defComboBand); |
222 |
FLyrRasterSE raster = (FLyrRasterSE) fLayer; |
223 |
BufferFactory buffer= new BufferFactory(raster.getDataSource());
|
224 |
if(buffer.getBandCount()>1) |
225 |
comboY.setSelectedIndex(1);
|
226 |
else
|
227 |
comboY.setSelectedIndex(0);
|
228 |
comboY.addActionListener(this);
|
229 |
|
230 |
} |
231 |
return comboY;
|
232 |
} |
233 |
|
234 |
|
235 |
/** @return panel grafico que contiene el diagrama */
|
236 |
public ChartScaterPlotPanel getPanelGrafico() {
|
237 |
if(panelGrafico==null){ |
238 |
FLyrRasterSE raster = (FLyrRasterSE) fLayer; |
239 |
BufferFactory buffer= new BufferFactory(raster.getDataSource());
|
240 |
if(buffer.getBandCount()>1) |
241 |
// por defecto se construye el grafico con las bandas 0 y 1
|
242 |
panelGrafico= new ChartScaterPlotPanel(fLayer, 0,1); |
243 |
else
|
244 |
// si solo hay una banda se construye el grafico con la misma banda en x y en y
|
245 |
panelGrafico = new ChartScaterPlotPanel(fLayer,0,0); |
246 |
} |
247 |
|
248 |
return panelGrafico;
|
249 |
} |
250 |
|
251 |
|
252 |
/**
|
253 |
* @return array con los identificativos de las capas
|
254 |
* */
|
255 |
public String[] getBand(){ |
256 |
|
257 |
FLyrRasterSE raster = (FLyrRasterSE) fLayer; |
258 |
BufferFactory buffer= new BufferFactory(raster.getDataSource());
|
259 |
String bands[]= new String[raster.getBandCount()]; |
260 |
for (int i= 0; i< raster.getBandCount(); i++) |
261 |
bands[i]= PluginServices.getText(this,"banda")+(i+1); |
262 |
return bands;
|
263 |
|
264 |
} |
265 |
|
266 |
|
267 |
public void actionPerformed(ActionEvent e) { |
268 |
if(e.getSource()== getComboX()){
|
269 |
panelGrafico.setBandX(getComboX().getSelectedIndex()); |
270 |
panelGrafico.updateChart(); |
271 |
panelGrafico.updateUI(); |
272 |
panelGrafico.repaint(); |
273 |
|
274 |
} |
275 |
if(e.getSource()== getComboY()){
|
276 |
panelGrafico.setBandY(getComboY().getSelectedIndex()); |
277 |
panelGrafico.updateChart(); |
278 |
panelGrafico.updateUI(); |
279 |
panelGrafico.repaint(); |
280 |
} |
281 |
|
282 |
if(e.getSource()== getJbuttomGestor()){
|
283 |
|
284 |
// A?ade el panel gestor de rois a la vista
|
285 |
ManagerROIChartPanel panel =new ManagerROIChartPanel(panelGrafico);
|
286 |
panelGrafico.getChart().setManagerROi(panel); |
287 |
PluginServices.getMDIManager().addWindow(panel); |
288 |
|
289 |
} |
290 |
|
291 |
} |
292 |
|
293 |
|
294 |
public JButton getJbuttomGestor() { |
295 |
|
296 |
if(jbuttomGestor==null){ |
297 |
jbuttomGestor= new JButton(PluginServices.getText(this,"gestor")); |
298 |
jbuttomGestor.addActionListener(this);
|
299 |
} |
300 |
return jbuttomGestor;
|
301 |
} |
302 |
|
303 |
} |
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|