Revision 32756
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/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 |
} |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/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 |
|
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/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 |
} |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/ExtrusionLineSymbol.java | ||
---|---|---|
1 |
package com.iver.ai2.gvsig3d.legend.symbols; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol; |
|
4 |
|
|
5 |
public class ExtrusionLineSymbol extends SimpleLineSymbol implements IExtrusionSymbol { |
|
6 |
|
|
7 |
|
|
8 |
private double extrusion = 0.0; |
|
9 |
|
|
10 |
public ExtrusionLineSymbol() { |
|
11 |
// TODO Auto-generated constructor stub |
|
12 |
} |
|
13 |
|
|
14 |
public double getExtrusion() { |
|
15 |
return this.extrusion; |
|
16 |
} |
|
17 |
|
|
18 |
public void setExtrusion(double extrusion) { |
|
19 |
this.extrusion = extrusion; |
|
20 |
} |
|
21 |
|
|
22 |
|
|
23 |
} |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/ExtrusionPolygonSymbol.java | ||
---|---|---|
1 |
package com.iver.ai2.gvsig3d.legend.symbols; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
|
4 |
|
|
5 |
public class ExtrusionPolygonSymbol extends SimpleFillSymbol implements |
|
6 |
IExtrusionSymbol { |
|
7 |
|
|
8 |
private double extrusion = 0.0; |
|
9 |
|
|
10 |
public ExtrusionPolygonSymbol() { |
|
11 |
// TODO Auto-generated constructor stub |
|
12 |
} |
|
13 |
|
|
14 |
public double getExtrusion() { |
|
15 |
return this.extrusion; |
|
16 |
} |
|
17 |
|
|
18 |
public void setExtrusion(double extrusion) { |
|
19 |
this.extrusion = extrusion; |
|
20 |
} |
|
21 |
|
|
22 |
} |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/IExtrusionSymbol.java | ||
---|---|---|
1 |
package com.iver.ai2.gvsig3d.legend.symbols; |
|
2 |
|
|
3 |
public interface IExtrusionSymbol { |
|
4 |
|
|
5 |
public void setExtrusion(double extrusion); |
|
6 |
|
|
7 |
public double getExtrusion(); |
|
8 |
|
|
9 |
} |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/Object3DMarker.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 |
* 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.legend.symbols; |
|
42 |
|
|
43 |
import java.awt.Component; |
|
44 |
import java.awt.Dimension; |
|
45 |
import java.awt.GridBagConstraints; |
|
46 |
import java.awt.GridBagLayout; |
|
47 |
import java.awt.event.ActionEvent; |
|
48 |
import java.awt.event.ActionListener; |
|
49 |
import java.awt.event.KeyEvent; |
|
50 |
import java.awt.event.KeyListener; |
|
51 |
import java.awt.event.MouseEvent; |
|
52 |
import java.awt.event.MouseListener; |
|
53 |
import java.io.File; |
|
54 |
import java.io.FileNotFoundException; |
|
55 |
import java.io.IOException; |
|
56 |
import java.util.ArrayList; |
|
57 |
import java.util.Iterator; |
|
58 |
import java.util.List; |
|
59 |
|
|
60 |
import javax.swing.JButton; |
|
61 |
import javax.swing.JCheckBox; |
|
62 |
import javax.swing.JFileChooser; |
|
63 |
import javax.swing.JLabel; |
|
64 |
import javax.swing.JOptionPane; |
|
65 |
import javax.swing.JPanel; |
|
66 |
import javax.swing.JTextField; |
|
67 |
import javax.swing.filechooser.FileFilter; |
|
68 |
|
|
69 |
import org.gvsig.osgvp.core.osg.Group; |
|
70 |
import org.gvsig.osgvp.core.osg.Node; |
|
71 |
import org.gvsig.osgvp.core.osg.Vec3; |
|
72 |
import org.gvsig.osgvp.core.osgdb.osgDB; |
|
73 |
import org.gvsig.osgvp.exceptions.node.LoadNodeException; |
|
74 |
import org.gvsig.osgvp.viewer.IViewerContainer; |
|
75 |
import org.gvsig.osgvp.viewer.ViewerFactory; |
|
76 |
|
|
77 |
import com.iver.ai2.gvsig3d.resources.MyFileFilter3D; |
|
78 |
import com.iver.andami.PluginServices; |
|
79 |
import com.iver.andami.messages.NotificationManager; |
|
80 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
81 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
82 |
import com.iver.cit.gvsig.fmap.core.symbols.SymbolDrawingException; |
|
83 |
import com.iver.cit.gvsig.gui.styling.AbstractTypeSymbolEditor; |
|
84 |
import com.iver.cit.gvsig.gui.styling.EditorTool; |
|
85 |
import com.iver.cit.gvsig.gui.styling.Mask; |
|
86 |
import com.iver.cit.gvsig.gui.styling.SymbolEditor; |
|
87 |
|
|
88 |
/** |
|
89 |
* PictureMarker allows the user to store and modify the properties that define |
|
90 |
* a <b>picture marker symbol</b>. |
|
91 |
* <p> |
|
92 |
* <p> |
|
93 |
* This functionality is carried out thanks to a tab (simple marker)which is |
|
94 |
* included in the panel to edit the properities of a symbol (SymbolEditor)how |
|
95 |
* is explained in AbstractTypeSymbolEditor. |
|
96 |
* <p> |
|
97 |
* First of all, in the above mentioned tab the user will have options to change |
|
98 |
* the files from where the pictures for the symbol are taken (one for the |
|
99 |
* symbol when it is not selected in the map and the other when it is done). |
|
100 |
* <p> |
|
101 |
* <p> |
|
102 |
* Secondly, the user will have options to modify the pictures which had been |
|
103 |
* selected before (width and offset) . |
|
104 |
* |
|
105 |
*@see AbstractTypeSymbolEditor |
|
106 |
*@author jaume dominguez faus - jaume.dominguez@iver.es |
|
107 |
*@author julio campos |
|
108 |
*@author jesus zarzoso |
|
109 |
*/ |
|
110 |
public class Object3DMarker extends AbstractTypeSymbolEditor implements |
|
111 |
ActionListener, KeyListener { |
|
112 |
protected ArrayList<JPanel> tabs = new ArrayList<JPanel>(); |
|
113 |
protected Mask mask; |
|
114 |
protected JLabel lblFileName; |
|
115 |
protected JLabel lblSelFileName; |
|
116 |
private JButton btn; |
|
117 |
private File fileOSG; |
|
118 |
private String filePath = ""; |
|
119 |
private double _scaleX = 1.0, _scaleY = 1.0, _scaleZ = 1.0, _rotX = 0, |
|
120 |
_rotY = 0, _rotZ = 0; |
|
121 |
|
|
122 |
private static String lastPath = ""; |
|
123 |
|
|
124 |
private IViewerContainer _canvas3d; |
|
125 |
private JPanel topPanel; |
|
126 |
private JPanel leftBottomPanel; |
|
127 |
private JPanel rigthBottomPanel; |
|
128 |
private JTextField rotationTextFieldX; |
|
129 |
private JTextField scaleTextFieldX; |
|
130 |
private JTextField rotationTextFieldZ; |
|
131 |
private JTextField rotationTextFieldY; |
|
132 |
private JTextField scaleTextFieldY; |
|
133 |
private JTextField scaleTextFieldZ; |
|
134 |
private JTextField filePathTextField; |
|
135 |
private JCheckBox autorotate; |
|
136 |
private String tempScreenshotimage; |
|
137 |
private Object3DMarkerSymbol _symbol; |
|
138 |
|
|
139 |
public Object3DMarker(SymbolEditor owner) { |
|
140 |
super(owner); |
|
141 |
initialize(); |
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
@Override |
|
146 |
protected void finalize() throws Throwable { |
|
147 |
super.finalize(); |
|
148 |
|
|
149 |
ViewerFactory.getInstance().stopAnimator(); |
|
150 |
_canvas3d.dispose(); |
|
151 |
|
|
152 |
} |
|
153 |
|
|
154 |
public String getFilePath() { |
|
155 |
return filePath; |
|
156 |
} |
|
157 |
|
|
158 |
public void setFilePath(String filePath) { |
|
159 |
this.filePath = filePath; |
|
160 |
if (filePathTextField != null) |
|
161 |
filePathTextField.setText(filePath); |
|
162 |
} |
|
163 |
|
|
164 |
/** |
|
165 |
* Initializes the parameters that define a picturmarker.To do it, a tab is |
|
166 |
* created inside the SymbolEditor panel with default values for the |
|
167 |
* different attributes of the picture marker. |
|
168 |
*/ |
|
169 |
|
|
170 |
private void initialize() { |
|
171 |
JPanel myTab = new JPanel(new GridBagLayout()); |
|
172 |
myTab.setName("3D Object"); |
|
173 |
|
|
174 |
// Top panel |
|
175 |
GridBagConstraints topPanelConstrain = new GridBagConstraints(); |
|
176 |
topPanelConstrain.gridx = 0; |
|
177 |
topPanelConstrain.gridy = 0; |
|
178 |
topPanelConstrain.gridwidth = 2; |
|
179 |
topPanelConstrain.fill = GridBagConstraints.BOTH; |
|
180 |
topPanelConstrain.weightx = 1.0; |
|
181 |
topPanelConstrain.weighty = 1.0; |
|
182 |
myTab.add(getTopPanel(), topPanelConstrain); |
|
183 |
|
|
184 |
// bottom left panel |
|
185 |
GridBagConstraints leftBottomPanelConstrain = new GridBagConstraints(); |
|
186 |
leftBottomPanelConstrain.gridx = 0; |
|
187 |
leftBottomPanelConstrain.gridy = 1; |
|
188 |
leftBottomPanelConstrain.fill = GridBagConstraints.BOTH; |
|
189 |
leftBottomPanelConstrain.weightx = 0.5; |
|
190 |
leftBottomPanelConstrain.weighty = 1.0; |
|
191 |
myTab.add(getLeftBottomPanel(), leftBottomPanelConstrain); |
|
192 |
|
|
193 |
// Bottom right panel |
|
194 |
GridBagConstraints rigthBottomPanelConstrain = new GridBagConstraints(); |
|
195 |
rigthBottomPanelConstrain.gridx = 1; |
|
196 |
rigthBottomPanelConstrain.gridy = 1; |
|
197 |
rigthBottomPanelConstrain.fill = GridBagConstraints.BOTH; |
|
198 |
rigthBottomPanelConstrain.weightx = 0.5; |
|
199 |
rigthBottomPanelConstrain.weighty = 1.0; |
|
200 |
myTab.add(getRigthBottomPanel(), rigthBottomPanelConstrain); |
|
201 |
|
|
202 |
tabs.add(myTab); |
|
203 |
|
|
204 |
PluginServices core = PluginServices.getPluginServices("com.iver.core"); |
|
205 |
if (core != null) { |
|
206 |
if (core.getPersistentXML().contains("DataFolder")) { |
|
207 |
|
|
208 |
lastPath = core.getPersistentXML().getStringProperty( |
|
209 |
"DataFolder"); |
|
210 |
} |
|
211 |
|
|
212 |
} |
|
213 |
|
|
214 |
} |
|
215 |
|
|
216 |
private ActionListener chooseAction = new ActionListener() { |
|
217 |
|
|
218 |
public void actionPerformed(ActionEvent e) { |
|
219 |
|
|
220 |
JFileChooser jfc = new JFileChooser(lastPath); |
|
221 |
jfc.removeChoosableFileFilter(jfc.getAcceptAllFileFilter()); |
|
222 |
|
|
223 |
List<MyFileFilter3D> filterListFile = new ArrayList<MyFileFilter3D>(); |
|
224 |
|
|
225 |
filterListFile.add(new MyFileFilter3D("ive", PluginServices |
|
226 |
.getText(this, "Ficheros *.ive"), "ive")); |
|
227 |
filterListFile.add(new MyFileFilter3D("3ds", PluginServices |
|
228 |
.getText(this, "Ficheros *.3ds"), "3ds")); |
|
229 |
filterListFile.add(new MyFileFilter3D("obj", PluginServices |
|
230 |
.getText(this, "Ficheros *.obj"), "obj")); |
|
231 |
filterListFile.add(new MyFileFilter3D("osg", PluginServices |
|
232 |
.getText(this, "Ficheros *.osg"), "osg")); |
|
233 |
|
|
234 |
Iterator<MyFileFilter3D> iter = filterListFile.iterator(); |
|
235 |
while (iter.hasNext()) { |
|
236 |
jfc.addChoosableFileFilter((FileFilter) iter.next()); |
|
237 |
} |
|
238 |
|
|
239 |
if (jfc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
|
240 |
|
|
241 |
fileOSG = jfc.getSelectedFile(); |
|
242 |
if (fileOSG.exists()) { |
|
243 |
|
|
244 |
MyFileFilter3D filter = (MyFileFilter3D) jfc |
|
245 |
.getFileFilter(); |
|
246 |
fileOSG = filter.normalizeExtension(fileOSG); |
|
247 |
filePath = fileOSG.getAbsolutePath(); |
|
248 |
filePathTextField.setText(filePath); |
|
249 |
loadFile(); |
|
250 |
lastPath = fileOSG.getPath(); |
|
251 |
fireSymbolChangedEvent(); |
|
252 |
} else { |
|
253 |
JOptionPane.showMessageDialog(null, |
|
254 |
"El fichero no existe.", "Fichero no encontrado", |
|
255 |
JOptionPane.WARNING_MESSAGE); |
|
256 |
return; |
|
257 |
} |
|
258 |
}// If aprove option. |
|
259 |
|
|
260 |
} |
|
261 |
|
|
262 |
}; |
|
263 |
|
|
264 |
private JPanel getTopPanel() { |
|
265 |
if (topPanel == null) { |
|
266 |
topPanel = new JPanel(new GridBagLayout()); |
|
267 |
// topPanel.setBorder(new LineBorder(Color.gray)); |
|
268 |
GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); |
|
269 |
gridBagConstraints.gridx = 0; |
|
270 |
gridBagConstraints.gridy = 0; |
|
271 |
gridBagConstraints.anchor = GridBagConstraints.WEST; |
|
272 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 5); |
|
273 |
// picture file label |
|
274 |
lblFileName = new JLabel("Seleccione fichero :"); |
|
275 |
// lblFileName.setFont(lblFileName.getFont().deriveFont(Font.BOLD)); |
|
276 |
|
|
277 |
topPanel.add(lblFileName, gridBagConstraints); |
|
278 |
|
|
279 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
280 |
gridBagConstraints.gridx = 0; |
|
281 |
gridBagConstraints.gridy = 1; |
|
282 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
283 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 5); |
|
284 |
gridBagConstraints.weightx = 0.75; |
|
285 |
|
|
286 |
filePathTextField = new JTextField(); |
|
287 |
topPanel.add(filePathTextField, gridBagConstraints); |
|
288 |
if (lastPath != null) { |
|
289 |
setFilePath(lastPath); |
|
290 |
} |
|
291 |
|
|
292 |
gridBagConstraints.gridx = 1; |
|
293 |
gridBagConstraints.gridy = 1; |
|
294 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
295 |
gridBagConstraints.weightx = 0.25; |
|
296 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 5); |
|
297 |
|
|
298 |
// button browse |
|
299 |
btn = new JButton(PluginServices.getText(this, "browse")); |
|
300 |
btn.addActionListener(chooseAction); |
|
301 |
|
|
302 |
topPanel.add(btn, gridBagConstraints); |
|
303 |
|
|
304 |
gridBagConstraints.gridx = 0; |
|
305 |
gridBagConstraints.gridy = 2; |
|
306 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
307 |
// gridBagConstraints.weightx = 0.25; |
|
308 |
|
|
309 |
autorotate = new JCheckBox(); |
|
310 |
autorotate.setSelected(false); |
|
311 |
autorotate.setText("Autorotate"); |
|
312 |
|
|
313 |
topPanel.add(autorotate, gridBagConstraints); |
|
314 |
|
|
315 |
} |
|
316 |
return topPanel; |
|
317 |
} |
|
318 |
|
|
319 |
public JCheckBox getAutorotate() { |
|
320 |
return autorotate; |
|
321 |
} |
|
322 |
|
|
323 |
public void setAutorotate(JCheckBox autorotate) { |
|
324 |
this.autorotate = autorotate; |
|
325 |
} |
|
326 |
|
|
327 |
private JPanel getLeftBottomPanel() { |
|
328 |
if (leftBottomPanel == null) { |
|
329 |
leftBottomPanel = new JPanel(new GridBagLayout()); |
|
330 |
// leftBottomPanel.setBorder(new LineBorder(Color.gray)); |
|
331 |
|
|
332 |
Component transLabel = new JLabel("Transformaciones :"); |
|
333 |
transLabel.setName("jLabel1"); // NOI18N |
|
334 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
335 |
gridBagConstraints.gridx = 0; |
|
336 |
gridBagConstraints.gridy = 0; |
|
337 |
gridBagConstraints.gridwidth = 2; |
|
338 |
gridBagConstraints.anchor = GridBagConstraints.WEST; |
|
339 |
leftBottomPanel.add(transLabel, gridBagConstraints); |
|
340 |
|
|
341 |
// Scale X |
|
342 |
Component scaleXLabel = new JLabel("Escalado X"); |
|
343 |
scaleXLabel.setName("jLabel2"); // NOI18N |
|
344 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
345 |
gridBagConstraints.gridx = 0; |
|
346 |
gridBagConstraints.gridy = 1; |
|
347 |
gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10); |
|
348 |
leftBottomPanel.add(scaleXLabel, gridBagConstraints); |
|
349 |
|
|
350 |
scaleTextFieldX = new JTextField(); |
|
351 |
scaleTextFieldX.setName("0"); |
|
352 |
scaleTextFieldX.setText("1"); |
|
353 |
scaleTextFieldX.addKeyListener(this); |
|
354 |
|
|
355 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
356 |
gridBagConstraints.gridx = 1; |
|
357 |
gridBagConstraints.gridy = 1; |
|
358 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
359 |
gridBagConstraints.weightx = 1.0; |
|
360 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 5); |
|
361 |
leftBottomPanel.add(scaleTextFieldX, gridBagConstraints); |
|
362 |
|
|
363 |
// Scale Y |
|
364 |
Component scaleYLabel = new JLabel("Escalado Y"); |
|
365 |
scaleYLabel.setName("jLabel5"); // NOI18N |
|
366 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
367 |
gridBagConstraints.gridx = 0; |
|
368 |
gridBagConstraints.gridy = 2; |
|
369 |
gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10); |
|
370 |
leftBottomPanel.add(scaleYLabel, gridBagConstraints); |
|
371 |
|
|
372 |
scaleTextFieldY = new JTextField(); |
|
373 |
scaleTextFieldY.setName("1"); |
|
374 |
scaleTextFieldY.setText("1"); |
|
375 |
scaleTextFieldY.addKeyListener(this); |
|
376 |
|
|
377 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
378 |
gridBagConstraints.gridx = 1; |
|
379 |
gridBagConstraints.gridy = 2; |
|
380 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
381 |
gridBagConstraints.weightx = 1.0; |
|
382 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 5); |
|
383 |
leftBottomPanel.add(scaleTextFieldY, gridBagConstraints); |
|
384 |
|
|
385 |
// Scale Z |
|
386 |
Component scaleZLabel = new JLabel("Escalado Z"); |
|
387 |
scaleZLabel.setName("jLabel5"); // NOI18N |
|
388 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
389 |
gridBagConstraints.gridx = 0; |
|
390 |
gridBagConstraints.gridy = 3; |
|
391 |
gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10); |
|
392 |
leftBottomPanel.add(scaleZLabel, gridBagConstraints); |
|
393 |
|
|
394 |
scaleTextFieldZ = new JTextField(); |
|
395 |
scaleTextFieldZ.setName("2"); // NOI18N |
|
396 |
scaleTextFieldZ.setText("1"); |
|
397 |
scaleTextFieldZ.addKeyListener(this); |
|
398 |
|
|
399 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
400 |
gridBagConstraints.gridx = 1; |
|
401 |
gridBagConstraints.gridy = 3; |
|
402 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
403 |
gridBagConstraints.weightx = 1.0; |
|
404 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 5); |
|
405 |
leftBottomPanel.add(scaleTextFieldZ, gridBagConstraints); |
|
406 |
|
|
407 |
// Rotation X |
|
408 |
Component rotationXLabel = new JLabel("Rotacion X"); |
|
409 |
rotationXLabel.setName("jLabel5"); // NOI18N |
|
410 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
411 |
gridBagConstraints.gridx = 0; |
|
412 |
gridBagConstraints.gridy = 4; |
|
413 |
gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10); |
|
414 |
leftBottomPanel.add(rotationXLabel, gridBagConstraints); |
|
415 |
|
|
416 |
rotationTextFieldX = new JTextField(); |
|
417 |
rotationTextFieldX.setName("3"); // NOI18N |
|
418 |
rotationTextFieldX.setText(String.valueOf(_rotX)); |
|
419 |
rotationTextFieldX.addKeyListener(this); |
|
420 |
|
|
421 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
422 |
gridBagConstraints.gridx = 1; |
|
423 |
gridBagConstraints.gridy = 4; |
|
424 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
425 |
gridBagConstraints.weightx = 1.0; |
|
426 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 5); |
|
427 |
leftBottomPanel.add(rotationTextFieldX, gridBagConstraints); |
|
428 |
|
|
429 |
// Rotation Y |
|
430 |
Component rotationYLabel = new JLabel("Rotacion Y"); |
|
431 |
rotationYLabel.setName("jLabel3"); // NOI18N |
|
432 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
433 |
gridBagConstraints.gridx = 0; |
|
434 |
gridBagConstraints.gridy = 5; |
|
435 |
gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10); |
|
436 |
leftBottomPanel.add(rotationYLabel, gridBagConstraints); |
|
437 |
|
|
438 |
rotationTextFieldY = new JTextField(); |
|
439 |
rotationTextFieldY.setName("4"); // NOI18N |
|
440 |
rotationTextFieldY.setText(String.valueOf(_rotY)); |
|
441 |
rotationTextFieldY.addKeyListener(this); |
|
442 |
|
|
443 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
444 |
gridBagConstraints.gridx = 1; |
|
445 |
gridBagConstraints.gridy = 5; |
|
446 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
447 |
gridBagConstraints.weightx = 1.0; |
|
448 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 5); |
|
449 |
leftBottomPanel.add(rotationTextFieldY, gridBagConstraints); |
|
450 |
|
|
451 |
// Rotation Z |
|
452 |
Component rotationZlabel = new JLabel("Rotacion Z"); |
|
453 |
rotationZlabel.setName("jLabel4"); // NOI18N |
|
454 |
|
|
455 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
456 |
gridBagConstraints.gridx = 0; |
|
457 |
gridBagConstraints.gridy = 6; |
|
458 |
gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10); |
|
459 |
leftBottomPanel.add(rotationZlabel, gridBagConstraints); |
|
460 |
|
|
461 |
rotationTextFieldZ = new JTextField(); |
|
462 |
rotationTextFieldZ.setName("5"); // NOI18N |
|
463 |
rotationTextFieldZ.setText(String.valueOf(_rotZ)); |
|
464 |
rotationTextFieldZ.addKeyListener(this); |
|
465 |
|
|
466 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
467 |
gridBagConstraints.gridx = 1; |
|
468 |
gridBagConstraints.gridy = 6; |
|
469 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
470 |
gridBagConstraints.weightx = 1.0; |
|
471 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 2, 5); |
|
472 |
leftBottomPanel.add(rotationTextFieldZ, gridBagConstraints); |
|
473 |
} |
|
474 |
return leftBottomPanel; |
|
475 |
} |
|
476 |
|
|
477 |
private JPanel getRigthBottomPanel() { |
|
478 |
if (rigthBottomPanel == null) { |
|
479 |
rigthBottomPanel = new JPanel(new GridBagLayout()); |
|
480 |
// rigthBottomPanel.setBorder(new LineBorder(Color.gray)); |
|
481 |
GridBagConstraints constrain = new GridBagConstraints(); |
|
482 |
constrain.gridx = 0; |
|
483 |
constrain.gridy = 0; |
|
484 |
constrain.anchor = GridBagConstraints.WEST; |
|
485 |
// selection picture file |
|
486 |
lblSelFileName = new JLabel("Preview:"); |
|
487 |
rigthBottomPanel.add(lblSelFileName, constrain); |
|
488 |
|
|
489 |
int size = 150; |
|
490 |
JPanel aux3 = new JPanel(); |
|
491 |
aux3.setPreferredSize(new Dimension(size, size)); |
|
492 |
if (_canvas3d == null) { |
|
493 |
_canvas3d = ViewerFactory.getInstance().createViewer( |
|
494 |
ViewerFactory.VIEWER_TYPE.CANVAS_VIEWER, null); |
|
495 |
ViewerFactory.getInstance().startAnimator(); |
|
496 |
_canvas3d.setSize(size, size); |
|
497 |
_canvas3d.getOSGViewer().setClearColor(1.0, 1.0, 1.0, 0.0); |
|
498 |
} |
|
499 |
|
|
500 |
loadFile(); |
|
501 |
|
|
502 |
constrain.gridx = 0; |
|
503 |
constrain.gridy = 1; |
|
504 |
aux3.add((Component) _canvas3d); |
|
505 |
rigthBottomPanel.add(aux3, constrain); |
|
506 |
|
|
507 |
_canvas3d.addMouseListener(new MouseListener() { |
|
508 |
|
|
509 |
public void mouseClicked(MouseEvent arg0) { |
|
510 |
|
|
511 |
} |
|
512 |
|
|
513 |
public void mouseEntered(MouseEvent arg0) { |
|
514 |
|
|
515 |
} |
|
516 |
|
|
517 |
public void mouseExited(MouseEvent arg0) { |
|
518 |
|
|
519 |
} |
|
520 |
|
|
521 |
public void mousePressed(MouseEvent arg0) { |
|
522 |
|
|
523 |
} |
|
524 |
|
|
525 |
public void mouseReleased(MouseEvent arg0) { |
|
526 |
|
|
527 |
if (_canvas3d.getOSGViewer().getSceneData() != null) |
|
528 |
fireSymbolChangedEvent(); |
|
529 |
|
|
530 |
} |
|
531 |
|
|
532 |
}); |
|
533 |
|
|
534 |
} |
|
535 |
return rigthBottomPanel; |
|
536 |
} |
|
537 |
|
|
538 |
private void loadFile() { |
|
539 |
try { |
|
540 |
Node node = null; |
|
541 |
if (this.getFilePath() == "") { |
|
542 |
node = new Group(); |
|
543 |
} else { |
|
544 |
node = osgDB.readNodeFile(filePath); |
|
545 |
} |
|
546 |
|
|
547 |
_canvas3d.getOSGViewer().setSceneData(node); |
|
548 |
|
|
549 |
tempScreenshotimage = System.getProperty("java.io.tmpdir") |
|
550 |
+ System.getProperty("file.separator") + node.getNodeName() |
|
551 |
+ ".png"; |
|
552 |
System.err.println("screenshot del simbolo " + tempScreenshotimage); |
|
553 |
_canvas3d.getOSGViewer().takeScreenshot(tempScreenshotimage); |
|
554 |
|
|
555 |
} catch (LoadNodeException e) { |
|
556 |
|
|
557 |
e.printStackTrace(); |
|
558 |
} catch (FileNotFoundException e) { |
|
559 |
|
|
560 |
e.printStackTrace(); |
|
561 |
} |
|
562 |
} |
|
563 |
|
|
564 |
public ISymbol getLayer() { |
|
565 |
// this method builds the new symbol and returns it to the legend |
|
566 |
// manager |
|
567 |
try { |
|
568 |
_symbol = null; |
|
569 |
|
|
570 |
// if (this.getFilePath().equals("")) |
|
571 |
// symbol = new Object3DMarkerSymbol(this.getFilePath(), _canvas3d |
|
572 |
// .getOSGViewer()); |
|
573 |
// else { |
|
574 |
_symbol = new Object3DMarkerSymbol(this.getFilePath(), _canvas3d |
|
575 |
.getOSGViewer()); |
|
576 |
_symbol.setScale(new Vec3(Double.parseDouble(scaleTextFieldX |
|
577 |
.getText()), Double.parseDouble(scaleTextFieldY.getText()), |
|
578 |
Double.parseDouble(scaleTextFieldZ.getText()))); |
|
579 |
|
|
580 |
_symbol.setRotation(new Vec3(Double.parseDouble(rotationTextFieldX |
|
581 |
.getText()), Double.parseDouble(rotationTextFieldY |
|
582 |
.getText()), Double.parseDouble(rotationTextFieldZ |
|
583 |
.getText()))); |
|
584 |
_symbol.setScale(new Vec3(_scaleX,_scaleY,_scaleZ)); |
|
585 |
_symbol.setAutoRotate(autorotate.isSelected()); |
|
586 |
_symbol.setSnapshot(tempScreenshotimage); |
|
587 |
_symbol.setSize(128); |
|
588 |
// } |
|
589 |
|
|
590 |
return _symbol; |
|
591 |
} catch (IOException e) { |
|
592 |
return SymbologyFactory.getWarningSymbol(PluginServices.getText( |
|
593 |
this, "failed_acessing_files"), null, |
|
594 |
SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS); |
|
595 |
} |
|
596 |
|
|
597 |
} |
|
598 |
|
|
599 |
public void refreshControls(ISymbol layer) { |
|
600 |
|
|
601 |
// this method gets the simbol from the legend manager |
|
602 |
|
|
603 |
Object3DMarkerSymbol sym; |
|
604 |
try { |
|
605 |
String fileName = null; |
|
606 |
if (layer == null) { |
|
607 |
// initialize defaults |
|
608 |
System.err.println(getClass().getName() |
|
609 |
+ ":: should be unreachable code"); |
|
610 |
fileName = "-"; |
|
611 |
} else { |
|
612 |
sym = (Object3DMarkerSymbol) layer; |
|
613 |
_symbol = sym; |
|
614 |
fileName = sym.getObject3DPath(); |
|
615 |
this.setFilePath(fileName); |
|
616 |
_scaleX = sym.getScale().x(); |
|
617 |
_scaleY = sym.getScale().y(); |
|
618 |
_scaleZ = sym.getScale().z(); |
|
619 |
scaleTextFieldX.setText(String.valueOf(_scaleX)); |
|
620 |
scaleTextFieldY.setText(String.valueOf(_scaleY)); |
|
621 |
scaleTextFieldZ.setText(String.valueOf(_scaleZ)); |
|
622 |
loadFile(); |
|
623 |
|
|
624 |
} |
|
625 |
|
|
626 |
} catch (IndexOutOfBoundsException ioEx) { |
|
627 |
NotificationManager.addWarning("Symbol layer index out of bounds", |
|
628 |
ioEx); |
|
629 |
} catch (ClassCastException ccEx) { |
|
630 |
NotificationManager.addWarning("Illegal casting from " |
|
631 |
+ layer.getClassName() + " to " |
|
632 |
+ getSymbolClass().getName() + ".", ccEx); |
|
633 |
} |
|
634 |
} |
|
635 |
|
|
636 |
public String getName() { |
|
637 |
return "Object 3D symbol"; |
|
638 |
|
|
639 |
} |
|
640 |
|
|
641 |
public JPanel[] getTabs() { |
|
642 |
return tabs.toArray(new JPanel[tabs.size()]); |
|
643 |
} |
|
644 |
|
|
645 |
public Class getSymbolClass() { |
|
646 |
return Object3DMarkerSymbol.class; |
|
647 |
} |
|
648 |
|
|
649 |
public EditorTool[] getEditorTools() { |
|
650 |
return null; |
|
651 |
|
|
652 |
} |
|
653 |
|
|
654 |
public void actionPerformed(ActionEvent e) { |
|
655 |
fireSymbolChangedEvent(); |
|
656 |
} |
|
657 |
|
|
658 |
public void keyPressed(KeyEvent e) { |
|
659 |
// TODO Auto-generated method stub |
|
660 |
|
|
661 |
} |
|
662 |
|
|
663 |
public void keyReleased(KeyEvent e) { |
|
664 |
// TODO Auto-generated method stub |
|
665 |
|
|
666 |
} |
|
667 |
|
|
668 |
public void keyTyped(KeyEvent e) { |
|
669 |
|
|
670 |
JTextField textF = (JTextField) e.getSource(); |
|
671 |
|
|
672 |
try { |
|
673 |
switch (Integer.parseInt(textF.getName())) { |
|
674 |
|
|
675 |
case 0: |
|
676 |
_scaleX = Double.parseDouble(textF.getText()); |
|
677 |
updateProperties(); |
|
678 |
fireSymbolChangedEvent(); |
|
679 |
break; |
|
680 |
case 1: |
|
681 |
_scaleY = Double.parseDouble(textF.getText()); |
|
682 |
updateProperties(); |
|
683 |
fireSymbolChangedEvent(); |
|
684 |
break; |
|
685 |
case 2: |
|
686 |
_scaleZ = Double.parseDouble(textF.getText()); |
|
687 |
updateProperties(); |
|
688 |
fireSymbolChangedEvent(); |
|
689 |
break; |
|
690 |
case 3: |
|
691 |
_rotX = Double.parseDouble(textF.getText()); |
|
692 |
updateProperties(); |
|
693 |
fireSymbolChangedEvent(); |
|
694 |
break; |
|
695 |
case 4: |
|
696 |
_rotY = Double.parseDouble(textF.getText()); |
|
697 |
updateProperties(); |
|
698 |
fireSymbolChangedEvent(); |
|
699 |
break; |
|
700 |
case 5: |
|
701 |
_rotZ = Double.parseDouble(textF.getText()); |
|
702 |
updateProperties(); |
|
703 |
fireSymbolChangedEvent(); |
|
704 |
break; |
|
705 |
|
|
706 |
} |
|
707 |
} catch (NumberFormatException ex) { |
|
708 |
|
|
709 |
NotificationManager.showMessageError("Only accepts numbers", null); |
|
710 |
textF.setText("0"); |
|
711 |
|
|
712 |
} |
|
713 |
|
|
714 |
if (_symbol != null) { |
|
715 |
|
|
716 |
_symbol.setScale(new Vec3(_scaleX, _scaleY, _scaleZ)); |
|
717 |
_symbol.setRotation(new Vec3(_rotX, _rotY, _rotZ)); |
|
718 |
|
|
719 |
} |
|
720 |
|
|
721 |
} |
|
722 |
|
|
723 |
private void updateProperties() { |
|
724 |
if (_symbol != null) { |
|
725 |
|
|
726 |
_symbol.setScale(new Vec3(_scaleX, _scaleY, _scaleZ)); |
|
727 |
_symbol.setRotation(new Vec3(_rotX, _rotY, _rotZ)); |
|
728 |
|
|
729 |
} |
|
730 |
|
|
731 |
} |
|
732 |
|
|
733 |
} |
|
0 | 734 |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/ExtrusionPointSymbol.java | ||
---|---|---|
1 |
package com.iver.ai2.gvsig3d.legend.symbols; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleMarkerSymbol; |
|
4 |
|
|
5 |
public class ExtrusionPointSymbol extends SimpleMarkerSymbol implements IExtrusionSymbol{ |
|
6 |
|
|
7 |
private double extrusion = 0.0; |
|
8 |
|
|
9 |
public ExtrusionPointSymbol() { |
|
10 |
// TODO Auto-generated constructor stub |
|
11 |
} |
|
12 |
|
|
13 |
public double getExtrusion() { |
|
14 |
return this.extrusion; |
|
15 |
} |
|
16 |
|
|
17 |
public void setExtrusion(double extrusion) { |
|
18 |
this.extrusion = extrusion; |
|
19 |
} |
|
20 |
|
|
21 |
} |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/BaseExtrusionSymbol.java | ||
---|---|---|
1 |
package com.iver.ai2.gvsig3d.legend.symbols; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
|
4 |
import com.iver.utiles.XMLEntity; |
|
5 |
|
|
6 |
public class BaseExtrusionSymbol extends SimpleFillSymbol implements |
|
7 |
IExtrusionSymbol { |
|
8 |
|
|
9 |
private double extrusion = 0.0; |
|
10 |
|
|
11 |
public double getExtrusion() { |
|
12 |
return this.extrusion; |
|
13 |
} |
|
14 |
|
|
15 |
public void setExtrusion(double extrusion) { |
|
16 |
this.extrusion = extrusion; |
|
17 |
} |
|
18 |
|
|
19 |
public BaseExtrusionSymbol(double extrusion) { |
|
20 |
super(); |
|
21 |
this.extrusion = extrusion; |
|
22 |
} |
|
23 |
|
|
24 |
public String getClassName() { |
|
25 |
return getClass().getName(); |
|
26 |
} |
|
27 |
|
|
28 |
public XMLEntity getXMLEntity() { |
|
29 |
XMLEntity xml = super.getXMLEntity(); |
|
30 |
xml.putProperty("extrusion", this.extrusion); |
|
31 |
return xml; |
|
32 |
} |
|
33 |
|
|
34 |
public void setXMLEntity(XMLEntity xml) { |
|
35 |
super.setXMLEntity(xml); |
|
36 |
if (xml.contains("extrusion")) |
|
37 |
extrusion = xml.getDoubleProperty("extrusion"); |
|
38 |
} |
|
39 |
|
|
40 |
|
|
41 |
} |
tags/gvSIG_3D_Animation_1_9_SNAPSHOT_build_14/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/Object3DMarkerSymbol.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 |
* 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 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id: PictureMarkerSymbol.java 15593 2007-10-29 13:01:13Z jdominguez $ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.17 2007-09-21 12:25:32 jaume |
|
47 |
* cancellation support extended down to the IGeometry and ISymbol level |
|
48 |
* |
|
49 |
* Revision 1.16 2007/09/19 16:22:04 jaume |
|
50 |
* removed unnecessary imports |
|
51 |
* |
|
52 |
* Revision 1.15 2007/09/11 07:46:55 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.14 2007/08/16 06:55:19 jvidal |
|
56 |
* javadoc updated |
|
57 |
* |
|
58 |
* Revision 1.13 2007/08/09 06:42:24 jvidal |
|
59 |
* javadoc |
|
60 |
* |
|
61 |
* Revision 1.12 2007/08/08 12:05:17 jvidal |
|
62 |
* javadoc |
|
63 |
* |
|
64 |
* Revision 1.11 2007/07/18 06:54:35 jaume |
|
65 |
* continuing with cartographic support |
|
66 |
* |
|
67 |
* Revision 1.10 2007/07/03 10:58:29 jaume |
|
68 |
* first refactor on CartographicSupport |
|
69 |
* |
|
70 |
* Revision 1.9 2007/06/29 13:07:01 jaume |
|
71 |
* +PictureLineSymbol |
|
72 |
* |
|
73 |
* Revision 1.8 2007/06/11 12:25:48 jaume |
|
74 |
* ISymbol drawing integration tests (markers and lines) |
|
75 |
* |
|
76 |
* Revision 1.7 2007/06/07 06:50:40 jaume |
|
77 |
* *** empty log message *** |
|
78 |
* |
|
79 |
* Revision 1.6 2007/05/29 15:46:37 jaume |
|
80 |
* *** empty log message *** |
|
81 |
* |
|
82 |
* Revision 1.5 2007/05/08 08:47:40 jaume |
|
83 |
* *** empty log message *** |
|
84 |
* |
|
85 |
* Revision 1.4 2007/03/21 17:36:22 jaume |
|
86 |
* *** empty log message *** |
|
87 |
* |
|
88 |
* Revision 1.3 2007/03/09 11:20:57 jaume |
|
89 |
* Advanced symbology (start committing) |
|
90 |
* |
|
91 |
* Revision 1.1.2.4 2007/02/21 07:34:09 jaume |
|
92 |
* labeling starts working |
|
93 |
* |
|
94 |
* Revision 1.1.2.3 2007/02/16 10:54:12 jaume |
|
95 |
* multilayer splitted to multilayerline, multilayermarker,and multilayerfill |
|
96 |
* |
|
97 |
* Revision 1.1.2.2 2007/02/15 16:23:44 jaume |
|
98 |
* *** empty log message *** |
|
99 |
* |
|
100 |
* Revision 1.1.2.1 2007/02/09 07:47:05 jaume |
|
101 |
* Isymbol moved |
|
102 |
* |
|
103 |
* Revision 1.1 2007/01/24 17:58:22 jaume |
|
104 |
* new features and architecture error fixes |
|
105 |
* |
|
106 |
* |
|
107 |
*/ |
|
108 |
package com.iver.ai2.gvsig3d.legend.symbols; |
|
109 |
|
|
110 |
import java.awt.Graphics2D; |
|
111 |
import java.awt.Rectangle; |
|
112 |
import java.awt.geom.AffineTransform; |
|
113 |
import java.awt.image.BufferedImage; |
|
114 |
import java.awt.image.ImagingOpException; |
|
115 |
import java.io.IOException; |
|
116 |
import java.net.MalformedURLException; |
|
117 |
import java.net.URL; |
|
118 |
|
|
119 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
120 |
|
|
121 |
import org.apache.log4j.Logger; |
|
122 |
import org.gvsig.osgvp.core.osg.Image; |
|
123 |
import org.gvsig.osgvp.core.osg.Matrix; |
|
124 |
import org.gvsig.osgvp.core.osg.Node; |
|
125 |
import org.gvsig.osgvp.core.osg.Vec3; |
|
126 |
import org.gvsig.osgvp.core.osgdb.osgDB; |
|
127 |
import org.gvsig.osgvp.exceptions.image.ImageConversionException; |
|
128 |
import org.gvsig.osgvp.exceptions.node.LoadNodeException; |
|
129 |
import org.gvsig.osgvp.viewer.Camera; |
|
130 |
import org.gvsig.osgvp.viewer.IViewer; |
|
131 |
import org.gvsig.osgvp.viewer.OSGViewer; |
|
132 |
|
|
133 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
134 |
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
|
135 |
import com.iver.andami.PluginServices; |
|
136 |
import com.iver.andami.messages.NotificationManager; |
|
137 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
138 |
import com.iver.cit.gvsig.fmap.Messages; |
|
139 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
140 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
141 |
import com.iver.cit.gvsig.fmap.core.symbols.AbstractMarkerSymbol; |
|
142 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
143 |
import com.iver.cit.gvsig.fmap.core.symbols.SymbolDrawingException; |
|
144 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
145 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
146 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
|
147 |
import com.iver.utiles.XMLEntity; |
|
148 |
import com.iver.utiles.swing.threads.Cancellable; |
|
149 |
|
|
150 |
public class Object3DMarkerSymbol extends AbstractMarkerSymbol { |
|
151 |
private static final float SELECTION_OPACITY_FACTOR = .3F; |
|
152 |
// transient private Image img; |
|
153 |
private String object3DPath; |
|
154 |
private OSGViewer _osgViewer; |
|
155 |
private OSGViewer _tabOsgViewer; |
|
156 |
private boolean selected; |
|
157 |
private Vec3 scale; |
|
158 |
private Vec3 rotation; |
|
159 |
private boolean autoRotate = false; |
|
160 |
private String tempScreenshotimage; |
|
161 |
|
|
162 |
// transient private Image selImg; |
|
163 |
|
|
164 |
public boolean isAutoRotate() { |
|
165 |
return autoRotate; |
|
166 |
} |
|
167 |
|
|
168 |
public void setAutoRotate(boolean autoRotate) { |
|
169 |
this.autoRotate = autoRotate; |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* Constructor method |
|
174 |
*/ |
|
175 |
public Object3DMarkerSymbol() { |
|
176 |
super(); |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* Constructor method |
|
181 |
* |
|
182 |
* @param imageURL |
|
183 |
* , URL of the normal image |
|
184 |
* @param selImageURL |
|
185 |
* , URL of the image when it is selected in the map |
|
186 |
* @throws IOException |
|
187 |
*/ |
|
188 |
// public Object3DMarkerSymbol(URL object3DURL) throws IOException { |
|
189 |
// setObject3DPath(object3DURL); |
|
190 |
// } |
|
191 |
public Object3DMarkerSymbol(String object3DPath, IViewer viewer) |
|
192 |
throws IOException { |
|
193 |
super(); |
Also available in: Unified diff