root / trunk / extensions / extRemoteSensing / src / org / gvsig / remotesensing / profiles / gui / ProfilePanel.java @ 20304
History | View | Annotate | Download (8.85 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.profiles.gui; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.Dimension; |
45 |
import java.util.ArrayList; |
46 |
import java.util.Iterator; |
47 |
|
48 |
import javax.swing.JPanel; |
49 |
import javax.swing.JTabbedPane; |
50 |
import javax.swing.event.ChangeEvent; |
51 |
import javax.swing.event.ChangeListener; |
52 |
|
53 |
import org.gvsig.fmap.raster.grid.roi.VectorialROI; |
54 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
55 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
56 |
import org.gvsig.gui.beans.graphic.GraphicChartPanel; |
57 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
58 |
import org.gvsig.raster.grid.roi.ROI; |
59 |
import org.gvsig.raster.util.RasterToolsUtil; |
60 |
|
61 |
import com.iver.andami.PluginServices; |
62 |
import com.iver.cit.gvsig.fmap.MapControl; |
63 |
import com.iver.cit.gvsig.fmap.core.FShape; |
64 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
65 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
66 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
67 |
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol; |
68 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
69 |
import com.iver.cit.gvsig.fmap.layers.GraphicLayer; |
70 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
71 |
|
72 |
/**
|
73 |
* Clase que define el panel donde aparece el grafico del perfil espectral de los puntos que seleccione el
|
74 |
* usuario.
|
75 |
*
|
76 |
* @author aMu?oz (alejandro.munoz@uclm.es)
|
77 |
* @version 11/3/2008
|
78 |
*/
|
79 |
|
80 |
public class ProfilePanel extends DefaultButtonsPanel implements ChangeListener{ |
81 |
|
82 |
private static final long serialVersionUID = 1L; |
83 |
private GraphicChartPanel jPanelChart = null; |
84 |
private MapControl mapControl = null;; |
85 |
private JPanel southPanel = null; |
86 |
private ZProfileOptionsPanel pointOptionsPanel= null; |
87 |
private LineProfileOptionsPanel lineOptionsPanel= null; |
88 |
private JTabbedPane tabbedPane = null; |
89 |
public static int PANELZPROFILE = 0; |
90 |
public static int PANELLINEPROFILE =1; |
91 |
private int nextActiveChart = 0; |
92 |
|
93 |
/** Constructor del panel.
|
94 |
* @param flayer capa de la que se van a tomar los puntos
|
95 |
**/
|
96 |
public ProfilePanel(ProfileDialog dialog){
|
97 |
super(ButtonsPanel.BUTTONS_ACCEPTCANCEL);
|
98 |
this.mapControl= dialog.getMapControl();
|
99 |
initialize(); |
100 |
} |
101 |
|
102 |
|
103 |
/**
|
104 |
* Inicializacion del panel que contiene el grafico
|
105 |
* */
|
106 |
private void initialize() { |
107 |
this.setLayout(new BorderLayout()); |
108 |
this.add(getChart(), BorderLayout.CENTER); |
109 |
this.add(getSouthPanel(), BorderLayout.SOUTH); |
110 |
} |
111 |
|
112 |
/**
|
113 |
* @return grafico actual
|
114 |
* */
|
115 |
public GraphicChartPanel getChart(){
|
116 |
if(jPanelChart == null){ |
117 |
jPanelChart = new GraphicChartPanel();
|
118 |
this.jPanelChart.getChart().getChart().getPlot().setBackgroundImage(null); |
119 |
jPanelChart.getChart().setDomainZoomable(false);
|
120 |
jPanelChart.getChart().setRangeZoomable(false);
|
121 |
jPanelChart.getChart().setDisplayToolTips(true);
|
122 |
} |
123 |
return jPanelChart;
|
124 |
} |
125 |
|
126 |
|
127 |
/**
|
128 |
* @return mapControl
|
129 |
* */
|
130 |
public MapControl getMapControl() {
|
131 |
return mapControl ;
|
132 |
} |
133 |
|
134 |
|
135 |
/**
|
136 |
* @return JPanel con los tab.
|
137 |
* */
|
138 |
public JPanel getSouthPanel(){ |
139 |
if(southPanel== null){ |
140 |
southPanel= new JPanel(); |
141 |
BorderLayout bd= new BorderLayout(); |
142 |
southPanel.setLayout(bd); |
143 |
southPanel.setPreferredSize(new Dimension(150,110)); |
144 |
getTabbedPane().addTab(PluginServices.getText(this, "zProfile"), getPointOptionsPanel()); |
145 |
getTabbedPane().addTab(PluginServices.getText(this, "lineProfile"), getLineOptionsPanel()); |
146 |
southPanel.add(getTabbedPane(),BorderLayout.CENTER);
|
147 |
} |
148 |
return southPanel;
|
149 |
} |
150 |
|
151 |
|
152 |
/**
|
153 |
* @return panel con las opciones zProfiles
|
154 |
* */
|
155 |
public ZProfileOptionsPanel getPointOptionsPanel(){
|
156 |
if(pointOptionsPanel==null){ |
157 |
pointOptionsPanel= new ZProfileOptionsPanel(this); |
158 |
pointOptionsPanel.setJPanelChart(getChart()); |
159 |
} |
160 |
return pointOptionsPanel;
|
161 |
} |
162 |
|
163 |
/**
|
164 |
* @return panel con las opciones lineProfiles
|
165 |
* */
|
166 |
public LineProfileOptionsPanel getLineOptionsPanel(){
|
167 |
if(lineOptionsPanel==null){ |
168 |
lineOptionsPanel= new LineProfileOptionsPanel(this); |
169 |
lineOptionsPanel.setJPanelChart(getChart()); |
170 |
} |
171 |
return lineOptionsPanel;
|
172 |
} |
173 |
|
174 |
|
175 |
public JTabbedPane getTabbedPane(){ |
176 |
if(tabbedPane==null){ |
177 |
tabbedPane= new JTabbedPane(); |
178 |
tabbedPane.addChangeListener(this);
|
179 |
} |
180 |
return tabbedPane;
|
181 |
} |
182 |
|
183 |
|
184 |
/**
|
185 |
* Acciones a llevar a cabo cuando se cambia de pesta?a
|
186 |
* */
|
187 |
public void stateChanged(ChangeEvent e) { |
188 |
|
189 |
if(e.getSource().equals(getTabbedPane())){
|
190 |
|
191 |
if(nextActiveChart==PANELZPROFILE){
|
192 |
// Se actualizan las propiedades del gr?fico
|
193 |
getPointOptionsPanel().getJPanelChart(); |
194 |
getPointOptionsPanel().selectDrawRoiTool(); |
195 |
|
196 |
GraphicLayer graphicLayer = mapControl.getMapContext().getGraphicsLayer(); |
197 |
// Se pintan todas las rois que existan en la tabla
|
198 |
ArrayList roisArray = getPointOptionsPanel().getROIs();
|
199 |
|
200 |
if (roisArray != null) { |
201 |
ISymbol symbol = null;
|
202 |
FGraphic fGraphic = null;
|
203 |
for (Iterator iter = roisArray.iterator(); iter.hasNext();) { |
204 |
VectorialROI vectorialROI = (VectorialROI)iter.next();; |
205 |
for (Iterator iterator = vectorialROI.getGeometries().iterator(); iterator.hasNext();) { |
206 |
IGeometry geometry = (IGeometry) iterator.next(); |
207 |
switch (geometry.getGeometryType()) {
|
208 |
case FShape.POINT:
|
209 |
symbol = SymbologyFactory.createDefaultMarkerSymbol(); |
210 |
((IMarkerSymbol) symbol).setColor(vectorialROI.getColor()); |
211 |
break;
|
212 |
} |
213 |
fGraphic = new FGraphic(geometry, graphicLayer.addSymbol(symbol));
|
214 |
graphicLayer.addGraphic(fGraphic); |
215 |
getPointOptionsPanel().getRoiGraphics(vectorialROI.getName()).add(fGraphic); |
216 |
} |
217 |
} |
218 |
getMapControl().drawGraphics(); |
219 |
} |
220 |
// Asignaci?n del siguiente estado
|
221 |
nextActiveChart = PANELLINEPROFILE; |
222 |
} |
223 |
else if(nextActiveChart == PANELLINEPROFILE){ |
224 |
//se actualizan las propiedades del gr?fico
|
225 |
getLineOptionsPanel().getJPanelChart(); |
226 |
getLineOptionsPanel().selectDrawRoiTool(); |
227 |
|
228 |
try {
|
229 |
int selectedRow = getLineOptionsPanel().getTable().getSelectedRow();
|
230 |
String roiName = (String)getLineOptionsPanel().getTable().getModel().getValueAt(selectedRow,0); |
231 |
VectorialROI roi = (VectorialROI)getLineOptionsPanel().getROI(roiName); |
232 |
roi.setBandToOperate(getLineOptionsPanel().getComboBands().getSelectedIndex()); |
233 |
getLineOptionsPanel().getTable().setSelectedIndex(0);
|
234 |
getLineOptionsPanel().getTable().updateUI(); |
235 |
|
236 |
GraphicLayer graphicLayer = mapControl.getMapContext().getGraphicsLayer(); |
237 |
// Se pintan las rois que existen en la tabla
|
238 |
ArrayList roisArray = getLineOptionsPanel().getROIs();
|
239 |
|
240 |
if (roisArray != null) { |
241 |
ISymbol symbol = null;
|
242 |
FGraphic fGraphic = null;
|
243 |
|
244 |
for (Iterator iter = roisArray.iterator(); iter.hasNext();) { |
245 |
ROI roiline = (ROI) iter.next(); |
246 |
VectorialROI vectorialROI = (VectorialROI) roiline; |
247 |
for (Iterator iterator = vectorialROI.getGeometries().iterator(); iterator.hasNext();) { |
248 |
IGeometry geometry = (IGeometry) iterator.next(); |
249 |
switch (geometry.getGeometryType()) {
|
250 |
case FShape.LINE:
|
251 |
symbol = SymbologyFactory.createDefaultLineSymbol(); |
252 |
((ILineSymbol) symbol).setLineColor(roiline.getColor()); |
253 |
break;
|
254 |
} |
255 |
fGraphic = new FGraphic(geometry, graphicLayer.addSymbol(symbol));
|
256 |
graphicLayer.addGraphic(fGraphic); |
257 |
getLineOptionsPanel().getRoiGraphics(roiline.getName()).add(fGraphic); |
258 |
} |
259 |
} |
260 |
getMapControl().drawGraphics(); |
261 |
} |
262 |
|
263 |
} catch (NotInitializeException e1) {
|
264 |
RasterToolsUtil.messageBoxError("tabla_no_inicializada", this, e1); |
265 |
} |
266 |
// Asignaci?n del siguiente estado
|
267 |
nextActiveChart= PANELZPROFILE; |
268 |
} |
269 |
} |
270 |
} |
271 |
|
272 |
/**
|
273 |
* @return entero que identifica el panel activo
|
274 |
* */
|
275 |
public int getActivePanel(){ |
276 |
return nextActiveChart;
|
277 |
} |
278 |
|
279 |
} |