svn-gvsig-desktop / trunk / libraries / lib3DMap-share / src / main / java / com / iver / ai2 / gvsig3d / gui / VectorLayerMenu.java @ 25862
History | View | Annotate | Download (8.42 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 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 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.ai2.gvsig3d.gui; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.Checkbox; |
45 |
import java.awt.Component; |
46 |
import java.awt.Dimension; |
47 |
import java.awt.GridBagConstraints; |
48 |
import java.awt.GridBagLayout; |
49 |
import java.awt.Insets; |
50 |
import java.awt.event.ActionEvent; |
51 |
import java.awt.event.ItemEvent; |
52 |
import java.awt.event.ItemListener; |
53 |
import java.awt.event.MouseEvent; |
54 |
import java.awt.event.MouseListener; |
55 |
|
56 |
import javax.swing.JDialog; |
57 |
import javax.swing.JFrame; |
58 |
import javax.swing.JLabel; |
59 |
import javax.swing.JPanel; |
60 |
import javax.swing.JTextField; |
61 |
|
62 |
import org.gvsig.gui.beans.swing.JButton; |
63 |
|
64 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
65 |
import com.iver.andami.PluginServices; |
66 |
|
67 |
/**
|
68 |
* This dialog shows the preferences about a 3D layers
|
69 |
*
|
70 |
* @author Julio Campos Alvarez
|
71 |
* @author Angel Fraile Gri?an
|
72 |
*/
|
73 |
public class VectorLayerMenu extends JDialog implements MouseListener, |
74 |
ItemListener {
|
75 |
|
76 |
private int width = 285; |
77 |
|
78 |
private int height = 190; |
79 |
|
80 |
private Checkbox aButton; // @jve:decl-index=0:visual-constraint="359,41" |
81 |
|
82 |
private Checkbox bButton; |
83 |
|
84 |
private JTextField heigthField; |
85 |
|
86 |
private Layer3DProps props3D;
|
87 |
|
88 |
private Object panel; |
89 |
|
90 |
private JPanel jContentPane = null; |
91 |
|
92 |
private JButton boton; |
93 |
|
94 |
private JLabel jLabel1; |
95 |
|
96 |
private String name; |
97 |
|
98 |
/**
|
99 |
* This is the default constructor
|
100 |
*
|
101 |
* @param nombre
|
102 |
*
|
103 |
* @param f
|
104 |
* Frame padre del dialogo
|
105 |
* @param v
|
106 |
* Vista que se representa
|
107 |
*/
|
108 |
public VectorLayerMenu(Layer3DProps props, String nombre) { |
109 |
|
110 |
props3D = props; |
111 |
|
112 |
name = nombre; |
113 |
|
114 |
initialize(); |
115 |
|
116 |
} |
117 |
|
118 |
/**
|
119 |
* This method initializes this class
|
120 |
*/
|
121 |
private void initialize() { |
122 |
// Inicialize component
|
123 |
this.setTitle(PluginServices.getText(this, "Layer_Properties") + ":" |
124 |
+ name); |
125 |
// Introducing the margin
|
126 |
this.setSize(new Dimension(width, height)); |
127 |
// Dimension of the panel only for java 1.5
|
128 |
// this.setPreferredSize(new Dimension(width, height));
|
129 |
this.setResizable(false); |
130 |
|
131 |
JFrame a = (JFrame) PluginServices.getMainFrame(); |
132 |
double posX = a.getBounds().getCenterX();
|
133 |
double posY = a.getBounds().getCenterY();
|
134 |
this.setLocation(((int) posX) - (width / 2), ((int) posY) |
135 |
- (height / 2));
|
136 |
panel = new JPanel(); |
137 |
this.getContentPane().add((Component) panel, BorderLayout.CENTER); |
138 |
|
139 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
140 |
gridBagConstraints.gridx = 0;
|
141 |
gridBagConstraints.insets = new Insets(0, 25, 0, 0); |
142 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
143 |
gridBagConstraints.fill = GridBagConstraints.VERTICAL;
|
144 |
gridBagConstraints.gridy = 0;
|
145 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
146 |
gridBagConstraints3.gridx = 0;
|
147 |
gridBagConstraints3.insets = new Insets(12, 0, 0, 0); |
148 |
gridBagConstraints3.gridy = 4;
|
149 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
150 |
gridBagConstraints2.fill = GridBagConstraints.VERTICAL;
|
151 |
gridBagConstraints2.gridy = 3;
|
152 |
gridBagConstraints2.weightx = 1.0;
|
153 |
gridBagConstraints2.gridwidth = 1;
|
154 |
gridBagConstraints2.ipadx = 93;
|
155 |
gridBagConstraints2.insets = new Insets(8, 0, 0, 0); |
156 |
gridBagConstraints2.gridx = 0;
|
157 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
158 |
gridBagConstraints1.gridx = 0;
|
159 |
gridBagConstraints1.insets = new Insets(0, 25, 0, 0); |
160 |
gridBagConstraints1.anchor = GridBagConstraints.WEST;
|
161 |
gridBagConstraints1.fill = GridBagConstraints.VERTICAL;
|
162 |
gridBagConstraints1.gridy = 1;
|
163 |
|
164 |
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
165 |
gridBagConstraints4.gridx = 0;
|
166 |
gridBagConstraints4.insets = new Insets(0, 25, 0, 0); |
167 |
gridBagConstraints4.anchor = GridBagConstraints.WEST;
|
168 |
gridBagConstraints4.fill = GridBagConstraints.VERTICAL;
|
169 |
gridBagConstraints4.gridy = 2;
|
170 |
|
171 |
jContentPane = new JPanel(); |
172 |
jContentPane.setLayout(new GridBagLayout()); |
173 |
jContentPane.add(getJCheckBox1(), gridBagConstraints1); |
174 |
jLabel1 = new JLabel("Altura en metros:"); |
175 |
jLabel1.setEnabled(false);
|
176 |
jContentPane.add(jLabel1, gridBagConstraints4); |
177 |
jContentPane.add(getJTextField(), gridBagConstraints2); |
178 |
jContentPane.add(getJButton(), gridBagConstraints3); |
179 |
jContentPane.add(getJCheckBox(), gridBagConstraints); |
180 |
this.setModal(true); |
181 |
this.setAlwaysOnTop(true); |
182 |
this.getContentPane().add(jContentPane);
|
183 |
|
184 |
} |
185 |
|
186 |
private Checkbox getJCheckBox1() { |
187 |
if (bButton == null) { |
188 |
bButton = new Checkbox(PluginServices.getText(this, "Heigth_Z"), |
189 |
false);
|
190 |
bButton.setEnabled(false);
|
191 |
bButton.addItemListener(this);
|
192 |
} |
193 |
return bButton;
|
194 |
} |
195 |
|
196 |
/**
|
197 |
* This method initializes jTextField
|
198 |
*
|
199 |
* @return javax.swing.JTextField
|
200 |
*/
|
201 |
private JTextField getJTextField() { |
202 |
if (heigthField == null) { |
203 |
heigthField = new JTextField(); |
204 |
heigthField.setText("10000");
|
205 |
heigthField.setEnabled(false);
|
206 |
|
207 |
} |
208 |
return heigthField;
|
209 |
} |
210 |
|
211 |
/**
|
212 |
* This method initializes jButton
|
213 |
*
|
214 |
* @return javax.swing.JButton
|
215 |
*/
|
216 |
private JButton getJButton() { |
217 |
if (boton == null) { |
218 |
boton = new JButton(PluginServices.getText(this, "Accept")); |
219 |
|
220 |
boton.addMouseListener(this);
|
221 |
} |
222 |
return boton;
|
223 |
} |
224 |
|
225 |
/**
|
226 |
* This method initializes jCheckBox
|
227 |
*
|
228 |
* @return javax.swing.JCheckBox
|
229 |
*/
|
230 |
private Checkbox getJCheckBox() { |
231 |
if (aButton == null) { |
232 |
aButton = new Checkbox( |
233 |
PluginServices.getText(this, "Raster_layer"), true); |
234 |
aButton.addItemListener(this);
|
235 |
} |
236 |
return aButton;
|
237 |
} |
238 |
|
239 |
private Checkbox getJLabel() { |
240 |
if (jLabel1 == null) { |
241 |
jLabel1 = new JLabel(); |
242 |
jLabel1.setText("Altura en metros:");
|
243 |
} |
244 |
return aButton;
|
245 |
} |
246 |
|
247 |
public void itemStateChanged(ItemEvent arg0) { |
248 |
|
249 |
bButton.setEnabled(!aButton.getState()); |
250 |
aButton.setEnabled(!bButton.getState()); |
251 |
heigthField.setEnabled(!aButton.getState()); |
252 |
heigthField.setEnabled(!(bButton.getState() || aButton.getState())); |
253 |
|
254 |
jLabel1.setEnabled(!aButton.getState()); |
255 |
jLabel1.setEnabled(!(bButton.getState() || aButton.getState())); |
256 |
|
257 |
} |
258 |
|
259 |
public void actionPerformed(ActionEvent e) { |
260 |
// TODO Auto-generated method stub
|
261 |
|
262 |
} |
263 |
|
264 |
public void mouseClicked(MouseEvent e) { |
265 |
// TODO Auto-generated method stub
|
266 |
|
267 |
if (aButton.getState()) {
|
268 |
props3D.setType(Layer3DProps.layer3DImage); |
269 |
} else {
|
270 |
props3D.setType(Layer3DProps.layer3DVector); |
271 |
if (!bButton.getState()) {
|
272 |
props3D.setZEnable(false);
|
273 |
int h = Integer.parseInt(heigthField.getText()); |
274 |
if (h >= 0) |
275 |
props3D.setHeigth(h); |
276 |
} else {
|
277 |
props3D.setZEnable(true);
|
278 |
} |
279 |
} |
280 |
this.dispose();
|
281 |
} |
282 |
|
283 |
public void mouseEntered(MouseEvent e) { |
284 |
// TODO Auto-generated method stub
|
285 |
|
286 |
} |
287 |
|
288 |
public void mouseExited(MouseEvent e) { |
289 |
// TODO Auto-generated method stub
|
290 |
|
291 |
} |
292 |
|
293 |
public void mousePressed(MouseEvent e) { |
294 |
// TODO Auto-generated method stub
|
295 |
|
296 |
} |
297 |
|
298 |
public void mouseReleased(MouseEvent e) { |
299 |
// TODO Auto-generated method stub
|
300 |
|
301 |
} |
302 |
|
303 |
/**
|
304 |
* This method initializes jContentPane
|
305 |
*
|
306 |
* @return javax.swing.JPanel
|
307 |
*/
|
308 |
private JPanel getJContentPane() { |
309 |
if (jContentPane == null) { |
310 |
jContentPane = new JPanel(); |
311 |
jContentPane.setLayout(new BorderLayout()); |
312 |
jContentPane.add(bButton, BorderLayout.CENTER);
|
313 |
} |
314 |
return jContentPane;
|
315 |
} |
316 |
} // @jve:decl-index=0:visual-constraint="10,10"
|