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