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