root / trunk / extensions / ext3Dgui / src / com / iver / ai2 / gvsig3dgui / layer / properties / VectorialLayerPanel3D.java @ 21925
History | View | Annotate | Download (11 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
|
20 |
package com.iver.ai2.gvsig3dgui.layer.properties; |
21 |
|
22 |
|
23 |
import java.awt.BorderLayout; |
24 |
import java.awt.Dimension; |
25 |
import java.awt.GridBagConstraints; |
26 |
import java.awt.GridBagLayout; |
27 |
import java.awt.Insets; |
28 |
import java.awt.event.ItemEvent; |
29 |
import java.awt.event.ItemListener; |
30 |
|
31 |
import javax.swing.JCheckBox; |
32 |
import javax.swing.JPanel; |
33 |
import javax.swing.border.TitledBorder; |
34 |
|
35 |
import org.gvsig.gui.beans.datainput.DataInputContainer; |
36 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
37 |
|
38 |
import com.hardcode.gdbms.engine.values.IntValue; |
39 |
import com.iver.ai2.gvsig3d.map3d.MapContext3D; |
40 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
41 |
import com.iver.andami.PluginServices; |
42 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
43 |
import com.iver.cit.gvsig.fmap.layers.FLyrWMS; |
44 |
|
45 |
|
46 |
/**
|
47 |
* Tab with vectorial options in properties 3D panel.
|
48 |
* @version
|
49 |
* @author ?ngel Fraile Gri??n.(angel.fraile@iver.es)
|
50 |
*/
|
51 |
|
52 |
public class VectorialLayerPanel3D extends AbstractPanel implements ItemListener { |
53 |
|
54 |
private static final long serialVersionUID = -4145789119404234621L; |
55 |
|
56 |
/**
|
57 |
* <p>Element for the interface.</p>
|
58 |
*/
|
59 |
|
60 |
private JPanel panelOptionsGlob; |
61 |
private JPanel panelOptionsDetail; |
62 |
private JPanel panelOptionsRast; |
63 |
private JCheckBox rasterOption; |
64 |
private JCheckBox zOption; |
65 |
private JCheckBox detailVector; |
66 |
private Layer3DProps props3D;
|
67 |
private TitledBorder borderOptionsRast; |
68 |
private DataInputContainer textFieldHeigth;
|
69 |
private VectorialLayerListener3D vectorialLayerListener3D;
|
70 |
final int integerMaxValue = 2147483647; |
71 |
|
72 |
|
73 |
private TitledBorder borderOptionsOff; |
74 |
|
75 |
/**
|
76 |
* @see AbstractPanel#AbstractPanel()
|
77 |
*/
|
78 |
public VectorialLayerPanel3D() {
|
79 |
super();
|
80 |
initialize(); |
81 |
} |
82 |
|
83 |
/**
|
84 |
* @see AbstractPanel#AbstractPanel(String, String, String)
|
85 |
*/
|
86 |
public VectorialLayerPanel3D(String id, String label, String labelGroup) { |
87 |
super(id, label, labelGroup);
|
88 |
initialize(); |
89 |
} |
90 |
|
91 |
private VectorialLayerListener3D getVectorialLayerListener3D() {
|
92 |
if (vectorialLayerListener3D == null) { |
93 |
vectorialLayerListener3D = new VectorialLayerListener3D(this); |
94 |
} |
95 |
return vectorialLayerListener3D;
|
96 |
} |
97 |
|
98 |
protected void initialize() { |
99 |
setLabel(PluginServices.getText(this, PluginServices.getText(this, "Capa_Vectorial"))); |
100 |
setLabelGroup(PluginServices.getText(this,PluginServices.getText(this, "Propiedades_3D"))); |
101 |
setPreferredSize(new Dimension(500, 400)); |
102 |
resetChangedStatus(); |
103 |
panelOptionsGlob = new JPanel(); |
104 |
panelOptionsGlob.setLayout(new GridBagLayout()); |
105 |
|
106 |
GridBagConstraints gbc = new GridBagConstraints(); |
107 |
gbc.fill = GridBagConstraints.HORIZONTAL;
|
108 |
gbc.weightx = 1.0;
|
109 |
gbc.insets = new Insets(0, 0, 0, 0); |
110 |
panelOptionsGlob.add(panelRaster(), gbc); |
111 |
|
112 |
gbc = new GridBagConstraints(); |
113 |
gbc.gridy = 1;
|
114 |
gbc.fill = GridBagConstraints.BOTH;
|
115 |
gbc.weighty = 1.0;
|
116 |
panelOptionsGlob.add(panelDetail(), gbc); |
117 |
|
118 |
this.setLayout(new BorderLayout()); |
119 |
this.add(panelOptionsGlob, BorderLayout.CENTER); |
120 |
|
121 |
} |
122 |
|
123 |
private JPanel panelRaster() { |
124 |
|
125 |
if (panelOptionsRast == null) { |
126 |
panelOptionsRast = new JPanel(); |
127 |
borderOptionsRast = new TitledBorder(PluginServices.getText(this, "Opciones")); |
128 |
panelOptionsRast.setLayout(new GridBagLayout()); |
129 |
panelOptionsRast.setBorder(this.borderOptionsRast);
|
130 |
|
131 |
GridBagConstraints gbc = new GridBagConstraints(); |
132 |
gbc.fill = GridBagConstraints.HORIZONTAL;
|
133 |
gbc.weightx = 1;
|
134 |
gbc.insets = new Insets(0, 0, 10, 0); |
135 |
panelOptionsRast.add(getJCheckBoxRaster(),gbc); |
136 |
|
137 |
gbc = new GridBagConstraints(); |
138 |
gbc.fill = GridBagConstraints.HORIZONTAL;
|
139 |
gbc.gridy = 1;
|
140 |
panelOptionsRast.add(getJCheckBoxValueZ(),gbc); |
141 |
|
142 |
gbc = new GridBagConstraints(); |
143 |
gbc.fill = GridBagConstraints.HORIZONTAL;
|
144 |
gbc.gridy = 2;
|
145 |
panelOptionsRast.add(getLabelText(), gbc); |
146 |
|
147 |
gbc = new GridBagConstraints(); |
148 |
gbc.weighty = 1.0;
|
149 |
gbc.gridy = 3;
|
150 |
panelOptionsRast.add(new JPanel(), gbc); |
151 |
} |
152 |
return panelOptionsRast;
|
153 |
} |
154 |
|
155 |
|
156 |
|
157 |
private JPanel panelDetail() { |
158 |
|
159 |
if (panelOptionsDetail == null) { |
160 |
|
161 |
panelOptionsDetail = new JPanel(); |
162 |
borderOptionsOff = new TitledBorder(PluginServices.getText(this, "Nivel_de_detalle")); |
163 |
panelOptionsDetail.setLayout(new GridBagLayout()); |
164 |
panelOptionsDetail.setBorder(this.borderOptionsOff);
|
165 |
|
166 |
GridBagConstraints gbc = new GridBagConstraints(); |
167 |
gbc.fill = GridBagConstraints.HORIZONTAL;
|
168 |
gbc.weightx = 1;
|
169 |
gbc.insets = new Insets(0, 0, 10, 0); |
170 |
panelOptionsDetail.add(getJCheckBoxDetail(),gbc); |
171 |
|
172 |
gbc = new GridBagConstraints(); |
173 |
gbc = new GridBagConstraints(); |
174 |
gbc.weighty = 1.0;
|
175 |
gbc.gridy = 1;
|
176 |
panelOptionsDetail.add(new JPanel(), gbc); |
177 |
} |
178 |
return panelOptionsDetail;
|
179 |
} |
180 |
|
181 |
|
182 |
|
183 |
|
184 |
/**
|
185 |
* @return JCheckbox. Return the checkbox of selection of image options
|
186 |
*/
|
187 |
private JCheckBox getJCheckBoxDetail() { |
188 |
if (detailVector == null) { |
189 |
detailVector = new JCheckBox( |
190 |
PluginServices.getText(this, "Activar"), false); |
191 |
detailVector.addItemListener(this);
|
192 |
detailVector.setEnabled(false);
|
193 |
} |
194 |
return detailVector;
|
195 |
} |
196 |
|
197 |
|
198 |
/*
|
199 |
* Enabled options depending the Layer3DProps
|
200 |
*/
|
201 |
private void controlEnabled() |
202 |
{ |
203 |
if(props3D.getType() == 0) { |
204 |
if (getLayer() instanceof FLyrWMS) { |
205 |
textFieldHeigth.setControlEnabled(false);
|
206 |
rasterOption.setSelected(true);
|
207 |
rasterOption.setEnabled(false);
|
208 |
zOption.setEnabled(false);
|
209 |
} |
210 |
else {
|
211 |
textFieldHeigth.setControlEnabled(false);
|
212 |
rasterOption.setEnabled(true);
|
213 |
rasterOption.setSelected(true);
|
214 |
zOption.setEnabled(false);
|
215 |
} |
216 |
|
217 |
detailVector.setEnabled(true);
|
218 |
int order = props3D.getTocOrder();
|
219 |
int aux = this.getMapContext().getPlanet().getMaxTextureResolution(order); |
220 |
if(aux < integerMaxValue ) {
|
221 |
detailVector.setSelected(true);
|
222 |
} |
223 |
|
224 |
} |
225 |
else if(props3D.isZEnable()) { |
226 |
|
227 |
textFieldHeigth.setControlEnabled(false);
|
228 |
rasterOption.setEnabled(false);
|
229 |
zOption.setEnabled(true);
|
230 |
zOption.setSelected(true);
|
231 |
} |
232 |
else {
|
233 |
textFieldHeigth.setControlEnabled(true);
|
234 |
rasterOption.setEnabled(true);
|
235 |
zOption.setEnabled(true);
|
236 |
} |
237 |
} |
238 |
|
239 |
/*
|
240 |
* Height layer data input container
|
241 |
*/
|
242 |
|
243 |
private DataInputContainer getLabelText() {
|
244 |
if(textFieldHeigth == null) |
245 |
{ |
246 |
textFieldHeigth = new DataInputContainer();
|
247 |
textFieldHeigth.setLabelText(PluginServices.getText(this,"Altura_en_metros")); |
248 |
textFieldHeigth.setValue(this.getMyHeight());
|
249 |
} |
250 |
|
251 |
return textFieldHeigth;
|
252 |
} |
253 |
|
254 |
/*
|
255 |
* Getting the actual layer height
|
256 |
* @return String.
|
257 |
*/
|
258 |
public String getMyHeight() { |
259 |
String elevation = "0"; |
260 |
try {
|
261 |
float alt = props3D.getHeigth();
|
262 |
elevation = Float.toString(alt);
|
263 |
} |
264 |
catch (Exception e) { |
265 |
|
266 |
} |
267 |
return elevation;
|
268 |
} |
269 |
|
270 |
/*
|
271 |
* @return JCheckbox rasterOption
|
272 |
*
|
273 |
*/
|
274 |
private JCheckBox getJCheckBoxRaster() { |
275 |
if (rasterOption == null) { |
276 |
rasterOption = new JCheckBox( |
277 |
PluginServices.getText(this, "Raster_layer"), false); |
278 |
rasterOption.addItemListener(this);
|
279 |
} |
280 |
return rasterOption;
|
281 |
} |
282 |
|
283 |
/**
|
284 |
* @return JCheckbox zOptions
|
285 |
*
|
286 |
*/
|
287 |
|
288 |
private JCheckBox getJCheckBoxValueZ() { |
289 |
if (zOption == null) { |
290 |
zOption = new JCheckBox(PluginServices.getText(this, "Heigth_Z"), |
291 |
false);
|
292 |
zOption.addItemListener(this);
|
293 |
} |
294 |
return zOption;
|
295 |
} |
296 |
|
297 |
|
298 |
public void selected() { |
299 |
|
300 |
} |
301 |
|
302 |
/**
|
303 |
* Logic with active or inactive options
|
304 |
*/
|
305 |
|
306 |
public void itemStateChanged(ItemEvent e) { |
307 |
|
308 |
zOption.setEnabled(!rasterOption.isSelected()); |
309 |
rasterOption.setEnabled(!zOption.isSelected()); |
310 |
textFieldHeigth.setControlEnabled(!(zOption.isSelected()) && !(rasterOption.isSelected())); |
311 |
|
312 |
if(!detailVector.isSelected()) {
|
313 |
int order = props3D.getTocOrder();
|
314 |
int aux = this.getMapContext().getPlanet().getMaxTextureResolution(order); |
315 |
if(aux != integerMaxValue) {
|
316 |
this.getMapContext().getPlanet().setMaxTextureResolution(order, integerMaxValue);
|
317 |
} |
318 |
} |
319 |
} |
320 |
|
321 |
|
322 |
/*
|
323 |
* Calling the listener
|
324 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept()
|
325 |
*/
|
326 |
public void accept() { |
327 |
getVectorialLayerListener3D().accept(); |
328 |
} |
329 |
|
330 |
/*
|
331 |
* Calling the listener
|
332 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept()
|
333 |
*/
|
334 |
public void apply() { |
335 |
getVectorialLayerListener3D().apply(); |
336 |
} |
337 |
|
338 |
/*
|
339 |
* Calling the listener
|
340 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept()
|
341 |
*/
|
342 |
public void cancel() { |
343 |
getVectorialLayerListener3D().cancel(); |
344 |
} |
345 |
|
346 |
|
347 |
/**
|
348 |
* Option raster selected
|
349 |
* @return boolean
|
350 |
*/
|
351 |
public boolean isRasterOptionSelected() { |
352 |
return getJCheckBoxRaster().isSelected();
|
353 |
} |
354 |
|
355 |
/**
|
356 |
* Option to work with Z values
|
357 |
* @return boolean
|
358 |
*/
|
359 |
public boolean isZValueSelected() { |
360 |
return getJCheckBoxValueZ().isSelected();
|
361 |
} |
362 |
|
363 |
/**
|
364 |
* Option level of detail selected
|
365 |
* @return boolean
|
366 |
*/
|
367 |
public boolean isDetailOptionSelected() { |
368 |
return getJCheckBoxDetail().isSelected();
|
369 |
} |
370 |
|
371 |
/**
|
372 |
* Getting the user height introduced
|
373 |
* @return actual height
|
374 |
*/
|
375 |
public String getJTextFieldHeight() { |
376 |
return textFieldHeigth.getValue();
|
377 |
} |
378 |
|
379 |
/**
|
380 |
* Getting the 3D properties
|
381 |
* @return Layer3DProps
|
382 |
*/
|
383 |
public Layer3DProps getLayer3DProps() {
|
384 |
return props3D;
|
385 |
} |
386 |
|
387 |
/**
|
388 |
* Getting the map context
|
389 |
* @return MapContext3D
|
390 |
*/
|
391 |
public MapContext3D getMapContext() {
|
392 |
FLayer fl = (FLayer)this.getReference();
|
393 |
MapContext3D mc = (MapContext3D)fl.getMapContext(); |
394 |
return mc;
|
395 |
} |
396 |
|
397 |
/**
|
398 |
* Getting the selected layer
|
399 |
* @return Flayer
|
400 |
*/
|
401 |
public FLayer getLayer() {
|
402 |
return (FLayer)this.getReference(); |
403 |
} |
404 |
|
405 |
/**
|
406 |
* Getting the actual height in the model
|
407 |
* @return height
|
408 |
*/
|
409 |
public double getHightLayer() { |
410 |
return props3D.getHeigth();
|
411 |
} |
412 |
|
413 |
/**
|
414 |
* Getting the objet(the selected layer). Updating the panel with the
|
415 |
* actual properties of the model.
|
416 |
* @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#setReference(java.lang.Object)
|
417 |
*/
|
418 |
public void setReference(Object arg0) { |
419 |
super.setReference(arg0);
|
420 |
props3D = Layer3DProps.getLayer3DProps((FLayer)this.getReference());
|
421 |
updatePanel(); |
422 |
} |
423 |
|
424 |
|
425 |
protected void updatePanel() { |
426 |
textFieldHeigth.setValue(this.getMyHeight());
|
427 |
controlEnabled(); |
428 |
} |
429 |
|
430 |
} |