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