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