root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / properties / panels / GeneralPanel.java @ 22364
History | View | Annotate | Download (22.6 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 IVER T.I. 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 |
package org.gvsig.rastertools.properties.panels; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Color; |
23 |
import java.awt.Dimension; |
24 |
import java.awt.GridBagConstraints; |
25 |
import java.awt.GridBagLayout; |
26 |
import java.awt.Insets; |
27 |
import java.awt.event.ActionEvent; |
28 |
import java.awt.event.ActionListener; |
29 |
import java.text.NumberFormat; |
30 |
|
31 |
import javax.swing.BorderFactory; |
32 |
import javax.swing.JButton; |
33 |
import javax.swing.JCheckBox; |
34 |
import javax.swing.JEditorPane; |
35 |
import javax.swing.JFormattedTextField; |
36 |
import javax.swing.JLabel; |
37 |
import javax.swing.JPanel; |
38 |
import javax.swing.JScrollPane; |
39 |
import javax.swing.border.TitledBorder; |
40 |
import javax.swing.text.DefaultFormatterFactory; |
41 |
import javax.swing.text.NumberFormatter; |
42 |
|
43 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
44 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
45 |
import org.gvsig.raster.Configuration; |
46 |
import org.gvsig.raster.IProcessActions; |
47 |
import org.gvsig.raster.RasterProcess; |
48 |
import org.gvsig.raster.dataset.properties.DatasetStatistics; |
49 |
import org.gvsig.raster.grid.GridTransparency; |
50 |
import org.gvsig.raster.hierarchy.IRasterProperties; |
51 |
import org.gvsig.raster.util.RasterToolsUtil; |
52 |
import org.gvsig.rastertools.properties.RasterPropertiesTocMenuEntry; |
53 |
import org.gvsig.rastertools.statistics.StatisticsProcess; |
54 |
|
55 |
import com.iver.andami.PluginServices; |
56 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
57 |
/**
|
58 |
* Este es el panel general de la ventana de propiedades. En el hemos metido
|
59 |
* todas aquellas opciones que no sabemos en que seccion meterlas.
|
60 |
*
|
61 |
* @version 15/04/2008
|
62 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
63 |
*/
|
64 |
public class GeneralPanel extends AbstractPanel implements ActionListener, INoDataPanel, IProcessActions { |
65 |
private static final long serialVersionUID = -4761218260868307869L; |
66 |
private FLayer fLayer = null; |
67 |
|
68 |
private JLabel labelNotShowLayer = null; |
69 |
private JLabel labelMinim = null; |
70 |
private JLabel labelMaxim = null; |
71 |
private JCheckBox checkBoxMinim = null; |
72 |
private JCheckBox checkBoxMaxim = null; |
73 |
private JFormattedTextField textFieldMinim = null; |
74 |
private JFormattedTextField textFieldMaxim = null; |
75 |
|
76 |
private NumberFormat doubleDisplayFormat = null; |
77 |
private NumberFormat doubleEditFormat = null; |
78 |
private double initMaxScale = -1; |
79 |
private double initMinScale = -1; |
80 |
|
81 |
private JButton calcButton = null; |
82 |
private JPanel scalePanel = null; |
83 |
private JPanel recalcStatsPanel = null; |
84 |
private NoDataPanel pNoDataPanel = null; |
85 |
private GridTransparency transparency = null; |
86 |
|
87 |
private JScrollPane jScrollPane = null; |
88 |
private JEditorPane jEditorPane = null; |
89 |
|
90 |
private final String bgColor0 = "\"#FEEDD6\""; // light salmon |
91 |
private final String bgColor1 = "\"#EAEAEA\""; // light grey |
92 |
private final String bgColor3 = "\"#FBFFE1\""; // light yellow |
93 |
private final String bgColor4 = "\"#D6D6D6\""; // Gris |
94 |
|
95 |
/**
|
96 |
* Booleano que est? a true cuando la fila a dibujar es par y a false cuando
|
97 |
* es impar.
|
98 |
*/
|
99 |
private boolean rowColor = true; |
100 |
|
101 |
|
102 |
/**
|
103 |
* Constructor del GeneralPanel
|
104 |
*/
|
105 |
public GeneralPanel() {
|
106 |
super();
|
107 |
setUpFormats(); |
108 |
initialize(); |
109 |
translate(); |
110 |
} |
111 |
|
112 |
/**
|
113 |
* Create and set up number formats. These objects also parse numbers input by
|
114 |
* user.
|
115 |
*/
|
116 |
private void setUpFormats() { |
117 |
doubleDisplayFormat = NumberFormat.getNumberInstance();
|
118 |
doubleDisplayFormat.setMinimumFractionDigits(0);
|
119 |
doubleEditFormat = NumberFormat.getNumberInstance();
|
120 |
} |
121 |
|
122 |
/**
|
123 |
* Asigna todos los textos del panel en su idioma correspondiente
|
124 |
*/
|
125 |
private void translate() { |
126 |
getJLabelNotShowLayer().setText(PluginServices.getText(this, "no_mostrar_la_capa_cuando_la_escala_sea") + ":"); |
127 |
getJLabelMinim().setText("(" + PluginServices.getText(this, "escala_minima") + ")"); |
128 |
getJLabelMaxim().setText("(" + PluginServices.getText(this, "escala_maxima") + ")"); |
129 |
getJCheckBoxMinim().setText(PluginServices.getText(this, "mayor_de") + " 1:"); |
130 |
getJCheckBoxMaxim().setText(PluginServices.getText(this, "menor_de") + " 1:"); |
131 |
getScalePanel().setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this, "rango_de_escalas"))); |
132 |
getRecalcStatsPanel().setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this, "stats"))); |
133 |
setLabel(PluginServices.getText(this, "general")); |
134 |
} |
135 |
|
136 |
/**
|
137 |
* Construye el panel
|
138 |
*/
|
139 |
protected void initialize() { |
140 |
GridBagConstraints gridBagConstraints;
|
141 |
setLayout(new GridBagLayout()); |
142 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
143 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
144 |
gridBagConstraints.weightx = 1.0;
|
145 |
add(getScalePanel(), gridBagConstraints); |
146 |
|
147 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
148 |
gridBagConstraints.gridx = 0;
|
149 |
gridBagConstraints.gridy = 1;
|
150 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
151 |
add(getNoDataPanel(), gridBagConstraints); |
152 |
|
153 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
154 |
gridBagConstraints.gridx = 0;
|
155 |
gridBagConstraints.gridy = 2;
|
156 |
gridBagConstraints.weighty = 1.0;
|
157 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
158 |
add(getRecalcStatsPanel(), gridBagConstraints); |
159 |
|
160 |
this.setPreferredSize(new Dimension(100, 80)); |
161 |
} |
162 |
|
163 |
/**
|
164 |
* This method initializes TranspOpacitySliderPanel
|
165 |
* @return javax.swing.JPanel
|
166 |
*/
|
167 |
public NoDataPanel getNoDataPanel() {
|
168 |
if (pNoDataPanel == null) { |
169 |
pNoDataPanel = new NoDataPanel(this); |
170 |
pNoDataPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "nodata"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
171 |
pNoDataPanel.setComboValueSetup(0);
|
172 |
} |
173 |
|
174 |
return pNoDataPanel;
|
175 |
} |
176 |
|
177 |
public JPanel getScalePanel() { |
178 |
if (scalePanel == null) { |
179 |
scalePanel = new JPanel(); |
180 |
scalePanel.setLayout(new GridBagLayout()); |
181 |
|
182 |
GridBagConstraints gridBagConstraints;
|
183 |
|
184 |
int y = 0; |
185 |
gridBagConstraints = new GridBagConstraints(); |
186 |
gridBagConstraints.gridx = 0;
|
187 |
gridBagConstraints.gridy = y; |
188 |
gridBagConstraints.gridwidth = 3;
|
189 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
190 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
191 |
scalePanel.add(getJLabelNotShowLayer(), gridBagConstraints); |
192 |
|
193 |
y++; |
194 |
gridBagConstraints = new GridBagConstraints(); |
195 |
gridBagConstraints.gridx = 0;
|
196 |
gridBagConstraints.gridy = y; |
197 |
gridBagConstraints.insets = new Insets(2, 2, 2, 0); |
198 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
199 |
scalePanel.add(getJCheckBoxMinim(), gridBagConstraints); |
200 |
|
201 |
gridBagConstraints = new GridBagConstraints(); |
202 |
gridBagConstraints.gridx = 1;
|
203 |
gridBagConstraints.gridy = y; |
204 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
205 |
gridBagConstraints.weightx = 1.0;
|
206 |
gridBagConstraints.insets = new Insets(2, 0, 2, 2); |
207 |
scalePanel.add(getJTextFieldMinim(), gridBagConstraints); |
208 |
|
209 |
gridBagConstraints = new GridBagConstraints(); |
210 |
gridBagConstraints.gridx = 2;
|
211 |
gridBagConstraints.gridy = y; |
212 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
213 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
214 |
scalePanel.add(getJLabelMinim(), gridBagConstraints); |
215 |
|
216 |
y++; |
217 |
gridBagConstraints = new GridBagConstraints(); |
218 |
gridBagConstraints.gridx = 0;
|
219 |
gridBagConstraints.gridy = y; |
220 |
gridBagConstraints.insets = new Insets(2, 2, 2, 0); |
221 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
222 |
scalePanel.add(getJCheckBoxMaxim(), gridBagConstraints); |
223 |
|
224 |
gridBagConstraints = new GridBagConstraints(); |
225 |
gridBagConstraints.gridx = 1;
|
226 |
gridBagConstraints.gridy = y; |
227 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
228 |
gridBagConstraints.weightx = 1.0;
|
229 |
gridBagConstraints.insets = new Insets(2, 0, 2, 2); |
230 |
scalePanel.add(getJTextFieldMaxim(), gridBagConstraints); |
231 |
|
232 |
gridBagConstraints = new GridBagConstraints(); |
233 |
gridBagConstraints.gridx = 2;
|
234 |
gridBagConstraints.gridy = y; |
235 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
236 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
237 |
scalePanel.add(getJLabelMaxim(), gridBagConstraints); |
238 |
|
239 |
y++; |
240 |
gridBagConstraints = new GridBagConstraints(); |
241 |
gridBagConstraints.gridx = 0;
|
242 |
gridBagConstraints.gridy = y; |
243 |
gridBagConstraints.gridwidth = 3;
|
244 |
gridBagConstraints.fill = GridBagConstraints.BOTH;
|
245 |
gridBagConstraints.weightx = 1.0;
|
246 |
gridBagConstraints.weighty = 1.0;
|
247 |
JPanel emptyPanel = new JPanel(); |
248 |
emptyPanel.setMinimumSize(new Dimension(0, 0)); |
249 |
scalePanel.add(emptyPanel, gridBagConstraints); |
250 |
} |
251 |
return scalePanel;
|
252 |
} |
253 |
|
254 |
public JPanel getRecalcStatsPanel() { |
255 |
if (recalcStatsPanel == null) { |
256 |
recalcStatsPanel = new JPanel(); |
257 |
recalcStatsPanel.setLayout(new BorderLayout(5, 5)); |
258 |
|
259 |
recalcStatsPanel.add(getJScrollPane(), BorderLayout.CENTER);
|
260 |
recalcStatsPanel.add(getCalcButton(), BorderLayout.SOUTH);
|
261 |
} |
262 |
return recalcStatsPanel;
|
263 |
} |
264 |
|
265 |
/**
|
266 |
* Bot?n para recalcular las estadisticas.
|
267 |
* @return JButton
|
268 |
*/
|
269 |
public JButton getCalcButton() { |
270 |
if(calcButton == null) { |
271 |
calcButton = new JButton(RasterToolsUtil.getText(this, "recalc_stats")); |
272 |
calcButton.addActionListener(this);
|
273 |
} |
274 |
return calcButton;
|
275 |
} |
276 |
|
277 |
private JLabel getJLabelNotShowLayer() { |
278 |
if (labelNotShowLayer == null) { |
279 |
labelNotShowLayer = new JLabel(); |
280 |
} |
281 |
return labelNotShowLayer;
|
282 |
} |
283 |
|
284 |
private JFormattedTextField getJTextFieldMinim() { |
285 |
if (textFieldMinim == null) { |
286 |
textFieldMinim = new JFormattedTextField(new DefaultFormatterFactory( |
287 |
new NumberFormatter(doubleDisplayFormat), |
288 |
new NumberFormatter(doubleDisplayFormat), |
289 |
new NumberFormatter(doubleEditFormat))); |
290 |
textFieldMinim.setEnabled(false);
|
291 |
textFieldMinim.setBackground(getBackground()); |
292 |
} |
293 |
return textFieldMinim;
|
294 |
} |
295 |
|
296 |
private JFormattedTextField getJTextFieldMaxim() { |
297 |
if (textFieldMaxim == null) { |
298 |
textFieldMaxim = new JFormattedTextField(new DefaultFormatterFactory( |
299 |
new NumberFormatter(doubleDisplayFormat), |
300 |
new NumberFormatter(doubleDisplayFormat), |
301 |
new NumberFormatter(doubleEditFormat))); |
302 |
textFieldMaxim.setEnabled(false);
|
303 |
textFieldMaxim.setBackground(getBackground()); |
304 |
} |
305 |
return textFieldMaxim;
|
306 |
} |
307 |
|
308 |
private JCheckBox getJCheckBoxMinim() { |
309 |
if (checkBoxMinim == null) { |
310 |
checkBoxMinim = new JCheckBox(); |
311 |
checkBoxMinim.addActionListener(this);
|
312 |
checkBoxMinim.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
313 |
checkBoxMinim.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
314 |
} |
315 |
return checkBoxMinim;
|
316 |
} |
317 |
|
318 |
private JLabel getJLabelMinim() { |
319 |
if (labelMinim == null) { |
320 |
labelMinim = new JLabel(); |
321 |
labelMinim.setEnabled(false);
|
322 |
} |
323 |
return labelMinim;
|
324 |
} |
325 |
|
326 |
private JCheckBox getJCheckBoxMaxim() { |
327 |
if (checkBoxMaxim == null) { |
328 |
checkBoxMaxim = new JCheckBox(); |
329 |
checkBoxMaxim.addActionListener(this);
|
330 |
checkBoxMaxim.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
331 |
checkBoxMaxim.setMargin(new java.awt.Insets(0, 0, 0, 0)); |
332 |
} |
333 |
return checkBoxMaxim;
|
334 |
} |
335 |
|
336 |
private JLabel getJLabelMaxim() { |
337 |
if (labelMaxim == null) { |
338 |
labelMaxim = new JLabel(); |
339 |
labelMaxim.setEnabled(false);
|
340 |
} |
341 |
return labelMaxim;
|
342 |
} |
343 |
|
344 |
/*
|
345 |
* (non-Javadoc)
|
346 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
347 |
*/
|
348 |
public void actionPerformed(ActionEvent e) { |
349 |
if (e.getSource() == getJCheckBoxMinim()) {
|
350 |
boolean enabled = getJCheckBoxMinim().isSelected();
|
351 |
getJLabelMinim().setEnabled(enabled); |
352 |
getJTextFieldMinim().setEnabled(enabled); |
353 |
getJTextFieldMinim().setBackground(enabled?Color.white: getBackground());
|
354 |
} |
355 |
|
356 |
if (e.getSource() == getCalcButton()) {
|
357 |
RasterProcess process = new StatisticsProcess();
|
358 |
process.addParam("layer", fLayer);
|
359 |
process.addParam("force", new Boolean(true)); |
360 |
process.setActions(this);
|
361 |
process.start(); |
362 |
} |
363 |
|
364 |
if (e.getSource() == getJCheckBoxMaxim()) {
|
365 |
boolean enabled = getJCheckBoxMaxim().isSelected();
|
366 |
getJLabelMaxim().setEnabled(enabled); |
367 |
getJTextFieldMaxim().setEnabled(enabled); |
368 |
getJTextFieldMaxim().setBackground(enabled?Color.white: getBackground());
|
369 |
} |
370 |
} |
371 |
|
372 |
/**
|
373 |
* Controla la alternatividad de colores en la tabla.
|
374 |
*
|
375 |
* @return Cadena con el color de la fila siguiente.
|
376 |
*/
|
377 |
private String getColor() { |
378 |
String color = (rowColor ? bgColor0 : bgColor1);
|
379 |
rowColor = !rowColor; |
380 |
return color;
|
381 |
} |
382 |
|
383 |
/**
|
384 |
* Obtiene una entrada de la tabla en formato HTML a partir de una propiedad,
|
385 |
* un valor y un color.
|
386 |
*
|
387 |
* @param prop
|
388 |
* Nombre de la propiedad
|
389 |
* @param value
|
390 |
* Valor
|
391 |
* @param color
|
392 |
* Color
|
393 |
*
|
394 |
* @return Entrada HTML de la tabla
|
395 |
*/
|
396 |
private String setHTMLBasicProperty(String prop, String value) { |
397 |
String content = "<tr valign=\"top\">"; |
398 |
if (prop != null) |
399 |
content += "<td bgcolor=" + bgColor4 + "align=\"right\" width=\"140\"><font face=\"Arial\" size=\"3\">" + prop + ": </font></td>"; |
400 |
content += "<td bgcolor=" + getColor() + "align=\"left\"><font face=\"Arial\" size=\"3\">" + value + "</font></td>"; |
401 |
content += "</tr>";
|
402 |
|
403 |
return content;
|
404 |
} |
405 |
|
406 |
/**
|
407 |
* Obtiene una cabecera de tabla en formato HTML a partir de un titulo.
|
408 |
*
|
409 |
* @param title
|
410 |
* Nombre del titulo
|
411 |
* @param colspan
|
412 |
* Numero de celdas que ocupara el titulo
|
413 |
*
|
414 |
* @return Entrada HTML del titulo
|
415 |
*/
|
416 |
private String setHTMLTitleTable(String title, int colspan) { |
417 |
return
|
418 |
"<tr valign=\"middle\" >" +
|
419 |
"<td bgcolor=" + bgColor3 + " align=\"center\" colspan=\"" + colspan + "\"><font face=\"Arial\" size=\"3\"><b> " + title + "</b></font></td>" + |
420 |
"</tr>";
|
421 |
} |
422 |
|
423 |
/**
|
424 |
* Obtiene una cabecera de tabla en formato HTML a partir de un titulo.
|
425 |
*
|
426 |
* @param content
|
427 |
* Codigo HTML de las filas que componen la tabla.
|
428 |
*
|
429 |
* @return Entrada HTML de la tabla completa
|
430 |
*/
|
431 |
private String setHTMLTable(String content) { |
432 |
return "<table cellpadding=\"0\" cellspacing=\"0\" align=\"center\" width=\"100%\">" + content + "</table>"; |
433 |
} |
434 |
|
435 |
|
436 |
/*
|
437 |
* (non-Javadoc)
|
438 |
* @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#setReference(java.lang.Object)
|
439 |
*/
|
440 |
public void setReference(Object ref) { |
441 |
super.setReference(ref);
|
442 |
|
443 |
if (!(ref instanceof FLayer)) |
444 |
return;
|
445 |
|
446 |
FLayer lyr = (FLayer) ref; |
447 |
|
448 |
if (lyr instanceof IRasterProperties) { |
449 |
fLayer = lyr; |
450 |
|
451 |
getNoDataPanel().setLayer((IRasterProperties) lyr); |
452 |
transparency = ((IRasterProperties) lyr).getRenderTransparency(); |
453 |
|
454 |
if (fLayer.getMaxScale() != -1) { |
455 |
initMaxScale = fLayer.getMaxScale(); |
456 |
getJTextFieldMaxim().setValue( |
457 |
Double.valueOf(fLayer.getMaxScale()));
|
458 |
getJCheckBoxMaxim().setSelected(true);
|
459 |
getJLabelMaxim().setEnabled(true);
|
460 |
getJTextFieldMaxim().setEnabled(true);
|
461 |
getJTextFieldMaxim().setBackground(Color.WHITE);
|
462 |
} |
463 |
|
464 |
if (fLayer.getMinScale() != -1) { |
465 |
initMinScale = fLayer.getMinScale(); |
466 |
getJTextFieldMinim().setValue( |
467 |
Double.valueOf(fLayer.getMinScale()));
|
468 |
getJCheckBoxMinim().setSelected(true);
|
469 |
getJLabelMinim().setEnabled(true);
|
470 |
getJTextFieldMinim().setEnabled(true);
|
471 |
getJTextFieldMinim().setBackground(Color.WHITE);
|
472 |
} |
473 |
} |
474 |
|
475 |
refreshHTMLStatistics(); |
476 |
saveStatus(); |
477 |
setValuesFromPanelToGridTransparency(); |
478 |
} |
479 |
|
480 |
/**
|
481 |
* Refresca el HTML del cuadro de texto de las estadisticas de todas las capas
|
482 |
*/
|
483 |
private void refreshHTMLStatistics() { |
484 |
String html = ""; |
485 |
DatasetStatistics statistics = ((FLyrRasterSE) fLayer).getDataSource().getStatistics(); |
486 |
((FLyrRasterSE) fLayer).getDataSource().getDataset(0)[0].loadObjectFromRmf(DatasetStatistics.class, statistics); |
487 |
|
488 |
if (statistics.isCalculated()) {
|
489 |
double[] maxRGB = statistics.getMaxRGB(); |
490 |
double[] max = statistics.getMax(); |
491 |
double[] minRGB = statistics.getMinRGB(); |
492 |
double[] min = statistics.getMin(); |
493 |
double[] variance = statistics.getVariance(); |
494 |
double[] mean = statistics.getMean(); |
495 |
|
496 |
for (int i=0; i<max.length; i++) { |
497 |
html += setHTMLTitleTable(RasterToolsUtil.getText(this, "band") + " " + (i + 1), 2); |
498 |
html += setHTMLBasicProperty(RasterToolsUtil.getText(this, "minimo"), Double.valueOf(min[i]).toString()); |
499 |
html += setHTMLBasicProperty(RasterToolsUtil.getText(this, "maximo"), Double.valueOf(max[i]).toString()); |
500 |
html += setHTMLBasicProperty(RasterToolsUtil.getText(this, "minimoRGB"), Double.valueOf(minRGB[i]).toString()); |
501 |
html += setHTMLBasicProperty(RasterToolsUtil.getText(this, "maximoRGB"), Double.valueOf(maxRGB[i]).toString()); |
502 |
html += setHTMLBasicProperty(RasterToolsUtil.getText(this, "media"), Double.valueOf(mean[i]).toString()); |
503 |
html += setHTMLBasicProperty(RasterToolsUtil.getText(this, "varianza"), Double.valueOf(variance[i]).toString()); |
504 |
} |
505 |
html = setHTMLTable(html); |
506 |
} else {
|
507 |
html += setHTMLTitleTable("Estadisticas no calculadas", 2); |
508 |
html = setHTMLTable(html); |
509 |
} |
510 |
getJEditorPane().setText(html); |
511 |
getJEditorPane().setCaretPosition(0);
|
512 |
} |
513 |
|
514 |
/**
|
515 |
* This method initializes jScrollPane
|
516 |
*
|
517 |
* @return javax.swing.JScrollPane
|
518 |
*/
|
519 |
private JScrollPane getJScrollPane() { |
520 |
if (jScrollPane == null) { |
521 |
jScrollPane = new JScrollPane(); |
522 |
jScrollPane.setViewportView(getJEditorPane()); |
523 |
} |
524 |
return jScrollPane;
|
525 |
} |
526 |
|
527 |
/**
|
528 |
* This method initializes jEditorPane
|
529 |
*
|
530 |
* @return javax.swing.JEditorPane
|
531 |
*/
|
532 |
private JEditorPane getJEditorPane() { |
533 |
if (jEditorPane == null) { |
534 |
jEditorPane = new JEditorPane(); |
535 |
jEditorPane.setEditable(false);
|
536 |
jEditorPane.setContentType("text/html");
|
537 |
} |
538 |
return jEditorPane;
|
539 |
} |
540 |
|
541 |
/*
|
542 |
* (non-Javadoc)
|
543 |
* @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#accept()
|
544 |
*/
|
545 |
public void accept() { |
546 |
onlyApply(); |
547 |
} |
548 |
|
549 |
/**
|
550 |
* Asigna los valores del panel a la transparencia de la capa.
|
551 |
*/
|
552 |
private void setValuesFromPanelToGridTransparency() { |
553 |
if (transparency == null) |
554 |
return;
|
555 |
|
556 |
if (fLayer == null) |
557 |
return;
|
558 |
|
559 |
((FLyrRasterSE) fLayer).getDataSource().setNoDataValue(getNoDataPanel().getNoDataValue()); |
560 |
((FLyrRasterSE) fLayer).getDataSource().setNoDataEnabled(getNoDataPanel().getComboSetupIndex() != 0);
|
561 |
|
562 |
transparency.setNoData(getNoDataPanel().getNoDataValue()); |
563 |
transparency.activeNoData(getNoDataPanel().getComboSetupIndex() != 0);
|
564 |
|
565 |
((FLyrRasterSE) fLayer).applyNoData(); |
566 |
|
567 |
((FLyrRasterSE) fLayer).setNoDataType(getNoDataPanel().getComboSetupIndex()); |
568 |
|
569 |
transparency.activeTransparency(); |
570 |
|
571 |
// Redibujamos
|
572 |
fLayer.getMapContext().invalidate(); |
573 |
} |
574 |
|
575 |
/**
|
576 |
* Aplica el estado del panel a la capa.
|
577 |
*/
|
578 |
public void onlyApply() { |
579 |
if (RasterPropertiesTocMenuEntry.enableEvents)
|
580 |
setValuesFromPanelToGridTransparency(); |
581 |
|
582 |
if (fLayer == null) |
583 |
return;
|
584 |
|
585 |
double maxScale = -1; |
586 |
double minScale = -1; |
587 |
|
588 |
if (getJCheckBoxMaxim().isSelected() && getJTextFieldMaxim().getValue() != null) |
589 |
maxScale = ((Number) getJTextFieldMaxim().getValue()).doubleValue();
|
590 |
|
591 |
if (getJCheckBoxMinim().isSelected() && getJTextFieldMinim().getValue() != null) |
592 |
minScale = ((Number) getJTextFieldMinim().getValue()).doubleValue();
|
593 |
|
594 |
fLayer.setMaxScale(maxScale); |
595 |
fLayer.setMinScale(minScale); |
596 |
} |
597 |
|
598 |
/*
|
599 |
* (non-Javadoc)
|
600 |
* @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#apply()
|
601 |
*/
|
602 |
public void apply() { |
603 |
onlyApply(); |
604 |
saveStatus(); |
605 |
} |
606 |
|
607 |
/**
|
608 |
* Guarda el estado actual del panel
|
609 |
*/
|
610 |
private void saveStatus() { |
611 |
getPanelGroup().getProperties().put("nodatavalue", new Double(getNoDataPanel().getNoDataValue())); |
612 |
getPanelGroup().getProperties().put("nodatatype", new Integer(((FLyrRasterSE) fLayer).getNoDataType())); |
613 |
} |
614 |
|
615 |
/**
|
616 |
* Restaura los valores de la capa conforme estaba al abrir el panel
|
617 |
*/
|
618 |
public void restoreStatus() { |
619 |
((FLyrRasterSE) fLayer).setNoDataValue(((Double) getPanelGroup().getProperties().get("nodatavalue")).doubleValue()); |
620 |
((FLyrRasterSE) fLayer).setNoDataType(((Integer) getPanelGroup().getProperties().get("nodatatype")).intValue()); |
621 |
|
622 |
fLayer.setMaxScale(initMaxScale); |
623 |
fLayer.setMinScale(initMinScale); |
624 |
} |
625 |
|
626 |
/*
|
627 |
* (non-Javadoc)
|
628 |
* @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#cancel()
|
629 |
*/
|
630 |
public void cancel() { |
631 |
restoreStatus(); |
632 |
} |
633 |
|
634 |
/**
|
635 |
* Actualiza los valores del panel noData
|
636 |
* @param noDataPanel
|
637 |
*/
|
638 |
public void RefreshValues(NoDataPanel noDataPanel) { |
639 |
if (fLayer == null) { |
640 |
noDataPanel.setEnabledComponents(false);
|
641 |
return;
|
642 |
} |
643 |
noDataPanel.setEnabledComponents(noDataPanel.getComboSetupIndex() == 2);
|
644 |
switch (noDataPanel.getComboSetupIndex()) {
|
645 |
case 0: // NoData desactivado |
646 |
noDataPanel.setNoDataValue(0);
|
647 |
break;
|
648 |
case 1: // Capa |
649 |
((FLyrRasterSE) fLayer).getDataSource().resetNoDataValue(); |
650 |
noDataPanel.setNoDataValue(((FLyrRasterSE) fLayer).getNoDataValue()); |
651 |
break;
|
652 |
case 2: // Personalizado |
653 |
noDataPanel.setNoDataValue(((Double) Configuration.getDefaultValue("nodata_value")).doubleValue()); |
654 |
break;
|
655 |
} |
656 |
} |
657 |
|
658 |
/*
|
659 |
* (non-Javadoc)
|
660 |
* @see org.gvsig.rastertools.properties.panels.INoDataPanel#BandStateChanged(org.gvsig.rastertools.properties.panels.NoDataPanel, int)
|
661 |
*/
|
662 |
public void BandStateChanged(NoDataPanel noDataPanel, int newIndex) { |
663 |
RefreshValues(noDataPanel); |
664 |
} |
665 |
|
666 |
/*
|
667 |
* (non-Javadoc)
|
668 |
* @see org.gvsig.rastertools.properties.panels.INoDataPanel#SourceStateChanged(org.gvsig.rastertools.properties.panels.NoDataPanel, int)
|
669 |
*/
|
670 |
public void SourceStateChanged(NoDataPanel noDataPanel, int newIndex) { |
671 |
RefreshValues(noDataPanel); |
672 |
} |
673 |
|
674 |
/*
|
675 |
* (non-Javadoc)
|
676 |
* @see org.gvsig.raster.IProcessActions#end(java.lang.Object)
|
677 |
*/
|
678 |
public void end(Object param) { |
679 |
refreshHTMLStatistics(); |
680 |
} |
681 |
|
682 |
public void selected() {} |
683 |
public void interrupted() {} |
684 |
} |