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 | 14467 | bsanchez | /* 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 | 14846 | bsanchez | import java.awt.Color; |
23 | 14467 | bsanchez | 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 | 20117 | bsanchez | import javax.swing.JButton; |
33 | 14467 | bsanchez | import javax.swing.JCheckBox; |
34 | 20311 | bsanchez | import javax.swing.JEditorPane; |
35 | 14467 | bsanchez | import javax.swing.JFormattedTextField; |
36 | import javax.swing.JLabel; |
||
37 | import javax.swing.JPanel; |
||
38 | 20311 | bsanchez | import javax.swing.JScrollPane; |
39 | 20117 | bsanchez | import javax.swing.border.TitledBorder; |
40 | 14467 | bsanchez | import javax.swing.text.DefaultFormatterFactory; |
41 | import javax.swing.text.NumberFormatter; |
||
42 | |||
43 | 26368 | nbrodin | import org.gvsig.fmap.mapcontext.layers.FLayer; |
44 | 20117 | bsanchez | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
45 | 15781 | bsanchez | import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
46 | 20117 | bsanchez | import org.gvsig.raster.Configuration; |
47 | 20311 | bsanchez | import org.gvsig.raster.IProcessActions; |
48 | 23973 | nbrodin | import org.gvsig.raster.RasterLibrary; |
49 | 20117 | bsanchez | import org.gvsig.raster.RasterProcess; |
50 | 25192 | nbrodin | import org.gvsig.raster.dataset.properties.DatasetListStatistics; |
51 | 22475 | bsanchez | import org.gvsig.raster.dataset.serializer.RmfSerializerException; |
52 | 20117 | bsanchez | import org.gvsig.raster.grid.GridTransparency; |
53 | 14467 | bsanchez | import org.gvsig.raster.hierarchy.IRasterProperties; |
54 | 20117 | bsanchez | import org.gvsig.raster.util.RasterToolsUtil; |
55 | import org.gvsig.rastertools.properties.RasterPropertiesTocMenuEntry; |
||
56 | import org.gvsig.rastertools.statistics.StatisticsProcess; |
||
57 | 14467 | bsanchez | |
58 | import com.iver.andami.PluginServices; |
||
59 | /**
|
||
60 | 20117 | bsanchez | * 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 | 15804 | bsanchez | *
|
63 | 20117 | bsanchez | * @version 15/04/2008
|
64 | 14467 | bsanchez | * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
65 | */
|
||
66 | 20311 | bsanchez | public class GeneralPanel extends AbstractPanel implements ActionListener, INoDataPanel, IProcessActions { |
67 | 14467 | bsanchez | 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 | 20117 | bsanchez | 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 | 20311 | bsanchez | |
89 | private JScrollPane jScrollPane = null; |
||
90 | private JEditorPane jEditorPane = null; |
||
91 | 20117 | bsanchez | |
92 | 20311 | bsanchez | 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 | 20117 | bsanchez | /**
|
98 | 20311 | bsanchez | * 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 | 20117 | bsanchez | * Constructor del GeneralPanel
|
106 | */
|
||
107 | public GeneralPanel() {
|
||
108 | 15781 | bsanchez | super();
|
109 | 14467 | bsanchez | setUpFormats(); |
110 | 15781 | bsanchez | initialize(); |
111 | 14467 | bsanchez | translate(); |
112 | } |
||
113 | |||
114 | 15804 | bsanchez | /**
|
115 | 14467 | bsanchez | * Create and set up number formats. These objects also parse numbers input by
|
116 | * user.
|
||
117 | */
|
||
118 | 15804 | bsanchez | private void setUpFormats() { |
119 | 14467 | bsanchez | doubleDisplayFormat = NumberFormat.getNumberInstance();
|
120 | doubleDisplayFormat.setMinimumFractionDigits(0);
|
||
121 | doubleEditFormat = NumberFormat.getNumberInstance();
|
||
122 | 15804 | bsanchez | } |
123 | 14467 | bsanchez | |
124 | 20117 | bsanchez | /**
|
125 | * Asigna todos los textos del panel en su idioma correspondiente
|
||
126 | */
|
||
127 | 14467 | bsanchez | private void translate() { |
128 | getJLabelNotShowLayer().setText(PluginServices.getText(this, "no_mostrar_la_capa_cuando_la_escala_sea") + ":"); |
||
129 | 23809 | nbrodin | getJLabelMinim().setText("(" + PluginServices.getText(this, "escala_maxima") + ")"); |
130 | getJLabelMaxim().setText("(" + PluginServices.getText(this, "escala_minima") + ")"); |
||
131 | 14467 | bsanchez | getJCheckBoxMinim().setText(PluginServices.getText(this, "mayor_de") + " 1:"); |
132 | getJCheckBoxMaxim().setText(PluginServices.getText(this, "menor_de") + " 1:"); |
||
133 | 20117 | bsanchez | 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 | 14467 | bsanchez | } |
137 | |||
138 | 20117 | bsanchez | /**
|
139 | * Construye el panel
|
||
140 | */
|
||
141 | 15804 | bsanchez | protected void initialize() { |
142 | GridBagConstraints gridBagConstraints;
|
||
143 | 20117 | bsanchez | 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 | 17047 | nbrodin | |
149 | 20117 | bsanchez | gridBagConstraints = new java.awt.GridBagConstraints();
|
150 | 15804 | bsanchez | gridBagConstraints.gridx = 0;
|
151 | 20117 | bsanchez | gridBagConstraints.gridy = 1;
|
152 | gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
||
153 | 22364 | nbrodin | add(getNoDataPanel(), gridBagConstraints); |
154 | 14467 | bsanchez | |
155 | 20117 | bsanchez | gridBagConstraints = new java.awt.GridBagConstraints();
|
156 | 15804 | bsanchez | gridBagConstraints.gridx = 0;
|
157 | 20117 | bsanchez | gridBagConstraints.gridy = 2;
|
158 | 20311 | bsanchez | gridBagConstraints.weighty = 1.0;
|
159 | gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
||
160 | 20117 | bsanchez | 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 | 22364 | nbrodin | pNoDataPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "nodata"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
173 | 20117 | bsanchez | pNoDataPanel.setComboValueSetup(0);
|
174 | } |
||
175 | 14467 | bsanchez | |
176 | 20117 | bsanchez | 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 | 14467 | bsanchez | |
186 | 20117 | bsanchez | 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 | 14467 | bsanchez | |
195 | 20117 | bsanchez | 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 | 14467 | bsanchez | |
203 | 20117 | bsanchez | 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 | 14467 | bsanchez | |
211 | 20117 | bsanchez | 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 | 14467 | bsanchez | |
218 | 20117 | bsanchez | 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 | 14467 | bsanchez | |
226 | 20117 | bsanchez | 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 | 15804 | bsanchez | } |
255 | |||
256 | 20117 | bsanchez | public JPanel getRecalcStatsPanel() { |
257 | if (recalcStatsPanel == null) { |
||
258 | recalcStatsPanel = new JPanel(); |
||
259 | 20311 | bsanchez | recalcStatsPanel.setLayout(new BorderLayout(5, 5)); |
260 | |||
261 | recalcStatsPanel.add(getJScrollPane(), BorderLayout.CENTER);
|
||
262 | recalcStatsPanel.add(getCalcButton(), BorderLayout.SOUTH);
|
||
263 | 15804 | bsanchez | } |
264 | 20117 | bsanchez | return recalcStatsPanel;
|
265 | 15804 | bsanchez | } |
266 | |||
267 | 20117 | bsanchez | /**
|
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 | 20311 | bsanchez | calcButton.addActionListener(this);
|
275 | 20117 | bsanchez | } |
276 | return calcButton;
|
||
277 | } |
||
278 | |||
279 | 14467 | bsanchez | 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 | 15804 | bsanchez | new NumberFormatter(doubleDisplayFormat), |
290 | new NumberFormatter(doubleDisplayFormat), |
||
291 | new NumberFormatter(doubleEditFormat))); |
||
292 | 14467 | bsanchez | textFieldMinim.setEnabled(false);
|
293 | 14846 | bsanchez | textFieldMinim.setBackground(getBackground()); |
294 | 14467 | bsanchez | } |
295 | return textFieldMinim;
|
||
296 | } |
||
297 | |||
298 | private JFormattedTextField getJTextFieldMaxim() { |
||
299 | if (textFieldMaxim == null) { |
||
300 | textFieldMaxim = new JFormattedTextField(new DefaultFormatterFactory( |
||
301 | 15804 | bsanchez | new NumberFormatter(doubleDisplayFormat), |
302 | new NumberFormatter(doubleDisplayFormat), |
||
303 | new NumberFormatter(doubleEditFormat))); |
||
304 | 14467 | bsanchez | textFieldMaxim.setEnabled(false);
|
305 | 14846 | bsanchez | textFieldMaxim.setBackground(getBackground()); |
306 | 14467 | bsanchez | } |
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 | 14846 | bsanchez | getJTextFieldMinim().setBackground(enabled?Color.white: getBackground());
|
356 | 14467 | bsanchez | } |
357 | |||
358 | 20311 | bsanchez | 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 | 14467 | bsanchez | if (e.getSource() == getJCheckBoxMaxim()) {
|
367 | boolean enabled = getJCheckBoxMaxim().isSelected();
|
||
368 | getJLabelMaxim().setEnabled(enabled); |
||
369 | getJTextFieldMaxim().setEnabled(enabled); |
||
370 | 14846 | bsanchez | getJTextFieldMaxim().setBackground(enabled?Color.white: getBackground());
|
371 | 14467 | bsanchez | } |
372 | 15804 | bsanchez | } |
373 | 14467 | bsanchez | |
374 | 20311 | bsanchez | /**
|
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 | 20117 | bsanchez | /*
|
439 | * (non-Javadoc)
|
||
440 | * @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#setReference(java.lang.Object)
|
||
441 | */
|
||
442 | 15781 | bsanchez | public void setReference(Object ref) { |
443 | super.setReference(ref);
|
||
444 | 15804 | bsanchez | |
445 | 15781 | bsanchez | if (!(ref instanceof FLayer)) |
446 | return;
|
||
447 | 15804 | bsanchez | |
448 | 15781 | bsanchez | FLayer lyr = (FLayer) ref; |
449 | 14467 | bsanchez | |
450 | if (lyr instanceof IRasterProperties) { |
||
451 | fLayer = lyr; |
||
452 | |||
453 | 20117 | bsanchez | getNoDataPanel().setLayer((IRasterProperties) lyr); |
454 | transparency = ((IRasterProperties) lyr).getRenderTransparency(); |
||
455 | |||
456 | 14467 | bsanchez | if (fLayer.getMaxScale() != -1) { |
457 | initMaxScale = fLayer.getMaxScale(); |
||
458 | 15781 | bsanchez | getJTextFieldMaxim().setValue( |
459 | Double.valueOf(fLayer.getMaxScale()));
|
||
460 | 14467 | bsanchez | getJCheckBoxMaxim().setSelected(true);
|
461 | getJLabelMaxim().setEnabled(true);
|
||
462 | getJTextFieldMaxim().setEnabled(true);
|
||
463 | 14846 | bsanchez | getJTextFieldMaxim().setBackground(Color.WHITE);
|
464 | 14467 | bsanchez | } |
465 | |||
466 | if (fLayer.getMinScale() != -1) { |
||
467 | initMinScale = fLayer.getMinScale(); |
||
468 | 15781 | bsanchez | getJTextFieldMinim().setValue( |
469 | Double.valueOf(fLayer.getMinScale()));
|
||
470 | 14467 | bsanchez | getJCheckBoxMinim().setSelected(true);
|
471 | getJLabelMinim().setEnabled(true);
|
||
472 | getJTextFieldMinim().setEnabled(true);
|
||
473 | 14846 | bsanchez | getJTextFieldMinim().setBackground(Color.WHITE);
|
474 | 14467 | bsanchez | } |
475 | } |
||
476 | 20117 | bsanchez | |
477 | 20311 | bsanchez | refreshHTMLStatistics(); |
478 | 20117 | bsanchez | saveStatus(); |
479 | setValuesFromPanelToGridTransparency(); |
||
480 | 14467 | bsanchez | } |
481 | 25192 | nbrodin | |
482 | 20311 | bsanchez | /**
|
483 | * Refresca el HTML del cuadro de texto de las estadisticas de todas las capas
|
||
484 | */
|
||
485 | private void refreshHTMLStatistics() { |
||
486 | String html = ""; |
||
487 | 25192 | nbrodin | DatasetListStatistics statistics = null;
|
488 | 22475 | bsanchez | try {
|
489 | 25192 | nbrodin | statistics = DatasetListStatistics.loadDatasetListStatistics(((FLyrRasterSE) fLayer).getDataSource()); |
490 | 22475 | bsanchez | } catch (RmfSerializerException e) {
|
491 | // Si no las consigue cargar no las mostrar?
|
||
492 | 25342 | nbrodin | return;
|
493 | 22475 | bsanchez | } |
494 | 22309 | bsanchez | |
495 | 20311 | bsanchez | 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 | 14467 | bsanchez | |
548 | /*
|
||
549 | * (non-Javadoc)
|
||
550 | * @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#accept()
|
||
551 | */
|
||
552 | public void accept() { |
||
553 | 20117 | bsanchez | 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 | 14467 | bsanchez | if (fLayer == null) |
564 | return;
|
||
565 | |||
566 | 20120 | bsanchez | ((FLyrRasterSE) fLayer).getDataSource().setNoDataValue(getNoDataPanel().getNoDataValue()); |
567 | ((FLyrRasterSE) fLayer).getDataSource().setNoDataEnabled(getNoDataPanel().getComboSetupIndex() != 0);
|
||
568 | 20117 | bsanchez | |
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 | 14467 | bsanchez | double maxScale = -1; |
593 | double minScale = -1; |
||
594 | 15804 | bsanchez | |
595 | 20276 | bsanchez | if (getJCheckBoxMaxim().isSelected() && getJTextFieldMaxim().getValue() != null) |
596 | 14467 | bsanchez | maxScale = ((Number) getJTextFieldMaxim().getValue()).doubleValue();
|
597 | |||
598 | 20276 | bsanchez | if (getJCheckBoxMinim().isSelected() && getJTextFieldMinim().getValue() != null) |
599 | 14467 | bsanchez | 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 | 20117 | bsanchez | onlyApply(); |
611 | saveStatus(); |
||
612 | 15804 | bsanchez | } |
613 | 20117 | bsanchez | |
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 | 14467 | bsanchez | |
622 | 20117 | bsanchez | /**
|
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 | 14467 | bsanchez | /*
|
634 | * (non-Javadoc)
|
||
635 | * @see org.gvsig.raster.gui.properties.dialog.IRegistrablePanel#cancel()
|
||
636 | */
|
||
637 | public void cancel() { |
||
638 | 20117 | bsanchez | restoreStatus(); |
639 | 15804 | bsanchez | } |
640 | 15781 | bsanchez | |
641 | 20117 | bsanchez | /**
|
642 | * Actualiza los valores del panel noData
|
||
643 | * @param noDataPanel
|
||
644 | */
|
||
645 | 23773 | nbrodin | public void refreshValues(NoDataPanel noDataPanel) { |
646 | 20117 | bsanchez | 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 | 23973 | nbrodin | noDataPanel.setNoDataValue(((Double)Configuration.getValue("nodata_value", new Double(RasterLibrary.defaultNoDataValue))).doubleValue()); |
661 | 20117 | bsanchez | break;
|
662 | } |
||
663 | 15781 | bsanchez | } |
664 | 20117 | bsanchez | |
665 | /*
|
||
666 | * (non-Javadoc)
|
||
667 | * @see org.gvsig.rastertools.properties.panels.INoDataPanel#BandStateChanged(org.gvsig.rastertools.properties.panels.NoDataPanel, int)
|
||
668 | */
|
||
669 | 23773 | nbrodin | public void bandStateChanged(NoDataPanel noDataPanel, int newIndex) { |
670 | refreshValues(noDataPanel); |
||
671 | 20117 | bsanchez | } |
672 | |||
673 | /*
|
||
674 | * (non-Javadoc)
|
||
675 | * @see org.gvsig.rastertools.properties.panels.INoDataPanel#SourceStateChanged(org.gvsig.rastertools.properties.panels.NoDataPanel, int)
|
||
676 | */
|
||
677 | 23773 | nbrodin | public void sourceStateChanged(NoDataPanel noDataPanel, int newIndex) { |
678 | refreshValues(noDataPanel); |
||
679 | 20117 | bsanchez | } |
680 | |||
681 | 20311 | bsanchez | /*
|
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 | 20117 | bsanchez | public void selected() {} |
690 | 20311 | bsanchez | public void interrupted() {} |
691 | 14467 | bsanchez | } |