gvsig-3d / 2.0 / trunk / org.gvsig.gvsig3d.app / org.gvsig.gvsig3d.app.extension / src / main / java / org / gvsig / gvsig3d / app / view / ViewProperties3D.java @ 306
History | View | Annotate | Download (18.2 KB)
1 |
package org.gvsig.gvsig3d.app.view; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Component; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.GridBagConstraints; |
7 |
import java.awt.GridBagLayout; |
8 |
import java.awt.Insets; |
9 |
import java.awt.event.ActionEvent; |
10 |
import java.awt.event.ActionListener; |
11 |
import java.util.Enumeration; |
12 |
|
13 |
import javax.swing.AbstractAction; |
14 |
import javax.swing.Action; |
15 |
import javax.swing.BorderFactory; |
16 |
import javax.swing.ButtonGroup; |
17 |
import javax.swing.JColorChooser; |
18 |
import javax.swing.JLabel; |
19 |
import javax.swing.JPanel; |
20 |
import javax.swing.JRadioButton; |
21 |
import javax.swing.JScrollPane; |
22 |
import javax.swing.JTextArea; |
23 |
import javax.swing.JTextField; |
24 |
|
25 |
import org.cresques.cts.IProjection; |
26 |
import org.gvsig.andami.PluginServices; |
27 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
28 |
import org.gvsig.andami.ui.mdiManager.SingletonWindow; |
29 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
30 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
31 |
import org.gvsig.app.project.documents.view.ViewDocument; |
32 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
33 |
import org.gvsig.fmap.crs.CRSFactory; |
34 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
35 |
import org.gvsig.fmap.mapcontext.layers.SingleLayerIterator; |
36 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
37 |
import org.gvsig.gui.beans.swing.JButton; |
38 |
import org.gvsig.gvsig3d.app.extension.DefaultView3DDocument; |
39 |
import org.gvsig.gvsig3d.app.extension.DefaultView3DPanel; |
40 |
import org.gvsig.gvsig3d.map3d.Layer3DProps; |
41 |
import org.gvsig.gvsig3d.map3d.layers.FLayers3D; |
42 |
import org.gvsig.osgvp.terrain.HeightfieldLayer; |
43 |
import org.gvsig.osgvp.terrain.Terrain; |
44 |
|
45 |
/**
|
46 |
* Dialogo donde se muestran las propiedades de una vista
|
47 |
*
|
48 |
* @author AI2
|
49 |
*/
|
50 |
public class ViewProperties3D extends GridBagLayoutPanel implements IWindow{ |
51 |
|
52 |
/**
|
53 |
*
|
54 |
*/
|
55 |
private static final long serialVersionUID = 1L; |
56 |
private DefaultView3DDocument _view3D;
|
57 |
private IProjection _proj;
|
58 |
private int _width = 700; |
59 |
private int _height = 600; |
60 |
private Color _backColor; |
61 |
|
62 |
private boolean _editable; |
63 |
private boolean _projectEditable = false; |
64 |
|
65 |
|
66 |
|
67 |
private JTextField txtName; |
68 |
private JTextField txtDate; |
69 |
private JTextField txtOwner; |
70 |
private JTextField verEx; |
71 |
private CRSSelectPanel jPanelProj;
|
72 |
private JPanel jPanelSelectProjection; |
73 |
private ButtonGroup radioButtonGroupTypeTerrain; |
74 |
private ButtonGroup radioButtonGroupProjection; |
75 |
private JButton btnColor; |
76 |
private JLabel lblColor; |
77 |
private GridBagLayoutPanel panelColor;
|
78 |
private JScrollPane jScrollPane; |
79 |
private JTextArea txtComments; |
80 |
private GridBagLayoutPanel okCancelPanel;
|
81 |
private JButton okButton; |
82 |
private JButton cancelButton; |
83 |
private JPanel jPanelSelectProjectionView; |
84 |
|
85 |
|
86 |
/**
|
87 |
* This is the default constructor
|
88 |
*
|
89 |
* @param f
|
90 |
* Frame padre del dialogo
|
91 |
* @param v
|
92 |
* Vista que se representa
|
93 |
*/
|
94 |
public ViewProperties3D(ViewDocument v, boolean edit) { |
95 |
_projectEditable = edit; |
96 |
_view3D = (DefaultView3DDocument) v; |
97 |
_proj = _view3D.getProjection(); |
98 |
setEditable(edit); |
99 |
initialize(); |
100 |
} |
101 |
|
102 |
private void addComponentGridBag(String label, Component component, |
103 |
int position) {
|
104 |
if (label == null) { |
105 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
106 |
gridBagConstraints.gridx = 0;
|
107 |
gridBagConstraints.gridy = position; |
108 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
109 |
gridBagConstraints.gridwidth = 2;
|
110 |
gridBagConstraints.insets = new Insets(2, 5, 2, 5); |
111 |
this.add(component, gridBagConstraints);
|
112 |
} else {
|
113 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
114 |
gridBagConstraints.gridx = 0;
|
115 |
gridBagConstraints.gridy = position; |
116 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
117 |
gridBagConstraints.insets = new Insets(2, 5, 2, 5); |
118 |
this.add(new JLabel(label), gridBagConstraints); |
119 |
|
120 |
gridBagConstraints = new GridBagConstraints(); |
121 |
gridBagConstraints.gridx = 1;
|
122 |
gridBagConstraints.gridy = position; |
123 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
124 |
gridBagConstraints.weightx = 1.0;
|
125 |
gridBagConstraints.insets = new Insets(2, 5, 2, 5); |
126 |
this.add(component, gridBagConstraints);
|
127 |
} |
128 |
} |
129 |
|
130 |
/**
|
131 |
* This method initializes this
|
132 |
*/
|
133 |
private void initialize() { |
134 |
this.setLayout(new GridBagLayout()); |
135 |
|
136 |
// Inicialize component
|
137 |
setName(PluginServices.getText(this, "view_3D_properties")); |
138 |
// Introducing the margin
|
139 |
setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
140 |
// Dimension of the panel
|
141 |
this.setPreferredSize(new Dimension(_width, _height)); |
142 |
|
143 |
// ADDING COMPONENTS
|
144 |
|
145 |
// Name Component
|
146 |
addComponentGridBag(PluginServices.getText(this, "Name"), getTxtName(), |
147 |
0);
|
148 |
|
149 |
// Date component
|
150 |
addComponentGridBag(PluginServices.getText(this, "Creation_Date"), |
151 |
getTxtDate(), 1);
|
152 |
|
153 |
// Owner component
|
154 |
|
155 |
this.addComponentGridBag(PluginServices.getText(this, "Owner"), |
156 |
getTxtOwner(), 2);
|
157 |
// Projection selector (Radio buton group)
|
158 |
this.addComponentGridBag(
|
159 |
PluginServices.getText(this, "Projection_Select"), |
160 |
getJPanelSelectProjection(), 3);
|
161 |
this.addComponentGridBag(null, getJPanelProj(), 4); |
162 |
|
163 |
// Description component
|
164 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
165 |
gridBagConstraints.gridx = 0;
|
166 |
gridBagConstraints.gridy = 5;
|
167 |
gridBagConstraints.insets = new Insets(2, 5, 2, 5); |
168 |
gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
|
169 |
this.add(new JLabel(PluginServices.getText(this, "Commentaries")), |
170 |
gridBagConstraints); |
171 |
|
172 |
gridBagConstraints = new GridBagConstraints(); |
173 |
gridBagConstraints.gridx = 1;
|
174 |
gridBagConstraints.gridy = 5;
|
175 |
gridBagConstraints.fill = GridBagConstraints.BOTH;
|
176 |
gridBagConstraints.weightx = 1.0;
|
177 |
gridBagConstraints.weighty = 1.0;
|
178 |
gridBagConstraints.insets = new Insets(2, 5, 2, 5); |
179 |
this.add(getJScrollPane(), gridBagConstraints);
|
180 |
|
181 |
// Vertical exaggeration
|
182 |
this.addComponentGridBag(
|
183 |
PluginServices.getText(this, "Vertical_Exageration"), |
184 |
getVerEx(), 6);
|
185 |
|
186 |
// Color Panel
|
187 |
panelColor = new GridBagLayoutPanel();
|
188 |
panelColor.add(getLblColor()); |
189 |
panelColor.add(getBtnColor()); |
190 |
this.addComponentGridBag(
|
191 |
PluginServices.getText(this, "Background_Color"), panelColor, 7); |
192 |
|
193 |
// Accept buton
|
194 |
this.addComponentGridBag(null, getOkCancelPanel(), 8); |
195 |
|
196 |
// Inicialicing default values
|
197 |
this.txtName.setText(PluginServices.getText(this, "Creation_Date")); |
198 |
txtName.setText(_view3D.getName()); |
199 |
txtDate.setText(_view3D.getCreationDate()); |
200 |
txtOwner.setText(_view3D.getOwner()); |
201 |
txtComments.setText(_view3D.getComment()); |
202 |
verEx.setText(Float.toString(_view3D.getVerticalExaggeration()));
|
203 |
_backColor = _view3D.getBackGroundColor(); |
204 |
|
205 |
} |
206 |
|
207 |
private javax.swing.JTextField getVerEx() {
|
208 |
if (verEx == null) { |
209 |
verEx = new javax.swing.JTextField();
|
210 |
verEx.setHorizontalAlignment(JTextField.RIGHT);
|
211 |
verEx.setColumns(2);
|
212 |
verEx.setPreferredSize(new java.awt.Dimension(10, 23)); |
213 |
} |
214 |
|
215 |
return verEx;
|
216 |
} |
217 |
|
218 |
private javax.swing.JTextField getTxtName() {
|
219 |
if (txtName == null) { |
220 |
txtName = new javax.swing.JTextField();
|
221 |
txtName.setPreferredSize(new java.awt.Dimension(150, 23)); |
222 |
} |
223 |
|
224 |
return txtName;
|
225 |
} |
226 |
|
227 |
private javax.swing.JTextField getTxtDate() {
|
228 |
if (txtDate == null) { |
229 |
txtDate = new javax.swing.JTextField();
|
230 |
txtDate.setPreferredSize(new java.awt.Dimension(150, 23)); |
231 |
txtDate.setEditable(false);
|
232 |
txtDate.setBackground(java.awt.Color.white); |
233 |
} |
234 |
|
235 |
return txtDate;
|
236 |
} |
237 |
|
238 |
private javax.swing.JTextField getTxtOwner() {
|
239 |
if (txtOwner == null) { |
240 |
txtOwner = new javax.swing.JTextField();
|
241 |
txtOwner.setPreferredSize(new java.awt.Dimension(150, 23)); |
242 |
} |
243 |
|
244 |
return txtOwner;
|
245 |
} |
246 |
|
247 |
private JPanel getJPanelSelectProjection() { |
248 |
if (jPanelSelectProjection == null) { |
249 |
// Create JPanel
|
250 |
jPanelSelectProjection = new GridBagLayoutPanel();
|
251 |
|
252 |
if (radioButtonGroupTypeTerrain == null) { |
253 |
radioButtonGroupTypeTerrain = getRadioButonGroupTerrainType(); |
254 |
} |
255 |
for (Enumeration e = radioButtonGroupTypeTerrain.getElements(); e |
256 |
.hasMoreElements();) { |
257 |
JRadioButton b = (JRadioButton) e.nextElement(); |
258 |
b.setEnabled(isEditable()); |
259 |
jPanelSelectProjection.add(b, null);
|
260 |
} |
261 |
|
262 |
} |
263 |
|
264 |
return jPanelSelectProjection;
|
265 |
} |
266 |
|
267 |
private JPanel getJPanelSelectProjectionView() { |
268 |
if (jPanelSelectProjectionView == null) { |
269 |
// Create JPanel
|
270 |
jPanelSelectProjectionView = new GridBagLayoutPanel();
|
271 |
|
272 |
if (radioButtonGroupProjection == null) { |
273 |
radioButtonGroupProjection = getRadioButonGroupProjection(); |
274 |
} |
275 |
for (Enumeration e = radioButtonGroupProjection.getElements(); e |
276 |
.hasMoreElements();) { |
277 |
JRadioButton b = (JRadioButton) e.nextElement(); |
278 |
b.setEnabled(isEditable()); |
279 |
jPanelSelectProjectionView.add(b, null);
|
280 |
} |
281 |
|
282 |
} |
283 |
|
284 |
return jPanelSelectProjectionView;
|
285 |
} |
286 |
|
287 |
/**
|
288 |
* Method to inicialize the radio button group
|
289 |
*
|
290 |
* @return the radio button group
|
291 |
*/
|
292 |
private ButtonGroup getRadioButonGroupTerrainType() { |
293 |
if (radioButtonGroupTypeTerrain == null) { |
294 |
|
295 |
// Create an action for each radio button
|
296 |
Action sphericalAction = new AbstractAction("spherical") { |
297 |
// This method is called whenever the radio button is pressed,
|
298 |
// even if it is already selected; this method is not called
|
299 |
// if the radio button was selected programmatically
|
300 |
public void actionPerformed(ActionEvent evt) { |
301 |
_view3D.setTerrainType(Terrain.CoordinateSystemType.GEOCENTRIC); |
302 |
_proj = CRSFactory.getCRS("EPSG:4326");
|
303 |
setComponentProjection(_proj); |
304 |
|
305 |
} |
306 |
}; |
307 |
Action flatAction = new AbstractAction("flat") { |
308 |
// See above
|
309 |
public void actionPerformed(ActionEvent evt) { |
310 |
_view3D.setTerrainType(Terrain.CoordinateSystemType.PROJECTED); |
311 |
_proj = _view3D.getProjection(); |
312 |
setComponentProjection(_proj); |
313 |
} |
314 |
}; |
315 |
Action orthoAction = new AbstractAction("ortho") { |
316 |
// See above
|
317 |
public void actionPerformed(ActionEvent evt) { |
318 |
_view3D.getCanvas3d() |
319 |
.getOSGViewer() |
320 |
.setProjectionMatrixAsOrtho(-10, 10, -10, 10, 1, |
321 |
1000);
|
322 |
} |
323 |
}; |
324 |
|
325 |
// Create the radio buttons using the actions
|
326 |
JRadioButton spherical = new JRadioButton(sphericalAction); |
327 |
JRadioButton flat = new JRadioButton(flatAction); |
328 |
JRadioButton ortho = new JRadioButton(orthoAction); |
329 |
|
330 |
// Inicialize the button properties
|
331 |
spherical.setName("spherical");
|
332 |
spherical.setText(PluginServices.getText(this, "Spherical")); |
333 |
flat.setName("flat");
|
334 |
flat.setText(PluginServices.getText(this, "Flat")); |
335 |
ortho.setName("ortho");
|
336 |
ortho.setText(PluginServices.getText(this, "Ortho")); |
337 |
|
338 |
if (_view3D.getTerrainType() == Terrain.CoordinateSystemType.GEOCENTRIC) {
|
339 |
spherical.setSelected(true);
|
340 |
} else
|
341 |
flat.setSelected(true);
|
342 |
|
343 |
// Associate the two buttons with a button group
|
344 |
radioButtonGroupTypeTerrain = new ButtonGroup(); |
345 |
radioButtonGroupTypeTerrain.add(spherical); |
346 |
radioButtonGroupTypeTerrain.add(flat); |
347 |
|
348 |
} |
349 |
|
350 |
return radioButtonGroupTypeTerrain;
|
351 |
} |
352 |
|
353 |
/**
|
354 |
* Method to inicialize the radio button group
|
355 |
*
|
356 |
* @return the radio button group
|
357 |
*/
|
358 |
private ButtonGroup getRadioButonGroupProjection() { |
359 |
if (radioButtonGroupProjection == null) { |
360 |
|
361 |
Action perspectiveAction = new AbstractAction("perspective") { |
362 |
// See above
|
363 |
public void actionPerformed(ActionEvent evt) { |
364 |
// Active perspective mode into View 3D
|
365 |
if (!(_view3D.isPerspectiveModeActive())) {
|
366 |
_view3D.setActivePerspectiveMode(true);
|
367 |
} |
368 |
} |
369 |
}; |
370 |
Action orthoAction = new AbstractAction("ortho") { |
371 |
// See above
|
372 |
public void actionPerformed(ActionEvent evt) { |
373 |
// Active ortho mode into View 3D
|
374 |
if (_view3D.isPerspectiveModeActive()) {
|
375 |
_view3D.setActivePerspectiveMode(false);
|
376 |
} |
377 |
} |
378 |
}; |
379 |
|
380 |
// Create the radio buttons using the actions
|
381 |
JRadioButton ortho = new JRadioButton(orthoAction); |
382 |
JRadioButton perspective = new JRadioButton(perspectiveAction); |
383 |
|
384 |
// Inicialize the button properties
|
385 |
ortho.setName("ortho");
|
386 |
ortho.setText(PluginServices.getText(this, "Ortho")); |
387 |
ortho.setSelected(false);
|
388 |
perspective.setName("perspective");
|
389 |
perspective.setText(PluginServices.getText(this, "Perspective")); |
390 |
perspective.setSelected(true);
|
391 |
|
392 |
// Associate the two buttons with a button group
|
393 |
radioButtonGroupProjection = new ButtonGroup(); |
394 |
radioButtonGroupProjection.add(perspective); |
395 |
radioButtonGroupProjection.add(ortho); |
396 |
} |
397 |
|
398 |
return radioButtonGroupProjection;
|
399 |
} |
400 |
|
401 |
private javax.swing.JLabel getLblColor() {
|
402 |
if (lblColor == null) { |
403 |
lblColor = new javax.swing.JLabel();
|
404 |
lblColor.setText("");
|
405 |
lblColor.setPreferredSize(new java.awt.Dimension(30, 16)); |
406 |
Color theColor = _view3D.getBackGroundColor();
|
407 |
|
408 |
if (theColor == null) |
409 |
theColor = Color.WHITE;
|
410 |
lblColor.setBackground(theColor); |
411 |
lblColor.setOpaque(true);
|
412 |
} |
413 |
|
414 |
return lblColor;
|
415 |
} |
416 |
|
417 |
private JButton getBtnColor() { |
418 |
if (btnColor == null) { |
419 |
btnColor = new JButton(); |
420 |
|
421 |
btnColor.setText("...");
|
422 |
|
423 |
btnColor.addActionListener(new java.awt.event.ActionListener() {
|
424 |
|
425 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
426 |
Color ret = JColorChooser.showDialog(ViewProperties3D.this, |
427 |
PluginServices.getText(this, "Select_Color"), |
428 |
lblColor.getBackground()); |
429 |
|
430 |
if (ret != null) { |
431 |
lblColor.setBackground(ret); |
432 |
_backColor = ret; |
433 |
} else
|
434 |
lblColor.setBackground(Color.WHITE);
|
435 |
} |
436 |
}); |
437 |
} |
438 |
|
439 |
return btnColor;
|
440 |
} |
441 |
|
442 |
private javax.swing.JScrollPane getJScrollPane() {
|
443 |
if (jScrollPane == null) { |
444 |
jScrollPane = new javax.swing.JScrollPane();
|
445 |
jScrollPane.setViewportView(getTxtComments()); |
446 |
jScrollPane.setPreferredSize(new java.awt.Dimension(340, 70)); |
447 |
} |
448 |
|
449 |
return jScrollPane;
|
450 |
} |
451 |
|
452 |
private javax.swing.JTextArea getTxtComments() {
|
453 |
if (txtComments == null) { |
454 |
txtComments = new javax.swing.JTextArea();
|
455 |
txtComments.setRows(1);
|
456 |
txtComments.setColumns(28);
|
457 |
} |
458 |
|
459 |
return txtComments;
|
460 |
} |
461 |
|
462 |
private GridBagLayoutPanel getOkCancelPanel() {
|
463 |
if (okCancelPanel == null) { |
464 |
ActionListener okAction, cancelAction;
|
465 |
okAction = new java.awt.event.ActionListener() {
|
466 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
467 |
_view3D.setName(txtName.getText()); |
468 |
_view3D.setCreationDate(txtDate.getText()); |
469 |
_view3D.setOwner(txtOwner.getText()); |
470 |
_view3D.setComment(txtComments.getText()); |
471 |
_view3D.setBackGroundColor(_backColor); |
472 |
_proj = jPanelProj.getCurProj(); |
473 |
setVerticalEx(Float.parseFloat(verEx.getText()));
|
474 |
_view3D.setVerticalExaggeration(Float.parseFloat(verEx
|
475 |
.getText())); |
476 |
_view3D.setProjection(_proj); |
477 |
setPropertiesCreated(true);
|
478 |
PluginServices.getMDIManager().closeWindow( |
479 |
ViewProperties3D.this); |
480 |
} |
481 |
}; |
482 |
cancelAction = new java.awt.event.ActionListener() {
|
483 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
484 |
PluginServices.getMDIManager().closeWindow( |
485 |
ViewProperties3D.this); |
486 |
} |
487 |
}; |
488 |
|
489 |
okCancelPanel = new GridBagLayoutPanel();
|
490 |
okCancelPanel.setAlignmentX(GridBagLayoutPanel.RIGHT_ALIGNMENT); |
491 |
okButton = new JButton(); |
492 |
okButton.setText(PluginServices.getText(this, "Accept")); |
493 |
okButton.addActionListener(okAction); |
494 |
cancelButton = new JButton(); |
495 |
cancelButton.setEnabled(!isEditable()); |
496 |
cancelButton.setText(PluginServices.getText(this, "Cancel")); |
497 |
cancelButton.addActionListener(cancelAction); |
498 |
|
499 |
okCancelPanel.addComponent(okButton, cancelButton); |
500 |
} |
501 |
return okCancelPanel;
|
502 |
} |
503 |
|
504 |
public Object getWindowModel() { |
505 |
return _view3D;
|
506 |
} |
507 |
|
508 |
public WindowInfo getWindowInfo() {
|
509 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
510 |
m_viewinfo.setTitle(PluginServices.getText(this, "view_3D_properties")); |
511 |
m_viewinfo.setHeight(_height); |
512 |
m_viewinfo.setWidth(_width); |
513 |
return m_viewinfo;
|
514 |
} |
515 |
|
516 |
public boolean isEditable() { |
517 |
return _editable;
|
518 |
} |
519 |
|
520 |
public void setEditable(boolean editable) { |
521 |
_editable = editable; |
522 |
} |
523 |
|
524 |
public void setVerticalEx(float exa) { |
525 |
|
526 |
SingleLayerIterator lyrIterator = new SingleLayerIterator(
|
527 |
(FLayers3D) _view3D.getMapContext().getLayers()); |
528 |
while (lyrIterator.hasNext()) {
|
529 |
FLayer lyr = lyrIterator.next(); |
530 |
|
531 |
Object propsObj = lyr.getProperty("3DLayerExtension"); |
532 |
Layer3DProps props = null;
|
533 |
if (propsObj != null) { |
534 |
try {
|
535 |
props = (Layer3DProps) propsObj; |
536 |
} catch (Exception e) { |
537 |
props = null;
|
538 |
} |
539 |
} |
540 |
|
541 |
int type = props.getType();
|
542 |
if (exa != props.getVerticalEx()) {
|
543 |
if (type == Layer3DProps.layer3DElevation) {
|
544 |
props.setVerticalEx(exa); |
545 |
HeightfieldLayer layer = (HeightfieldLayer) props |
546 |
.getTerrainLayer(); |
547 |
if (layer == null) |
548 |
return;
|
549 |
layer.setScaleFactor(exa); |
550 |
_view3D.getTerrain().getLayerManager().updateLayers(); |
551 |
} else if (type == Layer3DProps.layer3DVector) { |
552 |
props.setVerticalEx(exa); |
553 |
} |
554 |
} |
555 |
|
556 |
} |
557 |
} |
558 |
|
559 |
private CRSSelectPanel getJPanelProj() {
|
560 |
|
561 |
IProjection projectionAux = null;
|
562 |
IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
563 |
if (activeWindow instanceof DefaultView3DPanel) { |
564 |
AbstractViewPanel activeView = (DefaultView3DPanel) activeWindow; |
565 |
projectionAux = activeView.getProjection(); |
566 |
activeView.setProjection(_proj); |
567 |
} |
568 |
|
569 |
jPanelProj = CRSSelectPanel.getPanel(_proj); |
570 |
|
571 |
if (activeWindow instanceof DefaultView3DPanel) { |
572 |
AbstractViewPanel activeView = (DefaultView3DPanel) activeWindow; |
573 |
activeView.setProjection(projectionAux); |
574 |
} |
575 |
|
576 |
jPanelProj.setPreferredSize(new java.awt.Dimension(330, 35)); |
577 |
|
578 |
jPanelProj.addActionListener(new java.awt.event.ActionListener() {
|
579 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
580 |
if (jPanelProj.isOkPressed()) {
|
581 |
// New projection selected.
|
582 |
_view3D.setProjection(jPanelProj.getCurProj()); |
583 |
} |
584 |
} |
585 |
}); |
586 |
|
587 |
Component[] cs = jPanelProj.getComponents(); |
588 |
// Projection options disabled in spherical view.
|
589 |
if (_view3D.getTerrainType() == Terrain.CoordinateSystemType.GEOCENTRIC) {
|
590 |
_proj = CRSFactory.getCRS("EPSG:4326");
|
591 |
for (int i = 0; i < cs.length; i++) { |
592 |
cs[i].setEnabled(false);
|
593 |
} |
594 |
} |
595 |
// Projection options disabled in flat view.
|
596 |
else {
|
597 |
if (!_projectEditable) {
|
598 |
_proj = _view3D.getProjection(); |
599 |
for (int i = 0; i < cs.length; i++) { |
600 |
cs[i].setEnabled(false);
|
601 |
} |
602 |
} |
603 |
} |
604 |
|
605 |
return jPanelProj;
|
606 |
} |
607 |
|
608 |
private void setComponentProjection(IProjection projection) { |
609 |
_proj = projection; |
610 |
this.remove(jPanelProj);
|
611 |
jPanelProj = null;
|
612 |
|
613 |
this.addComponentGridBag(null, getJPanelProj(), 4); |
614 |
this.validate();
|
615 |
|
616 |
} |
617 |
|
618 |
public Object getWindowProfile() { |
619 |
return WindowInfo.PROPERTIES_PROFILE;
|
620 |
} |
621 |
|
622 |
public void setPropertiesCreated(boolean propertiesCreated) { |
623 |
_view3D.setPropertiesCreated(propertiesCreated); |
624 |
} |
625 |
|
626 |
public boolean isPropertiesCreated() { |
627 |
return _view3D.getPropertiesCreated();
|
628 |
} |
629 |
} |