Revision 247
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/lib3DMap-share/src/test/java/com/iver/ai2/gvsig3d/AppTest.java | ||
---|---|---|
1 |
package com.iver.ai2.gvsig3d; |
|
2 |
|
|
3 |
import junit.framework.Test; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import junit.framework.TestSuite; |
|
6 |
|
|
7 |
/** |
|
8 |
* Unit test for simple App. |
|
9 |
*/ |
|
10 |
public class AppTest |
|
11 |
extends TestCase |
|
12 |
{ |
|
13 |
/** |
|
14 |
* Create the test case |
|
15 |
* |
|
16 |
* @param testName name of the test case |
|
17 |
*/ |
|
18 |
public AppTest( String testName ) |
|
19 |
{ |
|
20 |
super( testName ); |
|
21 |
} |
|
22 |
|
|
23 |
/** |
|
24 |
* @return the suite of tests being tested |
|
25 |
*/ |
|
26 |
public static Test suite() |
|
27 |
{ |
|
28 |
return new TestSuite( AppTest.class ); |
|
29 |
} |
|
30 |
|
|
31 |
/** |
|
32 |
* Rigourous Test :-) |
|
33 |
*/ |
|
34 |
public void testApp() |
|
35 |
{ |
|
36 |
assertTrue( true ); |
|
37 |
} |
|
38 |
} |
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/gui/VectorLayerMenu.java | ||
---|---|---|
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.datainput.DataInputField; |
|
63 |
import org.gvsig.gui.beans.swing.JButton; |
|
64 |
|
|
65 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
|
66 |
import com.iver.andami.PluginServices; |
|
67 |
|
|
68 |
/** |
|
69 |
* This dialog shows the preferences about a 3D layers |
|
70 |
* |
|
71 |
* @author Julio Campos Alvarez |
|
72 |
* @author Angel Fraile Gri�an |
|
73 |
*/ |
|
74 |
public class VectorLayerMenu extends JDialog implements MouseListener, |
|
75 |
ItemListener { |
|
76 |
|
|
77 |
private int width = 285; |
|
78 |
|
|
79 |
private int height = 190; |
|
80 |
|
|
81 |
private Checkbox aButton; // @jve:decl-index=0:visual-constraint="359,41" |
|
82 |
|
|
83 |
private Checkbox bButton; |
|
84 |
|
|
85 |
private DataInputField heigthField; |
|
86 |
|
|
87 |
private Layer3DProps props3D; |
|
88 |
|
|
89 |
private Object panel; |
|
90 |
|
|
91 |
private JPanel jContentPane = null; |
|
92 |
|
|
93 |
private JButton boton; |
|
94 |
|
|
95 |
private JLabel jLabel1; |
|
96 |
|
|
97 |
private String name; |
|
98 |
|
|
99 |
/** |
|
100 |
* This is the default constructor |
|
101 |
* |
|
102 |
* @param nombre |
|
103 |
* |
|
104 |
* @param f |
|
105 |
* Frame padre del dialogo |
|
106 |
* @param v |
|
107 |
* Vista que se representa |
|
108 |
*/ |
|
109 |
public VectorLayerMenu(Layer3DProps props, String nombre) { |
|
110 |
|
|
111 |
props3D = props; |
|
112 |
|
|
113 |
name = nombre; |
|
114 |
|
|
115 |
initialize(); |
|
116 |
|
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* This method initializes this class |
|
121 |
*/ |
|
122 |
private void initialize() { |
|
123 |
// Inicialize component |
|
124 |
this.setTitle(PluginServices.getText(this, "Layer_Properties") + ":" |
|
125 |
+ name); |
|
126 |
// Introducing the margin |
|
127 |
this.setSize(new Dimension(width, height)); |
|
128 |
// Dimension of the panel only for java 1.5 |
|
129 |
// this.setPreferredSize(new Dimension(width, height)); |
|
130 |
this.setResizable(false); |
|
131 |
|
|
132 |
JFrame a = (JFrame) PluginServices.getMainFrame(); |
|
133 |
double posX = a.getBounds().getCenterX(); |
|
134 |
double posY = a.getBounds().getCenterY(); |
|
135 |
this.setLocation(((int) posX) - (width / 2), ((int) posY) |
|
136 |
- (height / 2)); |
|
137 |
panel = new JPanel(); |
|
138 |
this.getContentPane().add((Component) panel, BorderLayout.CENTER); |
|
139 |
|
|
140 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
141 |
gridBagConstraints.gridx = 0; |
|
142 |
gridBagConstraints.insets = new Insets(0, 25, 0, 0); |
|
143 |
gridBagConstraints.anchor = GridBagConstraints.WEST; |
|
144 |
gridBagConstraints.fill = GridBagConstraints.VERTICAL; |
|
145 |
gridBagConstraints.gridy = 0; |
|
146 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
|
147 |
gridBagConstraints3.gridx = 0; |
|
148 |
gridBagConstraints3.insets = new Insets(12, 0, 0, 0); |
|
149 |
gridBagConstraints3.gridy = 4; |
|
150 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
|
151 |
gridBagConstraints2.fill = GridBagConstraints.VERTICAL; |
|
152 |
gridBagConstraints2.gridy = 3; |
|
153 |
gridBagConstraints2.weightx = 1.0; |
|
154 |
gridBagConstraints2.gridwidth = 1; |
|
155 |
gridBagConstraints2.ipadx = 93; |
|
156 |
gridBagConstraints2.insets = new Insets(8, 0, 0, 0); |
|
157 |
gridBagConstraints2.gridx = 0; |
|
158 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
159 |
gridBagConstraints1.gridx = 0; |
|
160 |
gridBagConstraints1.insets = new Insets(0, 25, 0, 0); |
|
161 |
gridBagConstraints1.anchor = GridBagConstraints.WEST; |
|
162 |
gridBagConstraints1.fill = GridBagConstraints.VERTICAL; |
|
163 |
gridBagConstraints1.gridy = 1; |
|
164 |
|
|
165 |
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
|
166 |
gridBagConstraints4.gridx = 0; |
|
167 |
gridBagConstraints4.insets = new Insets(0, 25, 0, 0); |
|
168 |
gridBagConstraints4.anchor = GridBagConstraints.WEST; |
|
169 |
gridBagConstraints4.fill = GridBagConstraints.VERTICAL; |
|
170 |
gridBagConstraints4.gridy = 2; |
|
171 |
|
|
172 |
jContentPane = new JPanel(); |
|
173 |
jContentPane.setLayout(new GridBagLayout()); |
|
174 |
jContentPane.add(getJCheckBox1(), gridBagConstraints1); |
|
175 |
jLabel1 = new JLabel(PluginServices.getText(this, "Altura_en_metros")); |
|
176 |
jLabel1.setEnabled(false); |
|
177 |
jContentPane.add(jLabel1, gridBagConstraints4); |
|
178 |
jContentPane.add(getJTextField(), gridBagConstraints2); |
|
179 |
jContentPane.add(getJButton(), gridBagConstraints3); |
|
180 |
jContentPane.add(getJCheckBox(), gridBagConstraints); |
|
181 |
this.setModal(true); |
|
182 |
this.setAlwaysOnTop(true); |
|
183 |
this.getContentPane().add(jContentPane); |
|
184 |
|
|
185 |
} |
|
186 |
|
|
187 |
private Checkbox getJCheckBox1() { |
|
188 |
if (bButton == null) { |
|
189 |
bButton = new Checkbox(PluginServices.getText(this, "Heigth_Z"), |
|
190 |
false); |
|
191 |
bButton.setEnabled(false); |
|
192 |
bButton.addItemListener(this); |
|
193 |
} |
|
194 |
return bButton; |
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* This method initializes jTextField |
|
199 |
* |
|
200 |
* @return javax.swing.JTextField |
|
201 |
*/ |
|
202 |
private DataInputField getJTextField() { |
|
203 |
if (heigthField == null) { |
|
204 |
heigthField = new DataInputField(); |
|
205 |
heigthField.setValue("100"); |
|
206 |
heigthField.setControlEnabled(false); |
|
207 |
//heigthField.setEnabled(false); |
|
208 |
|
|
209 |
} |
|
210 |
return heigthField; |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* This method initializes jButton |
|
215 |
* |
|
216 |
* @return javax.swing.JButton |
|
217 |
*/ |
|
218 |
private JButton getJButton() { |
|
219 |
if (boton == null) { |
|
220 |
boton = new JButton(PluginServices.getText(this, "Accept")); |
|
221 |
|
|
222 |
boton.addMouseListener(this); |
|
223 |
} |
|
224 |
return boton; |
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* This method initializes jCheckBox |
|
229 |
* |
|
230 |
* @return javax.swing.JCheckBox |
|
231 |
*/ |
|
232 |
private Checkbox getJCheckBox() { |
|
233 |
if (aButton == null) { |
|
234 |
aButton = new Checkbox( |
|
235 |
PluginServices.getText(this, "Raster_layer"), true); |
|
236 |
aButton.addItemListener(this); |
|
237 |
} |
|
238 |
return aButton; |
|
239 |
} |
|
240 |
|
|
241 |
private Checkbox getJLabel() { |
|
242 |
if (jLabel1 == null) { |
|
243 |
jLabel1 = new JLabel(); |
|
244 |
jLabel1.setText(PluginServices.getText(this, "Altura_en_metros")); |
|
245 |
} |
|
246 |
return aButton; |
|
247 |
} |
|
248 |
|
|
249 |
public void itemStateChanged(ItemEvent arg0) { |
|
250 |
|
|
251 |
bButton.setEnabled(!aButton.getState()); |
|
252 |
aButton.setEnabled(!bButton.getState()); |
|
253 |
//heigthField.setEnabled(!aButton.getState()); |
|
254 |
//heigthField.setEnabled(!(bButton.getState() || aButton.getState())); |
|
255 |
heigthField.setControlEnabled(!aButton.getState()); |
|
256 |
heigthField.setControlEnabled(!(bButton.getState() || aButton.getState())); |
|
257 |
|
|
258 |
jLabel1.setEnabled(!aButton.getState()); |
|
259 |
jLabel1.setEnabled(!(bButton.getState() || aButton.getState())); |
|
260 |
|
|
261 |
} |
|
262 |
|
|
263 |
public void actionPerformed(ActionEvent e) { |
|
264 |
// TODO Auto-generated method stub |
|
265 |
|
|
266 |
} |
|
267 |
|
|
268 |
public void mouseClicked(MouseEvent e) { |
|
269 |
// TODO Auto-generated method stub |
|
270 |
|
|
271 |
if (aButton.getState()) { |
|
272 |
props3D.setType(Layer3DProps.layer3DImage); |
|
273 |
} else { |
|
274 |
props3D.setType(Layer3DProps.layer3DVector); |
|
275 |
if (!bButton.getState()) { |
|
276 |
props3D.setZEnable(false); |
|
277 |
float h = Float.parseFloat(heigthField.getValue()); |
|
278 |
if (h >= 0) |
|
279 |
props3D.setHeight(h); |
|
280 |
} else { |
|
281 |
props3D.setZEnable(true); |
|
282 |
} |
|
283 |
} |
|
284 |
this.dispose(); |
|
285 |
} |
|
286 |
|
|
287 |
public void mouseEntered(MouseEvent e) { |
|
288 |
// TODO Auto-generated method stub |
|
289 |
|
|
290 |
} |
|
291 |
|
|
292 |
public void mouseExited(MouseEvent e) { |
|
293 |
// TODO Auto-generated method stub |
|
294 |
|
|
295 |
} |
|
296 |
|
|
297 |
public void mousePressed(MouseEvent e) { |
|
298 |
// TODO Auto-generated method stub |
|
299 |
|
|
300 |
} |
|
301 |
|
|
302 |
public void mouseReleased(MouseEvent e) { |
|
303 |
// TODO Auto-generated method stub |
|
304 |
|
|
305 |
} |
|
306 |
|
|
307 |
/** |
|
308 |
* This method initializes jContentPane |
|
309 |
* |
|
310 |
* @return javax.swing.JPanel |
|
311 |
*/ |
|
312 |
private JPanel getJContentPane() { |
|
313 |
if (jContentPane == null) { |
|
314 |
jContentPane = new JPanel(); |
|
315 |
jContentPane.setLayout(new BorderLayout()); |
|
316 |
jContentPane.add(bButton, BorderLayout.CENTER); |
|
317 |
} |
|
318 |
return jContentPane; |
|
319 |
} |
|
320 |
} // @jve:decl-index=0:visual-constraint="10,10" |
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/map3d/layers/Layer3DProps.java | ||
---|---|---|
1 |
package com.iver.ai2.gvsig3d.map3d.layers; |
|
2 |
|
|
3 |
import java.awt.Component; |
|
4 |
import java.io.File; |
|
5 |
import java.io.FileNotFoundException; |
|
6 |
import java.io.FileReader; |
|
7 |
import java.io.FileWriter; |
|
8 |
import java.util.HashMap; |
|
9 |
import java.util.Hashtable; |
|
10 |
import java.util.Vector; |
|
11 |
|
|
12 |
import javax.swing.JOptionPane; |
|
13 |
|
|
14 |
import org.cresques.cts.IProjection; |
|
15 |
import org.exolab.castor.xml.Marshaller; |
|
16 |
import org.gvsig.cacheservice.CacheService; |
|
17 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
|
18 |
import org.gvsig.osgvp.terrain.HeightfieldLayer; |
|
19 |
import org.gvsig.osgvp.terrain.Layer; |
|
20 |
import org.gvsig.osgvp.terrain.RasterLayer; |
|
21 |
|
|
22 |
import com.iver.ai2.gvsig3d.gui.VectorLayerMenu; |
|
23 |
import com.iver.andami.PluginServices; |
|
24 |
import com.iver.andami.messages.NotificationManager; |
|
25 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
26 |
import com.iver.cit.gvsig.fmap.layers.FLyrDefault; |
|
27 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
28 |
import com.iver.cit.gvsig.fmap.layers.FLyrWCS; |
|
29 |
import com.iver.cit.gvsig.fmap.layers.FLyrWMS; |
|
30 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable; |
|
31 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial; |
|
32 |
import com.iver.cit.gvsig.fmap.rendering.ILegend; |
|
33 |
import com.iver.cit.gvsig.fmap.rendering.IVectorLegend; |
|
34 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
|
35 |
import com.iver.utiles.IPersistence; |
|
36 |
import com.iver.utiles.XMLEntity; |
|
37 |
import com.iver.utiles.xmlEntity.generate.XmlTag; |
|
38 |
|
|
39 |
/** |
|
40 |
* This class is used to manage all the 3d properties that the layer has. |
|
41 |
* |
|
42 |
* @author Salvador Bayarri |
|
43 |
* @author Julio Campos |
|
44 |
* |
|
45 |
*/ |
|
46 |
public class Layer3DProps implements IPersistence { |
|
47 |
|
|
48 |
// types of 3D layers |
|
49 |
public static final int layer3DImage = 0; |
|
50 |
public static final int layer3DElevation = 1; |
|
51 |
public static final int layer3DVector = 2; |
|
52 |
public static final int layer3DVectorMR = 4; |
|
53 |
public static final int layer3DOSG = 3; |
|
54 |
public long drawVersion = 0; |
|
55 |
|
|
56 |
private boolean newLayerOSG = false; |
|
57 |
|
|
58 |
// public static String m_cacheDir = "c:/data/cache"; // TEST |
|
59 |
// Create a .data directorio in user home for caching elements |
|
60 |
public static String m_cacheDir = System.getProperty("user.home") |
|
61 |
+ File.separator+"gvSIG"+File.separator+".data"+File.separator+"cache"; |
|
62 |
|
|
63 |
// Can be temporarily different from the TOC order while moving groups of |
|
64 |
// layers |
|
65 |
|
|
66 |
protected float _opacity = 1.0f; // Opacity of layer default 1.0 |
|
67 |
protected float _verticalEx = 1.0f; // Opacity of layer default 1.0 |
|
68 |
protected float _height = 100; // Opacity of layer default 1.0 |
|
69 |
protected int _type; // see type enumeration above |
|
70 |
|
|
71 |
protected Layer _terrainLayer; |
|
72 |
|
|
73 |
protected FLayer _layer; |
|
74 |
|
|
75 |
protected String _cacheName = "default"; |
|
76 |
|
|
77 |
protected CacheService _cacheService; |
|
78 |
|
|
79 |
private boolean _bChooseType = true; |
|
80 |
|
|
81 |
private boolean _zEnable = false; |
|
82 |
|
|
83 |
// used by FLayers3D (3D group layer) to flag when they are actually hooked |
|
84 |
// to TOC or not |
|
85 |
private boolean _hooked = false; |
|
86 |
|
|
87 |
private boolean isEditing = false; |
|
88 |
|
|
89 |
private int option; |
|
90 |
|
|
91 |
private VectorLayerMenu vectorLayerMenu; |
|
92 |
|
|
93 |
|
|
94 |
/** |
|
95 |
* the constructor |
|
96 |
*/ |
|
97 |
public Layer3DProps() { |
|
98 |
//m_tocOrder = -1; // not set |
|
99 |
//m_terrainOrder = -1; |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* This method make an instance of the 3D props of the layer that get from parameters |
|
104 |
* |
|
105 |
* @param layer |
|
106 |
* @return the properties |
|
107 |
*/ |
|
108 |
public static Layer3DProps getLayer3DProps(FLayer layer) { |
|
109 |
FLyrDefault baseLayer = (FLyrDefault) layer; |
|
110 |
Object propsObj = baseLayer.getProperty("3DLayerExtension"); |
|
111 |
Layer3DProps props3D = null; |
|
112 |
if (propsObj != null) { |
|
113 |
try { |
|
114 |
props3D = (Layer3DProps) propsObj; |
|
115 |
if (props3D.drawVersion == 0) |
|
116 |
props3D.drawVersion = layer.getDrawVersion(); |
|
117 |
} catch (Exception e) { |
|
118 |
props3D = null; |
|
119 |
} |
|
120 |
} |
|
121 |
return props3D; |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* Return The editing state |
|
126 |
* |
|
127 |
* @return true->editing. false->not editing |
|
128 |
*/ |
|
129 |
public boolean isEditing() { |
|
130 |
return isEditing; |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Set the editing state |
|
135 |
* |
|
136 |
* @param true->editing. false->not editing |
|
137 |
*/ |
|
138 |
public void setEditing(boolean isEditing) { |
|
139 |
this.isEditing = isEditing; |
|
140 |
} |
|
141 |
|
|
142 |
public void setChooseType(boolean bChoose) { |
|
143 |
_bChooseType = bChoose; |
|
144 |
} |
|
145 |
|
|
146 |
public boolean getHooked() { |
|
147 |
return _hooked; |
|
148 |
} |
|
149 |
|
|
150 |
public void setHooked(boolean hooked) { |
|
151 |
_hooked = hooked; |
|
152 |
} |
|
153 |
|
|
154 |
public void setTerrainLayer(Layer terrainLayer) |
|
155 |
{ |
|
156 |
_terrainLayer = terrainLayer; |
|
157 |
} |
|
158 |
|
|
159 |
public Layer getTerrainLayer() |
|
160 |
{ |
|
161 |
return _terrainLayer; |
|
162 |
} |
|
163 |
|
|
164 |
/** |
|
165 |
* Setting the layer |
|
166 |
* |
|
167 |
* @param layer |
|
168 |
*/ |
|
169 |
public void setLayer(FLayer layer) { |
|
170 |
|
|
171 |
if (_layer == layer) |
|
172 |
return; |
|
173 |
|
|
174 |
_layer = layer; |
|
175 |
|
|
176 |
// find out data type |
|
177 |
if (_bChooseType) { |
|
178 |
_bChooseType = false; |
|
179 |
_type = layer3DImage; |
|
180 |
boolean bCanBeElev = false; |
|
181 |
|
|
182 |
if (layer instanceof FLyrWMS) { |
|
183 |
FLyrWMS wmsLayer = (FLyrWMS) layer; |
|
184 |
String format = wmsLayer.getFormat(); |
|
185 |
if (format.regionMatches(true, 0, "image/geotiff", 0, 13) |
|
186 |
|| format.regionMatches(true, 0, "image/tiff", 0, 10)) |
|
187 |
bCanBeElev = true; |
|
188 |
} else if (layer instanceof FLyrWCS) { |
|
189 |
FLyrWCS wcsLayer = (FLyrWCS) layer; |
|
190 |
Hashtable props = wcsLayer.getProperties(); |
|
191 |
String format = (String) props.get("format"); |
|
192 |
String params = (String) props.get("parameter"); |
|
193 |
if (format.compareToIgnoreCase("GEOTIFF_INT16") == 0 |
|
194 |
&& params.compareToIgnoreCase("bands=1") == 0) |
|
195 |
bCanBeElev = true; |
|
196 |
} |
|
197 |
// FEATURES |
|
198 |
else /**/if (layer instanceof ClassifiableVectorial) { |
|
199 |
|
|
200 |
if (this.getType() != layer3DOSG) { |
|
201 |
vectorLayerMenu = new VectorLayerMenu(this, layer.getName()); |
|
202 |
vectorLayerMenu.setModal(true); |
|
203 |
vectorLayerMenu.pack(); |
|
204 |
vectorLayerMenu.setVisible(true); |
|
205 |
} |
|
206 |
|
|
207 |
} else if (layer instanceof FLyrRasterSE) { |
|
208 |
FLyrRasterSE rasterLayer = (FLyrRasterSE) layer; |
|
209 |
if (rasterLayer.getBandCount() == 1) |
|
210 |
bCanBeElev = true; |
|
211 |
|
|
212 |
} |
|
213 |
|
|
214 |
if (_type == layer3DImage && bCanBeElev) { |
|
215 |
option = JOptionPane.showConfirmDialog( |
|
216 |
(Component) PluginServices.getMainFrame(), |
|
217 |
PluginServices |
|
218 |
.getText(this, "Elevation_layer_question"), |
|
219 |
PluginServices.getText(this, "Layer_options"), |
|
220 |
JOptionPane.YES_NO_OPTION); |
|
221 |
|
|
222 |
if (option == JOptionPane.YES_OPTION) { |
|
223 |
_type = layer3DElevation; |
|
224 |
} |
|
225 |
} |
|
226 |
} |
|
227 |
} |
|
228 |
|
|
229 |
/** |
|
230 |
* Initialize the cache name for the layer. It uses the terrain type the view projection and the type o coordinates |
|
231 |
* |
|
232 |
* @param terrainType |
|
233 |
* @param viewProj |
|
234 |
* @param geocentricCoordinates |
|
235 |
*/ |
|
236 |
public void initCacheName(int terrainType, IProjection viewProj, |
|
237 |
int geocentricCoordinates) { |
|
238 |
// TODO: use full path of source or service, not just layer name |
|
239 |
|
|
240 |
String typeStr; |
|
241 |
if (terrainType == geocentricCoordinates) |
|
242 |
typeStr = "Sph"; |
|
243 |
else |
|
244 |
typeStr = "Pla" + viewProj.getAbrev(); |
|
245 |
|
|
246 |
if (_type == layer3DElevation) |
|
247 |
typeStr += "Elev"; |
|
248 |
else if (_type == layer3DVector) |
|
249 |
typeStr += "Vect"; |
|
250 |
|
|
251 |
String layerInfo = _layer.getName(); |
|
252 |
// TODO Un toggle this comment to use WMS extension |
|
253 |
|
|
254 |
if (_layer instanceof FLyrWMS) { |
|
255 |
FLyrWMS wmsLayer = (FLyrWMS) _layer; |
|
256 |
|
|
257 |
// Getting wms layer properties |
|
258 |
HashMap props = wmsLayer.getProperties(); |
|
259 |
Vector styles; |
|
260 |
// Getting styles |
|
261 |
styles = (Vector) (props.get("styles")); |
|
262 |
|
|
263 |
// Adding styles to cache path |
|
264 |
String layerStyle = ""; |
|
265 |
if (styles != null) { |
|
266 |
styles.size(); |
|
267 |
for (int i = 0; i < styles.size(); i++) { |
|
268 |
String ele = (String) styles.get(i); |
|
269 |
layerStyle += ele; |
|
270 |
} |
|
271 |
} |
|
272 |
|
|
273 |
layerInfo = wmsLayer.getHost().toString() |
|
274 |
+ wmsLayer.getLayerQuery() + "_" + layerStyle; |
|
275 |
|
|
276 |
} else { |
|
277 |
layerInfo = _layer.getName(); |
|
278 |
} |
|
279 |
/**/ |
|
280 |
_cacheName = typeStr + "_" + layerInfo; |
|
281 |
|
|
282 |
_cacheName = _cacheName.replace('/', '_'); |
|
283 |
_cacheName = _cacheName.replace(':', '_'); |
|
284 |
_cacheName = _cacheName.replace('\\', '_'); |
|
285 |
_cacheName = _cacheName.replace('*', '_'); |
|
286 |
_cacheName = _cacheName.replace('<', '_'); |
|
287 |
_cacheName = _cacheName.replace('>', '_'); |
|
288 |
_cacheName = _cacheName.replace('?', '_'); |
|
289 |
_cacheName = _cacheName.replace('"', '_'); |
|
290 |
_cacheName = _cacheName.replace('|', '_'); |
|
291 |
|
|
292 |
// filter strange characters out of the cache name |
|
293 |
int iChar; |
|
294 |
for (iChar = 0; iChar < _cacheName.length(); iChar++) { |
|
295 |
char c = _cacheName.charAt(iChar); |
|
296 |
boolean bIsLow = (c >= 'a') && (c <= 'z'); |
|
297 |
boolean bIsUp = (c >= 'A') && (c <= 'Z'); |
|
298 |
boolean bIsNum = (c >= '0') && (c <= '9'); |
|
299 |
if (!bIsLow && !bIsUp && !bIsNum && c != '_' && c != '.') { |
|
300 |
int newCInt = java.lang.Math.abs((int) (c) - (int) 'A'); |
|
301 |
newCInt = (newCInt % 26) + (int) 'A'; |
|
302 |
char newC = (char) newCInt; |
|
303 |
_cacheName = _cacheName.replace(c, newC); |
|
304 |
} |
|
305 |
} |
|
306 |
} |
|
307 |
|
|
308 |
/** |
|
309 |
* Return the cacheService of this layer. It depends of the type of the layer. |
|
310 |
* |
|
311 |
* @return |
|
312 |
*/ |
|
313 |
public CacheService getCacheService() { |
|
314 |
return _cacheService; |
|
315 |
} |
|
316 |
|
|
317 |
/** |
|
318 |
* Set the cacheService of this layer. It depends of the type of the layer. |
|
319 |
* |
|
320 |
* @param srv |
|
321 |
*/ |
|
322 |
public void setCacheService(CacheService srv) { |
|
323 |
_cacheService = srv; |
|
324 |
} |
|
325 |
|
|
326 |
/** |
|
327 |
* Set the type of this layer |
|
328 |
* |
|
329 |
* @param type |
|
330 |
*/ |
|
331 |
public void setType(int type) { |
|
332 |
_type = type; |
|
333 |
} |
|
334 |
|
|
335 |
/** |
|
336 |
* Get the type of the layer |
|
337 |
* |
|
338 |
* @return |
|
339 |
*/ |
|
340 |
public int getType() { |
|
341 |
return _type; |
|
342 |
} |
|
343 |
|
|
344 |
/** |
|
345 |
* Set the toc order of this layer |
|
346 |
* |
|
347 |
* @param order |
|
348 |
*/ |
|
349 |
/*public void setTocOrder(int order) { |
|
350 |
m_tocOrder = order; |
|
351 |
}*/ |
|
352 |
|
|
353 |
/** |
|
354 |
* Get the toc order of this layer |
|
355 |
* |
|
356 |
* @return |
|
357 |
*/ |
|
358 |
/*public int getTocOrder() { |
|
359 |
return m_tocOrder; |
|
360 |
}*/ |
|
361 |
|
|
362 |
/** |
|
363 |
* Set the terrain order of this layer |
|
364 |
* |
|
365 |
* @param order |
|
366 |
*/ |
|
367 |
/*public void setTerrainOrder(int order) { |
|
368 |
m_terrainOrder = order; |
|
369 |
}*/ |
|
370 |
|
|
371 |
/** |
|
372 |
* Get the terrain order of this layer |
|
373 |
* |
|
374 |
* @return |
|
375 |
*/ |
|
376 |
/*public int getTerrainOrder() { |
|
377 |
return m_terrainOrder; |
|
378 |
}*/ |
|
379 |
|
|
380 |
/** |
|
381 |
* Get the cache name for this layer |
|
382 |
* |
|
383 |
* @return |
|
384 |
*/ |
|
385 |
public String getCacheName() { |
|
386 |
return _cacheName; |
|
387 |
} |
|
388 |
|
|
389 |
/** |
|
390 |
* Verifies that the vector layer's legend matches the one in the cache |
|
391 |
* folder |
|
392 |
*/ |
|
393 |
public void VerifyLegend(String terrainName) { |
|
394 |
|
|
395 |
|
|
396 |
//NotificationManager.addInfo(m_cacheDir, null); |
|
397 |
if (_layer instanceof Classifiable) { |
|
398 |
Classifiable legendLyr = (Classifiable) _layer; |
|
399 |
String cacheFolder = m_cacheDir + "/" + terrainName + "/" |
|
400 |
+ _cacheName; |
|
401 |
File cacheFolderFile = new File(cacheFolder); |
|
402 |
if (!cacheFolderFile.exists()) |
|
403 |
cacheFolderFile.mkdir(); |
|
404 |
|
|
405 |
String legendFileName = cacheFolder + "/" + "legend.xml"; |
|
406 |
File legendFile = new File(legendFileName); |
|
407 |
|
|
408 |
if (legendFile.exists()) { // read legend |
|
409 |
NotificationManager.addInfo("el fichero existe", null); |
|
410 |
FileReader reader = null; |
|
411 |
try { |
|
412 |
reader = new FileReader(legendFile); |
|
413 |
} catch (FileNotFoundException e) { |
|
414 |
return; |
|
415 |
} |
|
416 |
try { |
|
417 |
XmlTag tag = (XmlTag) XmlTag.unmarshal(reader); |
|
418 |
XMLEntity legendXml = new XMLEntity(tag); |
|
419 |
ILegend legend = LegendFactory.createFromXML(legendXml); |
|
420 |
if (_layer instanceof FLyrVect) { |
|
421 |
((FLyrVect) _layer).setLegend((IVectorLegend) legend); |
|
422 |
} |
|
423 |
|
|
424 |
} catch (Exception e) { |
|
425 |
e.printStackTrace(); |
|
426 |
} |
|
427 |
|
|
428 |
} else { // write legend |
|
429 |
NotificationManager.addInfo("el fichero no existe", null); |
|
430 |
ILegend legend = legendLyr.getLegend(); |
|
431 |
if (legend == null) |
|
432 |
return; |
|
433 |
|
|
434 |
XMLEntity xmlLegend = legend.getXMLEntity(); |
|
435 |
|
|
436 |
try { |
|
437 |
FileWriter writer = new FileWriter(legendFileName); |
|
438 |
Marshaller m = new Marshaller(writer); |
|
439 |
m.setEncoding("ISO-8859-1"); |
|
440 |
m.marshal(xmlLegend.getXmlTag()); |
|
441 |
|
|
442 |
} catch (Exception e) { |
|
443 |
e.printStackTrace(); |
|
444 |
} |
|
445 |
} |
|
446 |
} |
|
447 |
} |
|
448 |
|
|
449 |
// IPersistance |
|
450 |
|
|
451 |
public String getClassName() { |
|
452 |
return this.getClass().getName(); |
|
453 |
} |
|
454 |
|
|
455 |
/* (non-Javadoc) |
|
456 |
* @see com.iver.utiles.IPersistence#getXMLEntity() |
|
457 |
*/ |
|
458 |
public XMLEntity getXMLEntity() { |
|
459 |
XMLEntity xml = new XMLEntity(); |
|
460 |
|
|
461 |
xml.putProperty("type", _type); |
|
462 |
//xml.putProperty("order", m_tocOrder); |
|
463 |
xml.putProperty("opacity", _opacity); |
|
464 |
xml.putProperty("heigth", _height); |
|
465 |
xml.putProperty("cacheName", _cacheName); |
|
466 |
return xml; |
|
467 |
} |
|
468 |
|
|
469 |
/* (non-Javadoc) |
|
470 |
* @see com.iver.utiles.IPersistence#setXMLEntity(com.iver.utiles.XMLEntity) |
|
471 |
*/ |
|
472 |
public void setXMLEntity(XMLEntity xml) { |
|
473 |
if (xml.contains("type")) { |
|
474 |
_bChooseType = false; |
|
475 |
_type = xml.getIntProperty("type"); |
|
476 |
} |
|
477 |
/*if (xml.contains("order")) |
|
478 |
m_tocOrder = xml.getIntProperty("order");*/ |
|
479 |
if (xml.contains("opacity")) |
|
480 |
_opacity = Float.parseFloat(xml.getStringProperty("opacity")); |
|
481 |
if (xml.contains("heigth")) |
|
482 |
_height = Float.parseFloat(xml.getStringProperty("heigth")); |
|
483 |
if (xml.contains("cacheName")) |
|
484 |
_cacheName = xml.getStringProperty("cacheName"); |
|
485 |
} |
|
486 |
|
|
487 |
/** |
|
488 |
* Return the opacity of this layer |
|
489 |
* |
|
490 |
* @return |
|
491 |
*/ |
|
492 |
public float getOpacity() { |
|
493 |
return _opacity; |
|
494 |
} |
|
495 |
|
|
496 |
/** |
|
497 |
* Set the opacity of this layer |
|
498 |
* |
|
499 |
* @param A value between 0 and 1 |
|
500 |
*/ |
|
501 |
public void setOpacity(float m_opacity) { |
|
502 |
this._opacity = m_opacity; |
|
503 |
} |
|
504 |
|
|
505 |
/** |
|
506 |
* Get the vertical exaggeration for this layer |
|
507 |
* |
|
508 |
* @return |
|
509 |
*/ |
|
510 |
public float getVerticalEx() { |
|
511 |
return _verticalEx; |
|
512 |
} |
|
513 |
|
|
514 |
/** |
|
515 |
* Get the vertical exaggeration from this layer |
|
516 |
* |
|
517 |
* @param ex |
|
518 |
*/ |
|
519 |
public void setVerticalEx(float ex) { |
|
520 |
_verticalEx = ex; |
|
521 |
} |
|
522 |
|
|
523 |
/** |
|
524 |
* Get the height that this layer has when it draws in 3D |
|
525 |
* |
|
526 |
* @return |
|
527 |
*/ |
|
528 |
public float getHeight() { |
|
529 |
return _height; |
|
530 |
} |
|
531 |
|
|
532 |
/** |
|
533 |
* Set the height that this layer has when it draws in 3D |
|
534 |
* |
|
535 |
* @param heigth |
|
536 |
*/ |
|
537 |
public void setHeight(float heigth) { |
|
538 |
this._height = heigth; |
|
539 |
} |
|
540 |
|
|
541 |
/** |
|
542 |
* If the features of this layer have z value this method will return true. In the other case it will return false |
|
543 |
* |
|
544 |
* @return |
|
545 |
*/ |
|
546 |
public boolean isZEnable() { |
|
547 |
return _zEnable; |
|
548 |
} |
|
549 |
|
|
550 |
/** |
|
551 |
* Set the z enable |
|
552 |
* |
|
553 |
* @param zenable |
|
554 |
*/ |
|
555 |
public void setZEnable(boolean zEnable) { |
|
556 |
_zEnable = zEnable; |
|
557 |
} |
|
558 |
|
|
559 |
/** |
|
560 |
* It is to know if this layer is new. It only works with the OSG layers |
|
561 |
* |
|
562 |
* @return |
|
563 |
*/ |
|
564 |
public boolean isNewLayerOSG() { |
|
565 |
return newLayerOSG; |
|
566 |
} |
|
567 |
|
|
568 |
/** |
|
569 |
* Set if this layer is new. It only works with OSG layers. |
|
570 |
* |
|
571 |
* @param newLayerOSG |
|
572 |
*/ |
|
573 |
public void setNewLayerOSG(boolean newLayerOSG) { |
|
574 |
this.newLayerOSG = newLayerOSG; |
|
575 |
} |
|
576 |
|
|
577 |
} |
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/camera/ProjectCamera.java | ||
---|---|---|
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.camera; |
|
42 |
|
|
43 |
import org.gvsig.osgvp.core.osg.Vec3; |
|
44 |
import org.gvsig.osgvp.viewer.Camera; |
|
45 |
|
|
46 |
import com.iver.utiles.IPersistence; |
|
47 |
import com.iver.utiles.XMLEntity; |
|
48 |
|
|
49 |
/** |
|
50 |
* This class is used to manage the cameras that the "herramienta de encuades" |
|
51 |
* needs like a data model |
|
52 |
* |
|
53 |
* @author |
|
54 |
*/ |
|
55 |
public class ProjectCamera implements IPersistence { |
|
56 |
// private Object camera; |
|
57 |
|
|
58 |
private Camera camera; |
|
59 |
|
|
60 |
private String description; |
|
61 |
|
|
62 |
/** |
|
63 |
* Return the description |
|
64 |
* |
|
65 |
* @return description of the camera |
|
66 |
*/ |
|
67 |
public String getDescription() { |
|
68 |
return description; |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Set the description |
|
73 |
* |
|
74 |
* @param the |
|
75 |
* description of the camera |
|
76 |
*/ |
|
77 |
public void setDescription(String string) { |
|
78 |
description = string; |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* @see java.lang.Object#toString() |
|
83 |
*/ |
|
84 |
public String toString() { |
|
85 |
return description; |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Return the camera object |
|
90 |
* |
|
91 |
* @return camera object |
|
92 |
*/ |
|
93 |
public Camera getCamera() { |
|
94 |
return camera; |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* Set the camera object |
|
99 |
* |
|
100 |
* @param the camera object |
|
101 |
*/ |
|
102 |
public void setCamera(Camera camera) { |
|
103 |
this.camera = camera; |
|
104 |
} |
|
105 |
|
|
106 |
/* (non-Javadoc) |
|
107 |
* @see com.iver.utiles.IPersistence#getClassName() |
|
108 |
*/ |
|
109 |
public String getClassName() { |
|
110 |
return this.getClass().getName(); |
|
111 |
} |
|
112 |
|
|
113 |
/* (non-Javadoc) |
|
114 |
* @see com.iver.utiles.IPersistence#getXMLEntity() |
|
115 |
*/ |
|
116 |
public XMLEntity getXMLEntity() { |
|
117 |
XMLEntity xml = new XMLEntity(); |
|
118 |
xml.putProperty("className", this.getClassName()); |
|
119 |
|
|
120 |
xml.putProperty("description", this.getDescription()); |
|
121 |
// Saving camera propeties |
|
122 |
|
|
123 |
// Eye |
|
124 |
xml.putProperty("eyeX", this.camera.getEye().x()); |
|
125 |
xml.putProperty("eyeY", this.camera.getEye().y()); |
|
126 |
xml.putProperty("eyeZ", this.camera.getEye().z()); |
|
127 |
// Center |
|
128 |
xml.putProperty("centerX", this.camera.getCenter().x()); |
|
129 |
xml.putProperty("centerY", this.camera.getCenter().y()); |
|
130 |
xml.putProperty("centerZ", this.camera.getCenter().z()); |
|
131 |
// Up |
|
132 |
xml.putProperty("upX", this.camera.getUp().x()); |
|
133 |
xml.putProperty("upY", this.camera.getUp().y()); |
|
134 |
xml.putProperty("upZ", this.camera.getUp().z()); |
|
135 |
|
|
136 |
return xml; |
|
137 |
} |
|
138 |
|
|
139 |
/* (non-Javadoc) |
|
140 |
* @see com.iver.utiles.IPersistence#setXMLEntity(com.iver.utiles.XMLEntity) |
|
141 |
*/ |
|
142 |
public void setXMLEntity(XMLEntity xml) { |
|
143 |
if (xml.contains("description")) |
|
144 |
this.setDescription(xml.getStringProperty("description")); |
|
145 |
|
|
146 |
// Getting camera properties |
|
147 |
camera = new Camera(); |
|
148 |
|
|
149 |
// Variables auxiliares |
|
150 |
Vec3 center = new Vec3(), eye = new Vec3(), up = new Vec3(); |
|
151 |
|
|
152 |
// Eye |
|
153 |
if (xml.contains("eyeX")) |
|
154 |
eye.setX(xml.getDoubleProperty("eyeX")); |
|
155 |
if (xml.contains("eyeY")) |
|
156 |
eye.setY(xml.getDoubleProperty("eyeY")); |
|
157 |
if (xml.contains("eyeZ")) |
|
158 |
eye.setZ(xml.getDoubleProperty("eyeZ")); |
|
159 |
|
|
160 |
// Center |
|
161 |
if (xml.contains("centerX")) |
|
162 |
center.setX(xml.getDoubleProperty("centerX")); |
|
163 |
if (xml.contains("centerY")) |
|
164 |
center.setY(xml.getDoubleProperty("centerY")); |
|
165 |
if (xml.contains("centerZ")) |
|
166 |
center.setZ(xml.getDoubleProperty("centerZ")); |
|
167 |
|
|
168 |
// Up |
|
169 |
if (xml.contains("upX")) |
|
170 |
up.setX(xml.getDoubleProperty("upX")); |
|
171 |
if (xml.contains("upY")) |
|
172 |
up.setY(xml.getDoubleProperty("upY")); |
|
173 |
if (xml.contains("upZ")) |
|
174 |
up.setZ(xml.getDoubleProperty("upZ")); |
|
175 |
|
|
176 |
this.camera.setViewByLookAt(eye, center, up); |
|
177 |
|
|
178 |
} |
|
179 |
} |
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/resources/MyFileFilter3D.java | ||
---|---|---|
1 |
package com.iver.ai2.gvsig3d.resources; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
import javax.swing.filechooser.FileFilter; |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
* @version 14/08/2007 |
|
10 |
* @author Angel Fraile |
|
11 |
* |
|
12 |
*/ |
|
13 |
public class MyFileFilter3D extends FileFilter { |
|
14 |
|
|
15 |
private String[] extensiones = new String[1]; |
|
16 |
private String description; |
|
17 |
private boolean dirs = true; |
|
18 |
private String info = null; |
|
19 |
|
|
20 |
public MyFileFilter3D(String[] ext, String desc) { |
|
21 |
extensiones = ext; |
|
22 |
description = desc; |
|
23 |
} |
|
24 |
|
|
25 |
public MyFileFilter3D(String[] ext, String desc, String info) { |
|
26 |
extensiones = ext; |
|
27 |
description = desc; |
|
28 |
this.info = info; |
|
29 |
} |
|
30 |
|
|
31 |
public MyFileFilter3D(String ext, String desc) { |
|
32 |
extensiones[0] = ext; |
|
33 |
description = desc; |
|
34 |
} |
|
35 |
|
|
36 |
public MyFileFilter3D(String ext, String desc, String info) { |
|
37 |
extensiones[0] = ext; |
|
38 |
description = desc; |
|
39 |
this.info = info; |
|
40 |
} |
|
41 |
|
|
42 |
public MyFileFilter3D(String ext, String desc, boolean dirs) { |
|
43 |
extensiones[0] = ext; |
|
44 |
description = desc; |
|
45 |
this.dirs = dirs; |
|
46 |
} |
|
47 |
|
|
48 |
public MyFileFilter3D(String ext, String desc, boolean dirs, String info) { |
|
49 |
extensiones[0] = ext; |
|
50 |
description = desc; |
|
51 |
this.dirs = dirs; |
|
52 |
this.info = info; |
|
53 |
} |
|
54 |
|
|
55 |
public boolean accept(File f) { |
|
56 |
if (f.isDirectory()) { |
|
57 |
if (dirs) { |
|
58 |
return true; |
|
59 |
} else { |
|
60 |
return false; |
|
61 |
} |
|
62 |
} |
|
63 |
for (int i = 0; i < extensiones.length; i++) { |
|
64 |
if (extensiones[i].equals("")) { |
|
65 |
continue; |
|
66 |
} |
|
67 |
if (getExtensionOfAFile(f).equalsIgnoreCase(extensiones[i])) { |
|
68 |
return true; |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
return false; |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* @see javax.swing.filechooser.FileFilter#getDescription() |
|
77 |
*/ |
|
78 |
public String getDescription() { |
|
79 |
return description; |
|
80 |
} |
|
81 |
|
|
82 |
public String[] getExtensions() { |
|
83 |
return extensiones; |
|
84 |
} |
|
85 |
|
|
86 |
public boolean isDirectory() { |
|
87 |
return dirs; |
|
88 |
} |
|
89 |
|
|
90 |
private String getExtensionOfAFile(File file) { |
|
91 |
String name; |
|
92 |
int dotPos; |
|
93 |
name = file.getName(); |
|
94 |
dotPos = name.lastIndexOf("."); |
|
95 |
if (dotPos < 1) { |
|
96 |
return ""; |
|
97 |
} |
|
98 |
return name.substring(dotPos + 1); |
|
99 |
} |
|
100 |
|
|
101 |
public File normalizeExtension(File file) { |
|
102 |
String ext = getExtensionOfAFile(file); |
|
103 |
if (ext.equals("") || !(this.accept(file))) { |
|
104 |
return new File(file.getAbsolutePath() + "." + extensiones[0]); |
|
105 |
} |
|
106 |
return file; |
|
107 |
} |
|
108 |
|
|
109 |
public String getInfo() { |
|
110 |
return this.info; |
|
111 |
} |
|
112 |
|
|
113 |
public void setInfo(String info) { |
|
114 |
this.info = info; |
|
115 |
} |
|
116 |
|
|
117 |
} |
|
118 |
|
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/resources/ResourcesFactory.java | ||
---|---|---|
1 |
package com.iver.ai2.gvsig3d.resources; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
|
|
5 |
/** |
|
6 |
* @author Julio Campos |
|
7 |
* |
|
8 |
* This class is a factory to find resources in 3D extensions |
|
9 |
* |
|
10 |
*/ |
|
11 |
public class ResourcesFactory { |
|
12 |
|
|
13 |
private static String textPath; |
|
14 |
|
|
15 |
private static String extPath; |
|
16 |
|
|
17 |
static { |
|
18 |
extPath = File.separator+"gvSIG"+File.separator+"extensiones"+File.separator+"org.gvsig.ext3Dgui"+File.separator+"resources"+File.separator; |
|
19 |
|
|
20 |
textPath = System.getProperty("user.dir") + extPath; |
|
21 |
} |
|
22 |
|
|
23 |
/** |
|
24 |
* Method to get Path resources directory |
|
25 |
* |
|
26 |
* @return |
|
27 |
*/ |
|
28 |
public static String getResourcesPath() { |
|
29 |
return textPath; |
|
30 |
} |
|
31 |
|
|
32 |
/** |
|
33 |
* Method to get path to specific resource |
|
34 |
* |
|
35 |
* @param name |
|
36 |
* Name of resource |
|
37 |
* @return All path resource |
|
38 |
*/ |
|
39 |
public static String getResourcePath(String name) { |
|
40 |
return textPath + name; |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* Method to get a list of all resources |
|
45 |
* |
|
46 |
* @return String array with all resources |
|
47 |
*/ |
|
48 |
public static String[] getResources() { |
|
49 |
String[] resourcesList; |
|
50 |
|
|
51 |
File dir = new File(ResourcesFactory.getResourcesPath()); |
|
52 |
|
|
53 |
resourcesList = dir.list(); |
|
54 |
if (resourcesList == null) { |
|
55 |
// Either dir does not exist or is not a directory |
|
56 |
} else { |
|
57 |
for (int i = 0; i < resourcesList.length; i++) { |
|
58 |
// Get filename of file or directory |
|
59 |
String filename = resourcesList[i]; |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
return resourcesList; |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* Method to verify if this resource exits |
|
68 |
* |
|
69 |
* @param name |
|
70 |
* Name of resource |
|
71 |
* @return True or false |
|
72 |
*/ |
|
73 |
public static boolean exitsResouce(String name) { |
|
74 |
boolean exit = false; |
|
75 |
String[] resourcesList = ResourcesFactory.getResources(); |
|
76 |
if (resourcesList != null) { |
|
77 |
|
|
78 |
for (int i = 0; i < resourcesList.length; i++) { |
|
79 |
// Get filename of file or directory |
|
80 |
String filename = resourcesList[i]; |
|
81 |
if (filename.equals(name)) |
|
82 |
return true; |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
return exit; |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Method to set the extension path |
|
91 |
* |
|
92 |
* @param extPath |
|
93 |
*/ |
|
94 |
public static void setExtPath(String extPath) { |
|
95 |
ResourcesFactory.extPath = extPath; |
|
96 |
textPath = System.getProperty("user.dir") + extPath; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Method to get the extension path |
|
101 |
* |
|
102 |
* @param extPath |
|
103 |
*/ |
|
104 |
public static String getExtPath() { |
|
105 |
return ResourcesFactory.extPath; |
|
106 |
} |
|
107 |
} |
1.10/tags/gvSIG_3D_Animation_1_10_build_21_FINAL/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/extrusion/SymbolTableExtrusion.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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 com.iver.ai2.gvsig3d.legend.extrusion; |
|
20 |
|
|
21 |
import java.awt.Component; |
|
22 |
import java.awt.Dimension; |
|
23 |
import java.awt.GridLayout; |
|
24 |
import java.awt.Point; |
|
25 |
import java.awt.Rectangle; |
|
26 |
import java.awt.event.ActionListener; |
|
27 |
import java.awt.event.MouseAdapter; |
|
28 |
import java.awt.event.MouseEvent; |
|
29 |
import java.util.ArrayList; |
|
30 |
import java.util.Hashtable; |
|
31 |
|
|
32 |
import javax.swing.JPanel; |
|
33 |
import javax.swing.JScrollPane; |
|
34 |
import javax.swing.event.ChangeEvent; |
|
35 |
import javax.swing.table.DefaultTableModel; |
|
36 |
import javax.swing.table.TableCellEditor; |
|
37 |
import javax.swing.table.TableColumn; |
|
38 |
|
|
39 |
import com.hardcode.gdbms.engine.values.NullValue; |
|
40 |
import com.iver.andami.PluginServices; |
|
41 |
import com.iver.andami.ui.mdiFrame.JMenuItem; |
|
42 |
import com.iver.andami.ui.mdiFrame.JPopUpMenu; |
|
43 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
44 |
import com.iver.cit.gvsig.fmap.rendering.NullIntervalValue; |
|
45 |
import com.iver.cit.gvsig.fmap.rendering.NullUniqueValue; |
|
46 |
import com.iver.cit.gvsig.project.documents.gui.SymbolCellEditor; |
|
47 |
import com.iver.cit.gvsig.project.documents.gui.TableSymbolCellRenderer; |
|
48 |
import com.iver.cit.gvsig.project.documents.view.legend.edition.gui.IntervalCellEditor; |
|
49 |
import com.iver.cit.gvsig.project.documents.view.legend.edition.gui.ValueCellEditor; |
|
50 |
|
|
51 |
|
|
52 |
import com.iver.utiles.swing.jtable.JTable; |
|
53 |
import com.iver.utiles.swing.jtable.TextFieldCellEditor; |
|
54 |
|
|
55 |
public class SymbolTableExtrusion extends JPanel { |
|
56 |
private static final long serialVersionUID = -8694846716328735113L; |
|
57 |
private static Hashtable<String,TableCellEditor> cellEditors = new Hashtable<String,TableCellEditor>(); |
|
58 |
|
|
59 |
public static final String VALUES_TYPE = "values"; |
|
60 |
public static final String INTERVALS_TYPE = "intervals"; |
|
61 |
private JTable table; |
|
62 |
private String type; |
|
63 |
private int shapeType; |
|
64 |
private OnTableMouseAdapter rightClickActions; |
|
65 |
|
|
66 |
/** |
|
67 |
* Crea un nuevo FSymbolTable. |
|
68 |
* |
|
69 |
* @param type |
|
70 |
* tipo de valor si es intervalo: "intervals" y si es por |
|
71 |
* valores: "values". |
|
72 |
*/ |
|
73 |
public SymbolTableExtrusion(Component ownerComponent, String type, int shapeType) { |
|
74 |
super(new GridLayout(1, 0)); |
|
75 |
this.type = type; |
|
76 |
this.shapeType = shapeType; |
|
77 |
|
|
78 |
rightClickActions = new OnTableMouseAdapter(); |
|
79 |
table = new JTable(); |
|
80 |
table.setModel(new MyTableModel()); |
|
81 |
table.setPreferredScrollableViewportSize(new Dimension(480, 110)); |
|
82 |
|
|
83 |
initializeCellEditors(); |
|
84 |
|
|
85 |
// Create the scroll pane and add the table to it. |
|
86 |
JScrollPane scrollPane = new JScrollPane(table); |
|
87 |
|
|
88 |
// Set up column sizes. |
|
89 |
// initColumnSizes(table); |
|
90 |
setUpSymbolColumn(table, table.getColumnModel().getColumn(0)); |
|
91 |
|
|
92 |
if(cellEditors.get(type) == null) |
|
93 |
throw new Error("Symbol table type not set!"); |
|
94 |
|
|
95 |
setUpValueColumn(table, table.getColumnModel().getColumn(0),cellEditors.get(this.type)); |
|
96 |
setUpLabelColumn(table, table.getColumnModel().getColumn(1)); |
|
97 |
|
|
98 |
// Add the scroll pane to this panel. |
|
99 |
add(scrollPane); |
|
100 |
table.setRowSelectionAllowed(true); |
|
101 |
table.addMouseListener(rightClickActions); |
|
102 |
} |
|
103 |
/** |
|
104 |
* Inicializa los valores de los CellEditors que la SymbolTable poseer? por defecto |
|
105 |
*/ |
|
106 |
private void initializeCellEditors() { |
|
107 |
this.cellEditors.put(this.INTERVALS_TYPE,new IntervalCellEditor()); |
|
108 |
this.cellEditors.put(this.VALUES_TYPE, new ValueCellEditor()); |
|
109 |
} |
|
110 |
/** |
|
111 |
* A?ade un nuevo CellEditor a la lista de disponibles |
|
112 |
* |
|
113 |
* @param key String con el nombre identificativo del CellEditor |
|
114 |
* @param cellEditor CellEditor que va a ser a?adido |
|
115 |
*/ |
|
116 |
public static void addCellEditor(String key,TableCellEditor cellEditor ) { |
|
117 |
cellEditors.put(key, cellEditor); |
|
118 |
} |
|
119 |
/** |
|
120 |
* Obtiene el valor de los elementos de una fila seleccionada |
|
121 |
* |
|
122 |
* @return Object[] Array con los objetos de cada una de las columnas de la fila seleccionada |
|
123 |
*/ |
|
124 |
public Object[] getSelectedRowElements() { |
|
125 |
Object[] values = new Object[2]; |
|
126 |
|
|
127 |
MyTableModel m = (MyTableModel) table.getModel(); |
Also available in: Unified diff