Revision 20310 trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/profiles/listener/LineProfileOptionsListener.java
LineProfileOptionsListener.java | ||
---|---|---|
67 | 67 |
import org.gvsig.raster.buffer.RasterBuffer; |
68 | 68 |
import org.gvsig.raster.grid.GridException; |
69 | 69 |
import org.gvsig.raster.grid.roi.ROI; |
70 |
import org.gvsig.raster.util.RasterToolsUtil; |
|
70 | 71 |
import org.gvsig.remotesensing.profiles.gui.LineProfileOptionsPanel; |
71 | 72 |
|
73 |
import com.iver.andami.PluginServices; |
|
72 | 74 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
73 | 75 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
74 | 76 |
import com.iver.cit.gvsig.fmap.layers.GraphicLayer; |
... | ... | |
77 | 79 |
public class LineProfileOptionsListener implements ButtonsPanelListener, ActionListener, ListSelectionListener, TableModelListener { |
78 | 80 |
|
79 | 81 |
LineProfileOptionsPanel optionsPanel = null; |
82 |
int createRois =0; |
|
80 | 83 |
|
84 |
/** |
|
85 |
* Constructor |
|
86 |
* */ |
|
81 | 87 |
public LineProfileOptionsListener( LineProfileOptionsPanel optionsPanel){ |
82 | 88 |
this.optionsPanel= optionsPanel; |
83 | 89 |
} |
... | ... | |
85 | 91 |
|
86 | 92 |
public void actionPerformed(ActionEvent e) { |
87 | 93 |
|
94 |
// Acciones a ejecutar cuando se crea una nueva entrada en la tabla |
|
95 |
// Construccion de la roi (vacia) que espera el dibujado de la geometria de tipo punto |
|
96 |
// selecci?n de la herramienta de dibujado de point |
|
97 |
|
|
88 | 98 |
if (e.getSource() == optionsPanel.getNewButton()){ |
89 | 99 |
try { |
90 |
String roiName= "";
|
|
91 |
roiName = "Line" + String.valueOf(optionsPanel.getTable().getRowCount());
|
|
100 |
String roiName = PluginServices.getText(this,"Line") + String.valueOf(createRois);
|
|
101 |
createRois++;
|
|
92 | 102 |
Object row [] = ((IModel)optionsPanel.getTable().getModel()).getNewLine(); |
93 | 103 |
row[0]= roiName; |
94 | 104 |
((DefaultTableModel)optionsPanel.getTable().getModel()).addRow(row); |
105 |
|
|
95 | 106 |
if (optionsPanel.getGrid()!=null){ |
96 | 107 |
ROI roi = new VectorialROI(optionsPanel.getGrid()); |
97 | 108 |
roi.setName(roiName); |
... | ... | |
99 | 110 |
optionsPanel.addROI(roi); |
100 | 111 |
} |
101 | 112 |
optionsPanel.getTable().setSelectedIndex(optionsPanel.getTable().getRowCount()-1); |
113 |
|
|
102 | 114 |
} catch (NotInitializeException e1) { |
103 |
e1.printStackTrace();
|
|
115 |
RasterToolsUtil.messageBoxError("tabla_no_inicializada", this, e1);
|
|
104 | 116 |
} |
105 | 117 |
optionsPanel.selectDrawRoiTool(); |
106 | 118 |
optionsPanel.getNewButton().setSelected(true); |
107 | 119 |
optionsPanel.getDeleteButton().setSelected(false); |
108 | 120 |
} |
109 | 121 |
|
122 |
// Seleccion de la banda cuyo perfil de linea se pretende representar. |
|
123 |
// Seleccionada la banda se actualiza la grafica y los datos en la tabla de la roi seleccionada |
|
110 | 124 |
if (e.getSource() == optionsPanel.getComboBands()){ |
125 |
|
|
111 | 126 |
try { |
112 | 127 |
if(optionsPanel.getTable().getRowCount()>0){ |
113 | 128 |
ROI lineRoi =(VectorialROI)optionsPanel.getROIs().get(optionsPanel.getTable().getSelectedRow()); |
114 | 129 |
int band = optionsPanel.getComboBands().getSelectedIndex(); |
115 | 130 |
drawChartRoi((VectorialROI)lineRoi,band); |
116 | 131 |
} |
132 |
|
|
117 | 133 |
} catch (NotInitializeException e1) { |
118 |
e1.printStackTrace();
|
|
134 |
RasterToolsUtil.messageBoxError("tabla_no_inicializada", this, e1);
|
|
119 | 135 |
} |
120 | 136 |
optionsPanel.selectDrawRoiTool(); |
121 |
optionsPanel.getNewButton().setSelected(true); |
|
122 |
optionsPanel.getDeleteButton().setSelected(false); |
|
123 | 137 |
} |
124 | 138 |
|
125 |
|
|
126 |
// Cada vez que se elimina una roi |
|
139 |
// Borrado de una roi |
|
127 | 140 |
if (e.getSource() == optionsPanel.getDeleteButton()){ |
128 | 141 |
optionsPanel.getDeleteButton().setSelected(false); |
129 | 142 |
try { |
... | ... | |
140 | 153 |
drawChartRoi((VectorialROI)lineRoi,band); |
141 | 154 |
} |
142 | 155 |
} |
156 |
|
|
143 | 157 |
} catch (NotInitializeException e2) { |
144 |
e2.printStackTrace();
|
|
158 |
RasterToolsUtil.messageBoxError("tabla_no_inicializada", this, e2);
|
|
145 | 159 |
} |
146 | 160 |
} |
147 | 161 |
} |
148 | 162 |
|
163 |
|
|
164 |
/** |
|
165 |
* Acciones cuando se produce una modificaci?n en la tabla |
|
166 |
* */ |
|
149 | 167 |
public void tableChanged(TableModelEvent e) { |
150 | 168 |
// Corregir segun cual sea definitivamente la columna asociada al color |
151 | 169 |
if(e.getColumn()==1){ |
... | ... | |
163 | 181 |
optionsPanel.getROI(roiName).setColor(color); |
164 | 182 |
optionsPanel.getMapControl().drawGraphics(); |
165 | 183 |
} |
166 |
|
|
167 | 184 |
optionsPanel.SetColorSeriesChart(); |
168 | 185 |
} |
169 | 186 |
} |
... | ... | |
171 | 188 |
|
172 | 189 |
public void valueChanged(ListSelectionEvent e) { |
173 | 190 |
try { |
174 |
if(optionsPanel.getTable().getSelectedRow()!=-1){ |
|
191 |
if(optionsPanel.getTable().getSelectedRow()!=-1){
|
|
175 | 192 |
ROI lineRoi =(VectorialROI)optionsPanel.getROIs().get(optionsPanel.getTable().getSelectedRow()); |
176 | 193 |
int band = optionsPanel.getComboBands().getSelectedIndex(); |
177 | 194 |
drawChartRoi((VectorialROI)lineRoi,band); |
178 | 195 |
} |
179 |
|
|
180 | 196 |
} catch (NotInitializeException e3) { |
181 |
e3.printStackTrace();
|
|
197 |
RasterToolsUtil.messageBoxError("tabla_no_inicializada", this, e3);
|
|
182 | 198 |
} |
183 |
|
|
184 | 199 |
} |
185 | 200 |
|
186 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
|
187 |
// TODO Auto-generated method stub |
|
188 |
|
|
189 |
} |
|
190 |
|
|
191 |
|
|
192 | 201 |
/** |
193 | 202 |
* Metodo que se encarga de pintar la roi que se pasa como parametro sobre el grafico. |
194 |
* La vanda de la que se tomar?n los valores es la que se pasa como par?metro.
|
|
203 |
* La banda de la que se tomar?n los valores es la que se pasa como par?metro.
|
|
195 | 204 |
* */ |
196 | 205 |
private void drawChartRoi(VectorialROI roi, int band){ |
197 |
|
|
198 | 206 |
try { |
199 |
|
|
200 | 207 |
int[][] series; |
201 | 208 |
series = new int[1][roi.getValues()]; |
202 | 209 |
String[] names = new String[1]; |
... | ... | |
274 | 281 |
optionsPanel.getTable().getModel().setValueAt(new Double(max), selectedRow, 2); |
275 | 282 |
optionsPanel.getTable().getModel().setValueAt(new Double(min), selectedRow, 3); |
276 | 283 |
optionsPanel.getTable().getModel().setValueAt(new Double(mean), selectedRow, 4); |
277 |
|
|
278 | 284 |
optionsPanel.updateUI(); |
279 | 285 |
} catch (GridException e) { |
280 |
e.printStackTrace();
|
|
286 |
RasterToolsUtil.messageBoxError(PluginServices.getText(this, "grid_error"), this, e);
|
|
281 | 287 |
} catch (NotInitializeException e) { |
282 |
// TODO Auto-generated catch block |
|
283 |
e.printStackTrace(); |
|
288 |
RasterToolsUtil.messageBoxError("tabla_no_inicializada", this, e); |
|
284 | 289 |
} |
290 |
} |
|
291 |
|
|
285 | 292 |
|
293 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
|
286 | 294 |
} |
287 |
|
|
295 |
|
|
288 | 296 |
} |
Also available in: Unified diff