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