Revision 25504
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/geometry3D/Abstract3DGeometry.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.geometry3D; |
|
2 |
|
|
3 |
|
|
4 |
import java.awt.geom.PathIterator; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import org.apache.log4j.Logger; |
|
9 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.I3DSymbol; |
|
10 |
import org.gvsig.osgvp.Group; |
|
11 |
import org.gvsig.osgvp.Node; |
|
12 |
import org.gvsig.osgvp.Vec3; |
|
13 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
|
14 |
import org.gvsig.osgvp.planets.Planet; |
|
15 |
|
|
16 |
import com.iver.cit.gvsig.fmap.core.FGeometry; |
|
17 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
18 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
19 |
|
|
20 |
public abstract class Abstract3DGeometry implements I3DGeometry { |
|
21 |
|
|
22 |
private int geomType; |
|
23 |
private IGeometry geometry; |
|
24 |
private boolean zEnable = false; |
|
25 |
|
|
26 |
private float vertEx = 1; |
|
27 |
private float heigth; |
|
28 |
private Planet planet; |
|
29 |
|
|
30 |
private static Logger logger = Logger.getLogger(Abstract3DGeometry.class.getName()); |
|
31 |
|
|
32 |
public Abstract3DGeometry(IGeometry geometry) { |
|
33 |
this.geometry = geometry; |
|
34 |
} |
|
35 |
|
|
36 |
public Group generateGeometry(I3DSymbol symbol3D) { |
|
37 |
Group groupAux = new Group(); |
|
38 |
Node node = null; |
|
39 |
|
|
40 |
if (geometry == null || symbol3D == null) |
|
41 |
return null; |
|
42 |
|
|
43 |
geomType = geometry.getGeometryType(); |
|
44 |
|
|
45 |
// Getting the Iterator |
|
46 |
PathIterator theIteratorL = geometry.getPathIterator(null); |
|
47 |
|
|
48 |
double[] dataLine = new double[6]; |
|
49 |
List<Vec3> posi = new ArrayList<Vec3>(); |
|
50 |
int contH = 0; |
|
51 |
while (!theIteratorL.isDone()) { |
|
52 |
int type = theIteratorL.currentSegment(dataLine); |
|
53 |
|
|
54 |
Vec3 position = getGeometryPosition(geometry, dataLine, heigth, |
|
55 |
contH); |
|
56 |
// Adding points |
|
57 |
switch (type) { |
|
58 |
case PathIterator.SEG_MOVETO: |
|
59 |
// System.out.println("SEG_MOVETO"); |
|
60 |
node = symbol3D.generateSymbol(posi); |
|
61 |
if (node != null) { |
|
62 |
try { |
|
63 |
groupAux.addChild(node); |
|
64 |
} catch (NodeException e) { |
|
65 |
logger.error("Command:" + "Error setting new child.",e); |
|
66 |
} |
|
67 |
posi.clear(); |
|
68 |
posi = new ArrayList<Vec3>(); |
|
69 |
} |
|
70 |
posi.add(position); |
|
71 |
break; |
|
72 |
|
|
73 |
case PathIterator.SEG_LINETO: |
|
74 |
// System.out.println("SEG_LINETO"); |
|
75 |
posi.add(position); |
|
76 |
break; |
|
77 |
|
|
78 |
case PathIterator.SEG_QUADTO: |
|
79 |
// System.out.println("SEG_QUADTO"); |
|
80 |
break; |
|
81 |
|
|
82 |
case PathIterator.SEG_CUBICTO: |
|
83 |
// System.out.println("SEG_CUBICTO"); |
|
84 |
break; |
|
85 |
|
|
86 |
case PathIterator.SEG_CLOSE: |
|
87 |
// System.out.println("SEG_CLOSE"); |
|
88 |
break; |
|
89 |
} |
|
90 |
contH++; |
|
91 |
theIteratorL.next(); |
|
92 |
} |
|
93 |
// System.out.println("Numero de puntos: " + contH); |
|
94 |
|
|
95 |
// Adding last symbol |
|
96 |
if (posi.size() > 0) { |
|
97 |
// if ((geomType & FShape.LINE) == FShape.LINE) { |
|
98 |
// } |
|
99 |
node = symbol3D.generateSymbol(posi); |
|
100 |
if (node != null) |
|
101 |
try { |
|
102 |
groupAux.addChild(node); |
|
103 |
} catch (NodeException e) { |
|
104 |
logger.error("Command:" + "Error adding new child.",e); |
|
105 |
} |
|
106 |
} |
|
107 |
return groupAux; |
|
108 |
|
|
109 |
} |
|
110 |
|
|
111 |
public Vec3 getGeometryPosition(IGeometry geometry, double[] dataLine, |
|
112 |
float heigth, int contH) { |
|
113 |
// TRANSFORMANDO A GEOMETRIA CON VALOR Z |
|
114 |
FGeometry g3D = null; |
|
115 |
if (geometry instanceof FGeometry) { |
|
116 |
g3D = (FGeometry) geometry; |
|
117 |
} |
|
118 |
Vec3 posGeo = null; |
|
119 |
Vec3 pos = null; |
|
120 |
double h = 0; |
|
121 |
if (isZEnable()) { |
|
122 |
if ((geomType & FShape.Z) == FShape.Z) { |
|
123 |
if (g3D != null) { |
|
124 |
h = (g3D.getZs()[contH]) * vertEx; |
|
125 |
} |
|
126 |
} |
|
127 |
} else { |
|
128 |
h = heigth; |
|
129 |
} |
|
130 |
|
|
131 |
if (planet.getCoordinateSystemType() == Planet.CoordinateSystemType.GEOCENTRIC) { |
|
132 |
posGeo = new Vec3(dataLine[1], dataLine[0], h); |
|
133 |
pos = planet.convertLatLongHeightToXYZ(posGeo); |
|
134 |
} else { |
|
135 |
pos = new Vec3(dataLine[0], dataLine[1], h); |
|
136 |
} |
|
137 |
return pos; |
|
138 |
} |
|
139 |
|
|
140 |
public int getGeomType() { |
|
141 |
return geomType; |
|
142 |
} |
|
143 |
|
|
144 |
public void setGeomType(int geomType) { |
|
145 |
this.geomType = geomType; |
|
146 |
} |
|
147 |
|
|
148 |
public IGeometry getGeometry() { |
|
149 |
return geometry; |
|
150 |
} |
|
151 |
|
|
152 |
public void setGeometry(IGeometry geometry) { |
|
153 |
this.geometry = geometry; |
|
154 |
} |
|
155 |
|
|
156 |
public boolean isZEnable() { |
|
157 |
return zEnable; |
|
158 |
} |
|
159 |
|
|
160 |
public void setZEnable(boolean enable) { |
|
161 |
zEnable = enable; |
|
162 |
} |
|
163 |
|
|
164 |
public float getVertEx() { |
|
165 |
return vertEx; |
|
166 |
} |
|
167 |
|
|
168 |
public void setVertEx(float vertEx) { |
|
169 |
this.vertEx = vertEx; |
|
170 |
} |
|
171 |
|
|
172 |
public float getHeigth() { |
|
173 |
return heigth; |
|
174 |
} |
|
175 |
|
|
176 |
public void setHeigth(float heigth) { |
|
177 |
this.heigth = heigth; |
|
178 |
} |
|
179 |
|
|
180 |
public Planet getPlanet() { |
|
181 |
return planet; |
|
182 |
} |
|
183 |
|
|
184 |
public void setPlanet(Planet planet) { |
|
185 |
this.planet = planet; |
|
186 |
} |
|
187 |
|
|
188 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/geometry3D/Line3DGeometry.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.geometry3D; |
|
2 |
|
|
3 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.I3DSymbol; |
|
4 |
import org.gvsig.osgvp.Group; |
|
5 |
|
|
6 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
7 |
|
|
8 |
public class Line3DGeometry extends Abstract3DGeometry { |
|
9 |
|
|
10 |
public Line3DGeometry(IGeometry geometry) { |
|
11 |
super(geometry); |
|
12 |
} |
|
13 |
|
|
14 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/geometry3D/Polygon3DGeometry.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.geometry3D; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
4 |
|
|
5 |
public class Polygon3DGeometry extends Abstract3DGeometry { |
|
6 |
|
|
7 |
public Polygon3DGeometry(IGeometry geometry) { |
|
8 |
super(geometry); |
|
9 |
} |
|
10 |
|
|
11 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/geometry3D/I3DGeometry.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.geometry3D; |
|
2 |
|
|
3 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.I3DSymbol; |
|
4 |
import org.gvsig.osgvp.Group; |
|
5 |
import org.gvsig.osgvp.Vec3; |
|
6 |
|
|
7 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
8 |
|
|
9 |
public interface I3DGeometry { |
|
10 |
|
|
11 |
Group generateGeometry(I3DSymbol symbol3D); |
|
12 |
|
|
13 |
Vec3 getGeometryPosition(IGeometry geometry, double[] dataLine, |
|
14 |
float heigth, int contH); |
|
15 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/geometry3D/Point3DGeometry.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.geometry3D; |
|
2 |
|
|
3 |
import java.awt.geom.PathIterator; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
|
|
8 |
import org.apache.log4j.Logger; |
|
9 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.I3DSymbol; |
|
10 |
import org.gvsig.osgvp.Group; |
|
11 |
import org.gvsig.osgvp.Node; |
|
12 |
import org.gvsig.osgvp.Vec3; |
|
13 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
|
14 |
import org.gvsig.osgvp.features.PixelPoint; |
|
15 |
|
|
16 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
17 |
|
|
18 |
public class Point3DGeometry extends Abstract3DGeometry { |
|
19 |
|
|
20 |
protected Map<Double, PixelPoint> pointsMap; |
|
21 |
|
|
22 |
private static Logger logger = Logger.getLogger(Point3DGeometry.class.getName()); |
|
23 |
|
|
24 |
public Point3DGeometry(IGeometry geometry) { |
|
25 |
super(geometry); |
|
26 |
|
|
27 |
} |
|
28 |
|
|
29 |
private Node getPointNode(double key) { |
|
30 |
PixelPoint pixelPoint= null; |
|
31 |
|
|
32 |
if (pointsMap.containsKey(new Double(key))) { |
|
33 |
// System.out.println("ya contiene esa key"); |
|
34 |
pixelPoint = pointsMap.get(new Double(key)); |
|
35 |
} else { |
|
36 |
try { |
|
37 |
pixelPoint = new PixelPoint(); |
|
38 |
} catch (NodeException e) { |
|
39 |
// TODO Auto-generated catch block |
|
40 |
e.printStackTrace(); |
|
41 |
} |
|
42 |
pointsMap.put(new Double(key), pixelPoint); |
|
43 |
} |
|
44 |
|
|
45 |
return pixelPoint; |
|
46 |
} |
|
47 |
|
|
48 |
|
|
49 |
public Group generateGeometry(I3DSymbol symbol3D) { |
|
50 |
Group groupAux = new Group(); |
|
51 |
Node node = null; |
|
52 |
|
|
53 |
if (getGeometry() == null || symbol3D == null) |
|
54 |
return null; |
|
55 |
|
|
56 |
this.setGeomType(getGeometry().getGeometryType()); |
|
57 |
// TRANSFORMANDO A GEOMETRIA CON VALOR Z |
|
58 |
|
|
59 |
// Getting the Iterator |
|
60 |
PathIterator theIteratorL = getGeometry().getPathIterator(null); |
|
61 |
|
|
62 |
double[] dataLine = new double[6]; |
|
63 |
List<Vec3> posi = new ArrayList<Vec3>(); |
|
64 |
int contH = 0; |
|
65 |
// System.out.println("ENTRO"); |
|
66 |
while (!theIteratorL.isDone()) { |
|
67 |
// System.out.println("ITERO"); |
|
68 |
int type = theIteratorL.currentSegment(dataLine); |
|
69 |
Vec3 position = getGeometryPosition(getGeometry(), dataLine, |
|
70 |
getHeigth(), contH); |
|
71 |
|
|
72 |
// Adding points |
|
73 |
switch (type) { |
|
74 |
case PathIterator.SEG_MOVETO: |
|
75 |
// System.out.println("SEG_MOVETO"); |
|
76 |
// FeatureFactory.addPointToNode(node, pos, rgba, pointSize); |
|
77 |
// posi.add(pos); |
|
78 |
// INSERT HERE THE CODE TO MAKE TETURED QUAD POINT |
|
79 |
// List<Vec3> posit = new ArrayList<Vec3>(); |
|
80 |
posi.add(position); |
|
81 |
node = symbol3D.generateSymbol(posi); |
|
82 |
try { |
|
83 |
groupAux.addChild(node); |
|
84 |
} catch (NodeException e) { |
|
85 |
logger.equals("command: " + "Error adding new child" + e); |
|
86 |
} |
|
87 |
// group.addChild(generateFeature(posit,new |
|
88 |
// Vec4(1.0,0.0,0.0,1.0),sym)); |
|
89 |
// group.addChild(); |
|
90 |
// pointListAux.add(new Punto3D(pos, rgba, pointSize)); |
|
91 |
break; |
|
92 |
|
|
93 |
case PathIterator.SEG_LINETO: |
|
94 |
// System.out.println("SEG_LINETO"); |
|
95 |
posi.add(position); |
|
96 |
break; |
|
97 |
|
|
98 |
case PathIterator.SEG_QUADTO: |
|
99 |
// System.out.println("SEG_QUADTO"); |
|
100 |
break; |
|
101 |
|
|
102 |
case PathIterator.SEG_CUBICTO: |
|
103 |
// System.out.println("SEG_CUBICTO"); |
|
104 |
break; |
|
105 |
|
|
106 |
case PathIterator.SEG_CLOSE: |
|
107 |
// System.out.println("SEG_CLOSE"); |
|
108 |
break; |
|
109 |
} |
|
110 |
contH++; |
|
111 |
theIteratorL.next(); |
|
112 |
} |
|
113 |
return groupAux; |
|
114 |
|
|
115 |
} |
|
116 |
|
|
117 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/AbstractFeature3D.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
4 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
5 |
|
|
6 |
|
|
7 |
public abstract class AbstractFeature3D implements I3DFeature { |
|
8 |
|
|
9 |
private ISymbol symbol; |
|
10 |
private IGeometry geometry; |
|
11 |
|
|
12 |
public AbstractFeature3D(ISymbol symbol, IGeometry geometry) { |
|
13 |
super(); |
|
14 |
this.symbol = symbol; |
|
15 |
this.geometry = geometry; |
|
16 |
} |
|
17 |
|
|
18 |
public ISymbol getSymbol() { |
|
19 |
return symbol; |
|
20 |
} |
|
21 |
|
|
22 |
public void setSymbol(ISymbol symbol) { |
|
23 |
this.symbol = symbol; |
|
24 |
} |
|
25 |
|
|
26 |
public IGeometry getGeometry() { |
|
27 |
return geometry; |
|
28 |
} |
|
29 |
|
|
30 |
public void setGeometry(IGeometry geometry) { |
|
31 |
this.geometry = geometry; |
|
32 |
} |
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/Line3DFeature.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D; |
|
2 |
|
|
3 |
import org.apache.log4j.Logger; |
|
4 |
import org.gvsig.gvsig3d.simbology3D.geometry3D.Line3DGeometry; |
|
5 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
6 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.polyline.ExtrusionLine3DSymbol; |
|
7 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.polyline.SimpleLine3DSymbol; |
|
8 |
import org.gvsig.osgvp.Group; |
|
9 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
|
10 |
import org.gvsig.osgvp.planets.Planet; |
|
11 |
|
|
12 |
import com.iver.ai2.gvsig3d.legend.symbols.BaseExtrusionSymbol; |
|
13 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
14 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
15 |
|
|
16 |
public class Line3DFeature extends AbstractFeature3D { |
|
17 |
|
|
18 |
private Line3DGeometry l3DGeometry; |
|
19 |
private Abstract3DSymbol l3DSymbol; |
|
20 |
|
|
21 |
private static Logger logger = Logger.getLogger(Line3DFeature.class |
|
22 |
.getName()); |
|
23 |
|
|
24 |
public Line3DFeature(ISymbol symbol, IGeometry geometry) { |
|
25 |
super(symbol, geometry); |
|
26 |
l3DGeometry = new Line3DGeometry(geometry); |
|
27 |
// l3DGeometry = (Line3DGeometry) this.getGeometry(); |
|
28 |
// l3DSymbol = (SimpleLine3DSymbol) this.getSymbol(); |
|
29 |
|
|
30 |
if (this.getSymbol().getClass().equals(BaseExtrusionSymbol.class)) { |
|
31 |
l3DSymbol = new ExtrusionLine3DSymbol(symbol); |
|
32 |
} else { |
|
33 |
l3DSymbol = new SimpleLine3DSymbol(symbol); |
|
34 |
} |
|
35 |
|
|
36 |
|
|
37 |
} |
|
38 |
|
|
39 |
public Group Draw(Group group) { |
|
40 |
try { |
|
41 |
group.addChild(l3DGeometry.generateGeometry(l3DSymbol)); |
|
42 |
} catch (NodeException e) { |
|
43 |
logger.error("Command:" + "Error adding new child.", e); |
|
44 |
} |
|
45 |
return group; |
|
46 |
} |
|
47 |
|
|
48 |
public void setPlanet(Planet planet) { |
|
49 |
if (this.l3DGeometry != null) { |
|
50 |
this.l3DGeometry.setPlanet(planet); |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
public void setHeigth(float heigth) { |
|
55 |
if (this.l3DGeometry != null) { |
|
56 |
this.l3DGeometry.setHeigth(heigth); |
|
57 |
} |
|
58 |
} |
|
59 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/Polygon3DFeature.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D; |
|
2 |
|
|
3 |
import org.apache.log4j.Logger; |
|
4 |
import org.gvsig.gvsig3d.simbology3D.geometry3D.Abstract3DGeometry; |
|
5 |
import org.gvsig.gvsig3d.simbology3D.geometry3D.Polygon3DGeometry; |
|
6 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
7 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.polygon.ExtrusionPolygon3DSymbol; |
|
8 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.polygon.SimplePolygon3DSymbol; |
|
9 |
import org.gvsig.osgvp.Group; |
|
10 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
|
11 |
import org.gvsig.osgvp.planets.Planet; |
|
12 |
|
|
13 |
import com.iver.ai2.gvsig3d.legend.symbols.BaseExtrusionSymbol; |
|
14 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
15 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
16 |
|
|
17 |
public class Polygon3DFeature extends AbstractFeature3D { |
|
18 |
|
|
19 |
Polygon3DGeometry p3DGeometry; |
|
20 |
Abstract3DSymbol pp3DSymbol; |
|
21 |
private static Logger logger = Logger.getLogger(Abstract3DGeometry.class |
|
22 |
.getName()); |
|
23 |
|
|
24 |
public Polygon3DFeature(ISymbol symbol, IGeometry geometry) { |
|
25 |
super(symbol, geometry); |
|
26 |
// TODO Auto-generated constructor stub |
|
27 |
// p3DGeometry = (Polygon3DGeometry) this.getGeometry(); |
|
28 |
// pp3DSymbol = (SimplePolygon3DSymbol) this.getSymbol(); |
|
29 |
p3DGeometry = new Polygon3DGeometry(geometry); |
|
30 |
if (this.getSymbol().getClass().equals(BaseExtrusionSymbol.class)) { |
|
31 |
pp3DSymbol = new ExtrusionPolygon3DSymbol(symbol); |
|
32 |
} else { |
|
33 |
pp3DSymbol = new SimplePolygon3DSymbol(symbol); |
|
34 |
} |
|
35 |
} |
|
36 |
|
|
37 |
public Group Draw(Group group) { |
|
38 |
// TODO Auto-generated method stub |
|
39 |
try { |
|
40 |
group.addChild(p3DGeometry.generateGeometry(pp3DSymbol)); |
|
41 |
} catch (NodeException e) { |
|
42 |
logger.error("Command: " + "Error adding new child.", e); |
|
43 |
} |
|
44 |
return group; |
|
45 |
} |
|
46 |
|
|
47 |
public void setPlanet(Planet planet) { |
|
48 |
if (this.p3DGeometry != null) { |
|
49 |
this.p3DGeometry.setPlanet(planet); |
|
50 |
} |
|
51 |
} |
|
52 |
|
|
53 |
public void setHeigth(float heigth) { |
|
54 |
if (this.p3DGeometry != null) { |
|
55 |
this.p3DGeometry.setHeigth(heigth); |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/I3DFeature.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D; |
|
2 |
|
|
3 |
import org.gvsig.osgvp.Group; |
|
4 |
|
|
5 |
public interface I3DFeature { |
|
6 |
|
|
7 |
/** |
|
8 |
* This method build this feature into a group node |
|
9 |
* |
|
10 |
* @param group |
|
11 |
* the group to add the feature |
|
12 |
* @return the group with the feature |
|
13 |
*/ |
|
14 |
Group Draw(Group group); |
|
15 |
|
|
16 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/Point3DFeature.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D; |
|
2 |
|
|
3 |
import org.apache.log4j.Logger; |
|
4 |
import org.gvsig.gvsig3d.simbology3D.geometry3D.Point3DGeometry; |
|
5 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
6 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.point.CharacterPoint3DSymbol; |
|
7 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.point.ExtrusionPoint3DSymbol; |
|
8 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.point.MultiLayerPoint3DSymbol; |
|
9 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.point.ObjectPoint3DSymbol; |
|
10 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.point.PicturePoint3DSymbol; |
|
11 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.point.SimplePoint3DSymbol; |
|
12 |
import org.gvsig.osgvp.Group; |
|
13 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
|
14 |
import org.gvsig.osgvp.planets.Planet; |
|
15 |
import org.gvsig.symbology.fmap.symbols.CharacterMarkerSymbol; |
|
16 |
import org.gvsig.symbology.fmap.symbols.PictureMarkerSymbol; |
|
17 |
|
|
18 |
import com.iver.ai2.gvsig3d.legend.Object3DMarkerSymbol; |
|
19 |
import com.iver.ai2.gvsig3d.legend.symbols.BaseExtrusionSymbol; |
|
20 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
21 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
22 |
import com.iver.cit.gvsig.fmap.core.symbols.MultiLayerMarkerSymbol; |
|
23 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleMarkerSymbol; |
|
24 |
|
|
25 |
public class Point3DFeature extends AbstractFeature3D { |
|
26 |
|
|
27 |
private Point3DGeometry p3DGeometry; |
|
28 |
//private I3DSymbol p3DSymbol; |
|
29 |
private Abstract3DSymbol p3DSymbol; |
|
30 |
|
|
31 |
private static Logger logger = Logger.getLogger(Point3DFeature.class |
|
32 |
.getName()); |
|
33 |
|
|
34 |
public Point3DFeature(ISymbol symbol, IGeometry geometry) { |
|
35 |
super(symbol, geometry); |
|
36 |
|
|
37 |
p3DGeometry = new Point3DGeometry(geometry); |
|
38 |
// p3DSymbol = new SimplePolygon3DSymbol(symbol); |
|
39 |
|
|
40 |
if (this.getSymbol().getClass().equals(BaseExtrusionSymbol.class)) { |
|
41 |
p3DSymbol = new ExtrusionPoint3DSymbol(symbol); |
|
42 |
} |
|
43 |
else if (this.getSymbol().getClass().equals(SimpleMarkerSymbol.class)) { |
|
44 |
p3DSymbol = new SimplePoint3DSymbol(symbol); |
|
45 |
} else if (this.getSymbol().getClass().equals(PictureMarkerSymbol.class)) { |
|
46 |
p3DSymbol = new PicturePoint3DSymbol(symbol); |
|
47 |
} else if (this.getSymbol().getClass().equals(CharacterMarkerSymbol.class)) { |
|
48 |
p3DSymbol = new CharacterPoint3DSymbol(symbol); |
|
49 |
} else if (this.getSymbol().getClass().equals(MultiLayerMarkerSymbol.class)) { |
|
50 |
p3DSymbol = new MultiLayerPoint3DSymbol(symbol); |
|
51 |
} else if (this.getSymbol().getClass().equals(Object3DMarkerSymbol.class)) { |
|
52 |
p3DSymbol = new ObjectPoint3DSymbol(symbol); |
|
53 |
} |
|
54 |
|
|
55 |
} |
|
56 |
|
|
57 |
public Group Draw(Group group) { |
|
58 |
try { |
|
59 |
group.addChild(p3DGeometry.generateGeometry(p3DSymbol)); |
|
60 |
} catch (NodeException e) { |
|
61 |
logger.error("Command: " + "Error adding new child.", e); |
|
62 |
} |
|
63 |
return group; |
|
64 |
} |
|
65 |
|
|
66 |
public void setPlanet(Planet planet) { |
|
67 |
if (this.p3DGeometry != null) { |
|
68 |
this.p3DGeometry.setPlanet(planet); |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
public void setHeigth(float heigth) { |
|
73 |
if (this.p3DGeometry != null) { |
|
74 |
this.p3DGeometry.setHeigth(heigth); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
// public Group generateGeometry(Group group) { |
|
79 |
// Node node = null; |
|
80 |
// |
|
81 |
// if (geometry == null || symbol == null) |
|
82 |
// return null; |
|
83 |
// |
|
84 |
// geomType = geometry.getGeometryType(); |
|
85 |
// |
|
86 |
// |
|
87 |
// // Setup point hash map |
|
88 |
// List pointListAux = null; |
|
89 |
// if (pointsMap==null) |
|
90 |
// pointsMap = new HashMap<Double, List>(); |
|
91 |
// if ((geomType & FShape.POINT) == FShape.POINT) { |
|
92 |
// if (pointsMap.containsKey(new Integer(pointSize))) { |
|
93 |
// // System.out.println("ya contiene esa key"); |
|
94 |
// pointListAux = (List) pointsMap.get(new Double(pointSize)); |
|
95 |
// } else { |
|
96 |
// pointListAux = new ArrayList(); |
|
97 |
// pointsMap.put(new Double(pointSize), pointListAux); |
|
98 |
// } |
|
99 |
// |
|
100 |
// } |
|
101 |
// |
|
102 |
// |
|
103 |
// // Getting the Iterator |
|
104 |
// PathIterator theIteratorL = geometry.getPathIterator(null); |
|
105 |
// |
|
106 |
// double[] dataLine = new double[6]; |
|
107 |
// List<Vec3> posi = new ArrayList<Vec3>(); |
|
108 |
// int contH = 0; |
|
109 |
// // System.out.println("ENTRO"); |
|
110 |
// while (!theIteratorL.isDone()) { |
|
111 |
// // System.out.println("ITERO"); |
|
112 |
// int type = theIteratorL.currentSegment(dataLine); |
|
113 |
// |
|
114 |
// Vec3 position = getGeometryPosition(geometry,dataLine,heigth,contH); |
|
115 |
// // Adding points |
|
116 |
// switch (type) { |
|
117 |
// case PathIterator.SEG_MOVETO: |
|
118 |
// // System.out.println("SEG_MOVETO"); |
|
119 |
// // FeatureFactory.addPointToNode(node, pos, rgba, pointSize); |
|
120 |
// // posi.add(position); |
|
121 |
// pointListAux.add(new Punto3D(position, rgba, pointSize)); |
|
122 |
// break; |
|
123 |
// |
|
124 |
// case PathIterator.SEG_LINETO: |
|
125 |
// // System.out.println("SEG_LINETO"); |
|
126 |
// posi.add(position); |
|
127 |
// break; |
|
128 |
// |
|
129 |
// case PathIterator.SEG_QUADTO: |
|
130 |
// // System.out.println("SEG_QUADTO"); |
|
131 |
// break; |
|
132 |
// |
|
133 |
// case PathIterator.SEG_CUBICTO: |
|
134 |
// // System.out.println("SEG_CUBICTO"); |
|
135 |
// break; |
|
136 |
// |
|
137 |
// case PathIterator.SEG_CLOSE: |
|
138 |
// // System.out.println("SEG_CLOSE"); |
|
139 |
// break; |
|
140 |
// } |
|
141 |
// contH++; |
|
142 |
// theIteratorL.next(); |
|
143 |
// } |
|
144 |
// // System.out.println("Numero de puntos: " + contH); |
|
145 |
// |
|
146 |
// // Adding last symbol |
|
147 |
// // System.err.println("tama?o de posi " + posi.size()); |
|
148 |
// // node = FeatureFactory.insertPoints(posi, rgba, pointSize); |
|
149 |
// // group.addChild(node); |
|
150 |
// // posi.clear(); |
|
151 |
// return group; |
|
152 |
// return null; |
|
153 |
// } |
|
154 |
|
|
155 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/symbol3D/Abstract3DSymbol.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.symbol3D; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.gvsig.osgvp.Node; |
|
7 |
import org.gvsig.osgvp.Vec3; |
|
8 |
|
|
9 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
10 |
|
|
11 |
public abstract class Abstract3DSymbol implements I3DSymbol { |
|
12 |
|
|
13 |
ISymbol symbol = null; |
|
14 |
|
|
15 |
public Abstract3DSymbol(ISymbol symbol) { |
|
16 |
super(); |
|
17 |
this.symbol = symbol; |
|
18 |
} |
|
19 |
|
|
20 |
public abstract Node generateSymbol(List<Vec3> position); |
|
21 |
|
|
22 |
public Node generateSymbol(Vec3[] position) { |
|
23 |
// TODO Auto-generated method stub |
|
24 |
List<Vec3> auxList = new ArrayList<Vec3>(); |
|
25 |
for (int i = 0; i < position.length; i++) { |
|
26 |
Vec3 vec3 = position[i]; |
|
27 |
auxList.add(vec3); |
|
28 |
} |
|
29 |
return generateSymbol(auxList); |
|
30 |
} |
|
31 |
|
|
32 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/symbol3D/I3DSymbol.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.symbol3D; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.gvsig.osgvp.Node; |
|
6 |
import org.gvsig.osgvp.Vec3; |
|
7 |
|
|
8 |
|
|
9 |
public interface I3DSymbol { |
|
10 |
public Node generateSymbol(List<Vec3> position); |
|
11 |
|
|
12 |
public Node generateSymbol(Vec3[] position); |
|
13 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/symbol3D/polygon/SimplePolygon3DSymbol.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.symbol3D.polygon; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.gvsig.gvsig3d.gui.FeatureFactory; |
|
7 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
8 |
import org.gvsig.osgvp.Node; |
|
9 |
import org.gvsig.osgvp.Vec3; |
|
10 |
import org.gvsig.osgvp.Vec4; |
|
11 |
|
|
12 |
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol; |
|
13 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
14 |
|
|
15 |
public class SimplePolygon3DSymbol extends Abstract3DSymbol { |
|
16 |
|
|
17 |
protected Vec4 rgba; |
|
18 |
|
|
19 |
public SimplePolygon3DSymbol(ISymbol symbol) { |
|
20 |
super(symbol); |
|
21 |
IFillSymbol fillSymbol = (IFillSymbol) symbol; |
|
22 |
|
|
23 |
// Getting symbol properties |
|
24 |
|
|
25 |
// Symbol color and alpha value |
|
26 |
Color color = fillSymbol.getFillColor(); |
|
27 |
float alpha = fillSymbol.getFillAlpha() / 255f; |
|
28 |
rgba = new Vec4(color.getRed() / 255f, color.getGreen() / 255f, color |
|
29 |
.getBlue() / 255f, alpha); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public Node generateSymbol(List<Vec3> position) { |
|
34 |
// TODO Auto-generated method stub |
|
35 |
return FeatureFactory.insertPolygon(position, rgba, null); |
|
36 |
// return FeatureFactory.insertPolygonExtruded(position, rgba, null,1000); |
|
37 |
} |
|
38 |
|
|
39 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/symbol3D/polygon/ExtrusionPolygon3DSymbol.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.symbol3D.polygon; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.gvsig.gvsig3d.gui.FeatureFactory; |
|
7 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
8 |
import org.gvsig.osgvp.Node; |
|
9 |
import org.gvsig.osgvp.Vec3; |
|
10 |
import org.gvsig.osgvp.Vec4; |
|
11 |
|
|
12 |
import com.iver.ai2.gvsig3d.legend.symbols.BaseExtrusionSymbol; |
|
13 |
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol; |
|
14 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
15 |
|
|
16 |
public class ExtrusionPolygon3DSymbol extends Abstract3DSymbol { |
|
17 |
|
|
18 |
protected Vec4 rgba ; |
|
19 |
private double extrusion; |
|
20 |
|
|
21 |
public ExtrusionPolygon3DSymbol(ISymbol symbol) { |
|
22 |
super(symbol); |
|
23 |
BaseExtrusionSymbol baseExtrusionSymbol = (BaseExtrusionSymbol) symbol; |
|
24 |
|
|
25 |
IFillSymbol fillSymbol = (IFillSymbol) symbol; |
|
26 |
|
|
27 |
// Getting symbol properties |
|
28 |
|
|
29 |
// Symbol color and alpha value |
|
30 |
Color color = baseExtrusionSymbol.getFillColor(); |
|
31 |
// float alpha = baseExtrusionSymbol.getFillAlpha() / 255f; |
|
32 |
rgba = new Vec4(color.getRed() / 255f, color.getGreen() / 255f, color |
|
33 |
.getBlue() / 255f, 1.0); |
|
34 |
extrusion = baseExtrusionSymbol.getExtrusion(); |
|
35 |
// System.err.println("extrusion " + extrusion); |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public Node generateSymbol(List<Vec3> position) { |
|
40 |
// TODO Auto-generated method stub |
|
41 |
// return FeatureFactory.insertPolygon(position, rgba, null); |
|
42 |
return FeatureFactory.insertPolygonExtruded(position,rgba , null,extrusion); |
|
43 |
} |
|
44 |
|
|
45 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/symbol3D/point/PicturePoint3DSymbol.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.symbol3D.point; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.gvsig.gvsig3d.gui.FeatureFactory; |
|
6 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
7 |
import org.gvsig.osgvp.Node; |
|
8 |
import org.gvsig.osgvp.Vec3; |
|
9 |
import org.gvsig.osgvp.Vec4; |
|
10 |
import org.gvsig.symbology.fmap.symbols.PictureMarkerSymbol; |
|
11 |
|
|
12 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
13 |
|
|
14 |
public class PicturePoint3DSymbol extends Abstract3DSymbol{ |
|
15 |
|
|
16 |
private PictureMarkerSymbol pictureMarketSymbol; |
|
17 |
|
|
18 |
public PicturePoint3DSymbol(ISymbol symbol) { |
|
19 |
super(symbol); |
|
20 |
pictureMarketSymbol = (PictureMarkerSymbol) symbol; |
|
21 |
} |
|
22 |
|
|
23 |
@Override |
|
24 |
public Node generateSymbol(List<Vec3> position) { |
|
25 |
return FeatureFactory.generateQuadPoligon(position.get(0),new Vec4(1.0,1.0,1.0,1.0),pictureMarketSymbol.getImagePath(),(float)pictureMarketSymbol.getSize()*10); |
|
26 |
} |
|
27 |
|
|
28 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/symbol3D/point/CharacterPoint3DSymbol.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.symbol3D.point; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.Graphics2D; |
|
5 |
import java.awt.Image; |
|
6 |
import java.awt.Rectangle; |
|
7 |
import java.awt.geom.AffineTransform; |
|
8 |
import java.awt.image.BufferedImage; |
|
9 |
import java.awt.image.RenderedImage; |
|
10 |
import java.io.File; |
|
11 |
import java.io.FileOutputStream; |
|
12 |
import java.io.IOException; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
import org.gvsig.gvsig3d.gui.FeatureFactory; |
|
16 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
17 |
import org.gvsig.osgvp.Node; |
|
18 |
import org.gvsig.osgvp.Vec3; |
|
19 |
import org.gvsig.osgvp.Vec4; |
|
20 |
import org.gvsig.symbology.fmap.symbols.CharacterMarkerSymbol; |
|
21 |
|
|
22 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
23 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
24 |
import com.iver.cit.gvsig.fmap.core.symbols.SymbolDrawingException; |
|
25 |
import com.sun.media.jai.codec.ImageCodec; |
|
26 |
import com.sun.media.jai.codec.ImageEncoder; |
|
27 |
import com.sun.media.jai.codec.PNGEncodeParam; |
|
28 |
import com.sun.media.jai.codec.TIFFEncodeParam; |
|
29 |
|
|
30 |
public class CharacterPoint3DSymbol extends Abstract3DSymbol{ |
|
31 |
|
|
32 |
private CharacterMarkerSymbol characterMarketSymbol; |
|
33 |
private String imagePath = null; |
|
34 |
|
|
35 |
|
|
36 |
public String getImagePath() { |
|
37 |
return imagePath; |
|
38 |
} |
|
39 |
|
|
40 |
public void setImagePath(String imagePath) { |
|
41 |
this.imagePath = imagePath; |
|
42 |
} |
|
43 |
|
|
44 |
public CharacterPoint3DSymbol(ISymbol symbol) { |
|
45 |
super(symbol); |
|
46 |
characterMarketSymbol = (CharacterMarkerSymbol) symbol; |
|
47 |
this.setImagePath(rasterizeSymbol(characterMarketSymbol)); |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public Node generateSymbol(List<Vec3> position) { |
|
53 |
return FeatureFactory.generateQuadPoligon(position.get(0),new Vec4(1.0,1.0,1.0,1.0),this.getImagePath(),(float)characterMarketSymbol.getSize()*10); |
|
54 |
} |
|
55 |
|
|
56 |
|
|
57 |
private String rasterizeSymbol(CharacterMarkerSymbol sym) { |
|
58 |
|
|
59 |
BufferedImage image; |
|
60 |
// Setting the size symbol |
|
61 |
double size = sym.getSize(); |
|
62 |
// Generating the image |
|
63 |
image = new BufferedImage((int) size, (int) size, |
|
64 |
BufferedImage.TYPE_INT_ARGB); |
|
65 |
// Getting graphics |
|
66 |
Graphics2D graphics = image.createGraphics(); |
|
67 |
// Transparent background |
|
68 |
Color backgColor = new Color(0, 0,0, 0); |
|
69 |
graphics.setColor(backgColor); |
|
70 |
// Setting the fill rectangle |
|
71 |
graphics.fillRect(0, 0, (int) size, (int) size); |
|
72 |
// Drawing |
|
73 |
|
|
74 |
AffineTransform at =new AffineTransform(); |
|
75 |
at.scale(10, 10); |
|
76 |
|
|
77 |
try { |
|
78 |
sym.drawInsideRectangle(graphics,at ,new Rectangle((int)size,(int)size)); |
|
79 |
} catch (SymbolDrawingException e1) { |
|
80 |
try { |
|
81 |
SymbologyFactory.getWarningSymbol( |
|
82 |
SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS, |
|
83 |
"desc", |
|
84 |
SymbolDrawingException.SHAPETYPE_MISMATCH). |
|
85 |
drawInsideRectangle(graphics,at ,new Rectangle((int)size,(int)size)); |
|
86 |
} catch (SymbolDrawingException e) { /* impossible */ } |
|
87 |
} |
|
88 |
|
|
89 |
String sip = "SymbolTmp.png"; |
|
90 |
File file = new File(sip); |
|
91 |
String format = "png"; |
|
92 |
try { |
|
93 |
saveCachedFile(image, format, file); |
|
94 |
} catch (IOException e) { |
|
95 |
// TODO Auto-generated catch block |
|
96 |
e.printStackTrace(); |
|
97 |
} |
|
98 |
|
|
99 |
return sip; |
|
100 |
} |
|
101 |
|
|
102 |
public void saveCachedFile(Image img, String format, File f) |
|
103 |
throws IOException { |
|
104 |
// ImageIO.write((RenderedImage) img, format, f); |
|
105 |
// File file = new File(fName); |
|
106 |
FileOutputStream out = new FileOutputStream(f); |
|
107 |
if (f.exists()){ |
|
108 |
f.delete(); |
|
109 |
f.createNewFile(); |
|
110 |
} |
|
111 |
if (format.equals("png")) { |
|
112 |
PNGEncodeParam params = new PNGEncodeParam.RGB(); |
|
113 |
|
|
114 |
// params.setsetCompression(TIFFEncodeParam.COMPRESSION_NONE); |
|
115 |
ImageEncoder encoder = ImageCodec.createImageEncoder("PNG", out, |
|
116 |
params); |
|
117 |
if (encoder == null) { |
|
118 |
System.out.println("imageEncoder is null"); |
|
119 |
System.exit(0); |
|
120 |
} |
|
121 |
encoder.encode((RenderedImage) img); |
|
122 |
} else if (format.equals("tif")) { |
|
123 |
TIFFEncodeParam params = new TIFFEncodeParam(); |
|
124 |
params.setCompression(TIFFEncodeParam.COMPRESSION_NONE); |
|
125 |
ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out, |
|
126 |
params); |
|
127 |
if (encoder == null) { |
|
128 |
System.out.println("imageEncoder is null"); |
|
129 |
System.exit(0); |
|
130 |
} |
|
131 |
encoder.encode((RenderedImage) img); |
|
132 |
} |
|
133 |
out.close(); |
|
134 |
} |
|
135 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/symbol3D/point/ExtrusionPoint3DSymbol.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 org.gvsig.gvsig3d.simbology3D.symbol3D.point; |
|
20 |
|
|
21 |
import java.awt.Color; |
|
22 |
import java.util.List; |
|
23 |
|
|
24 |
import org.gvsig.gvsig3d.gui.FeatureFactory; |
|
25 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
26 |
import org.gvsig.osgvp.Node; |
|
27 |
import org.gvsig.osgvp.Vec3; |
|
28 |
import org.gvsig.osgvp.Vec4; |
|
29 |
|
|
30 |
import com.iver.ai2.gvsig3d.legend.symbols.BaseExtrusionSymbol; |
|
31 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
|
32 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
33 |
|
|
34 |
public class ExtrusionPoint3DSymbol extends Abstract3DSymbol{ |
|
35 |
|
|
36 |
|
|
37 |
protected Vec4 rgba ; |
|
38 |
private double extrusion; |
|
39 |
|
|
40 |
public ExtrusionPoint3DSymbol(ISymbol symbol) { |
|
41 |
super(symbol); |
|
42 |
BaseExtrusionSymbol baseExtrusionSymbol = (BaseExtrusionSymbol) symbol; |
|
43 |
|
|
44 |
// ILineSymbol fillSymbol = (ILineSymbol) symbol; |
|
45 |
|
|
46 |
// Getting symbol properties |
|
47 |
|
|
48 |
// Symbol color and alpha value |
|
49 |
Color color = baseExtrusionSymbol.getFillColor(); |
|
50 |
// float alpha = baseExtrusionSymbol.getFillAlpha() / 255f; |
|
51 |
rgba = new Vec4(color.getRed() / 255f, color.getGreen() / 255f, color |
|
52 |
.getBlue() / 255f, 0.7); |
|
53 |
extrusion = baseExtrusionSymbol.getExtrusion(); |
|
54 |
// System.err.println("extrusion " + extrusion); |
|
55 |
} |
|
56 |
|
|
57 |
public Node generateSymbol(List<Vec3> position) { |
|
58 |
// TODO Auto-generated method stub |
|
59 |
// return FeatureFactory.insertPolygon(position, rgba, null); |
|
60 |
//return FeatureFactory.addPointToNode(position,rgba , null,extrusion); |
|
61 |
//return FeatureFactory.addPointToNode(node, newPosition, rgba, (int) size); |
|
62 |
return FeatureFactory.insertPointExtruded(position,rgba , null,extrusion); |
|
63 |
} |
|
64 |
|
|
65 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/symbol3D/point/ObjectPoint3DSymbol.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.symbol3D.point; |
|
2 |
|
|
3 |
import java.io.FileNotFoundException; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.gvsig.gvsig3d.gui.FeatureFactory; |
|
8 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
9 |
import org.gvsig.osgvp.AutoTransform; |
|
10 |
import org.gvsig.osgvp.Group; |
|
11 |
import org.gvsig.osgvp.Node; |
|
12 |
import org.gvsig.osgvp.PositionAttitudeTransform; |
|
13 |
import org.gvsig.osgvp.Vec3; |
|
14 |
import org.gvsig.osgvp.Vec4; |
|
15 |
import org.gvsig.osgvp.osgDB; |
|
16 |
import org.gvsig.osgvp.AutoTransform.AutoRotateMode; |
|
17 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
|
18 |
import org.gvsig.symbology.fmap.symbols.PictureMarkerSymbol; |
|
19 |
|
|
20 |
import com.iver.ai2.gvsig3d.legend.Object3DMarkerSymbol; |
|
21 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
22 |
import com.sun.java_cup.internal.sym; |
|
23 |
|
|
24 |
public class ObjectPoint3DSymbol extends Abstract3DSymbol { |
|
25 |
|
|
26 |
private Object3DMarkerSymbol object3DMarketSymbol; |
|
27 |
private static Node object3D = null; |
|
28 |
private static String oldPath = ""; |
|
29 |
|
|
30 |
public ObjectPoint3DSymbol(ISymbol symbol) { |
|
31 |
super(symbol); |
|
32 |
object3DMarketSymbol = (Object3DMarkerSymbol) symbol; |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
public Node generateSymbol(List<Vec3> position) { |
|
37 |
|
|
38 |
Group group = new Group(); |
|
39 |
PositionAttitudeTransform posAttTrasn = null; |
|
40 |
Vec3 scale = object3DMarketSymbol.getScale(); |
|
41 |
Vec3 rotation = object3DMarketSymbol.getRotationObject(); |
|
42 |
try { |
|
43 |
// Node object3D = osgDB.readNodeFile("D:/modelos3d/cow.ive"); |
|
44 |
if (!(oldPath.equals(object3DMarketSymbol.getObject3DPath()))){ |
|
45 |
oldPath = object3DMarketSymbol.getObject3DPath(); |
|
46 |
object3D = osgDB.readNodeFile(oldPath); |
|
47 |
} |
|
48 |
for (Iterator iterator = position.iterator(); iterator.hasNext();) { |
|
49 |
Vec3 pos = (Vec3) iterator.next(); |
|
50 |
System.err.println("position " + pos.x() + " " + pos.y() + " " |
|
51 |
+ pos.z()); |
|
52 |
posAttTrasn = new PositionAttitudeTransform(); |
|
53 |
posAttTrasn.setPosition(pos); |
|
54 |
posAttTrasn.setScale(scale); |
|
55 |
|
|
56 |
if (object3DMarketSymbol.isAutoRotate()) { |
|
57 |
AutoTransform autoRotateTrasn = null; |
|
58 |
autoRotateTrasn = new AutoTransform(); |
|
59 |
autoRotateTrasn.setPosition(pos); |
|
60 |
autoRotateTrasn.addChild(posAttTrasn); |
|
61 |
autoRotateTrasn |
|
62 |
.setAutoRotateMode(AutoTransform.AutoRotateMode.ROTATE_TO_CAMERA); |
|
63 |
// autoRotateTrasn.setAutoScaleToScreen(true); |
|
64 |
group.addChild(autoRotateTrasn); |
|
65 |
} else { |
|
66 |
group.addChild(posAttTrasn); |
|
67 |
} |
|
68 |
posAttTrasn.addChild(object3D); |
|
69 |
|
|
70 |
} |
|
71 |
} catch (NodeException e1) { |
|
72 |
// TODO Auto-generated catch block |
|
73 |
e1.printStackTrace(); |
|
74 |
} catch (FileNotFoundException e) { |
|
75 |
// TODO Auto-generated catch block |
|
76 |
e.printStackTrace(); |
|
77 |
} |
|
78 |
|
|
79 |
return group; |
|
80 |
} |
|
81 |
|
|
82 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/symbol3D/point/MultiLayerPoint3DSymbol.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.symbol3D.point; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.Graphics2D; |
|
5 |
import java.awt.Image; |
|
6 |
import java.awt.Rectangle; |
|
7 |
import java.awt.geom.AffineTransform; |
|
8 |
import java.awt.image.BufferedImage; |
|
9 |
import java.awt.image.RenderedImage; |
|
10 |
import java.io.File; |
|
11 |
import java.io.FileOutputStream; |
|
12 |
import java.io.IOException; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
import org.gvsig.gvsig3d.gui.FeatureFactory; |
|
16 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
17 |
import org.gvsig.osgvp.Node; |
|
18 |
import org.gvsig.osgvp.Vec3; |
|
19 |
import org.gvsig.osgvp.Vec4; |
|
20 |
|
|
21 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
22 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
23 |
import com.iver.cit.gvsig.fmap.core.symbols.MultiLayerMarkerSymbol; |
|
24 |
import com.iver.cit.gvsig.fmap.core.symbols.SymbolDrawingException; |
|
25 |
import com.sun.media.jai.codec.ImageCodec; |
|
26 |
import com.sun.media.jai.codec.ImageEncoder; |
|
27 |
import com.sun.media.jai.codec.PNGEncodeParam; |
|
28 |
import com.sun.media.jai.codec.TIFFEncodeParam; |
|
29 |
|
|
30 |
public class MultiLayerPoint3DSymbol extends Abstract3DSymbol{ |
|
31 |
|
|
32 |
private MultiLayerMarkerSymbol multiLayerMarketSymbol; |
|
33 |
private String imagePath = null; |
|
34 |
|
|
35 |
|
|
36 |
public String getImagePath() { |
|
37 |
return imagePath; |
|
38 |
} |
|
39 |
|
|
40 |
public void setImagePath(String imagePath) { |
|
41 |
this.imagePath = imagePath; |
|
42 |
} |
|
43 |
|
|
44 |
public MultiLayerPoint3DSymbol(ISymbol symbol) { |
|
45 |
super(symbol); |
|
46 |
multiLayerMarketSymbol = (MultiLayerMarkerSymbol) symbol; |
|
47 |
this.setImagePath(rasterizeSymbol(multiLayerMarketSymbol)); |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public Node generateSymbol(List<Vec3> position) { |
|
53 |
return FeatureFactory.generateQuadPoligon(position.get(0),new Vec4(1.0,1.0,1.0,1.0),this.getImagePath(),(float)multiLayerMarketSymbol.getSize()*10); |
|
54 |
} |
|
55 |
|
|
56 |
|
|
57 |
private String rasterizeSymbol(MultiLayerMarkerSymbol sym) { |
|
58 |
|
|
59 |
BufferedImage image; |
|
60 |
// Setting the size symbol |
|
61 |
double size = sym.getSize(); |
|
62 |
// Generating the image |
|
63 |
image = new BufferedImage((int) size, (int) size, |
|
64 |
BufferedImage.TYPE_INT_ARGB); |
|
65 |
// Getting graphics |
|
66 |
Graphics2D graphics = image.createGraphics(); |
|
67 |
// Transparent background |
|
68 |
Color backgColor = new Color(0, 0,0, 0); |
|
69 |
graphics.setColor(backgColor); |
|
70 |
// Setting the fill rectangle |
|
71 |
graphics.fillRect(0, 0, (int) size, (int) size); |
|
72 |
// Drawing |
|
73 |
|
|
74 |
AffineTransform at =new AffineTransform(); |
|
75 |
at.scale(10, 10); |
|
76 |
|
|
77 |
try { |
|
78 |
sym.drawInsideRectangle(graphics,at ,new Rectangle((int)size,(int)size)); |
|
79 |
} catch (SymbolDrawingException e1) { |
|
80 |
try { |
|
81 |
SymbologyFactory.getWarningSymbol( |
|
82 |
SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS, |
|
83 |
"desc", |
|
84 |
SymbolDrawingException.SHAPETYPE_MISMATCH). |
|
85 |
drawInsideRectangle(graphics,at ,new Rectangle((int)size,(int)size)); |
|
86 |
} catch (SymbolDrawingException e) { /* impossible */ } |
|
87 |
} |
|
88 |
|
|
89 |
String sip = "SymbolTmp.png"; |
|
90 |
File file = new File(sip); |
|
91 |
String format = "png"; |
|
92 |
try { |
|
93 |
saveCachedFile(image, format, file); |
|
94 |
} catch (IOException e) { |
|
95 |
// TODO Auto-generated catch block |
|
96 |
e.printStackTrace(); |
|
97 |
} |
|
98 |
|
|
99 |
return sip; |
|
100 |
} |
|
101 |
|
|
102 |
public void saveCachedFile(Image img, String format, File f) |
|
103 |
throws IOException { |
|
104 |
// ImageIO.write((RenderedImage) img, format, f); |
|
105 |
// File file = new File(fName); |
|
106 |
FileOutputStream out = new FileOutputStream(f); |
|
107 |
if (f.exists()){ |
|
108 |
f.delete(); |
|
109 |
f.createNewFile(); |
|
110 |
} |
|
111 |
if (format.equals("png")) { |
|
112 |
PNGEncodeParam params = new PNGEncodeParam.RGB(); |
|
113 |
|
|
114 |
// params.setsetCompression(TIFFEncodeParam.COMPRESSION_NONE); |
|
115 |
ImageEncoder encoder = ImageCodec.createImageEncoder("PNG", out, |
|
116 |
params); |
|
117 |
if (encoder == null) { |
|
118 |
System.out.println("imageEncoder is null"); |
|
119 |
System.exit(0); |
|
120 |
} |
|
121 |
encoder.encode((RenderedImage) img); |
|
122 |
} else if (format.equals("tif")) { |
|
123 |
TIFFEncodeParam params = new TIFFEncodeParam(); |
|
124 |
params.setCompression(TIFFEncodeParam.COMPRESSION_NONE); |
|
125 |
ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out, |
|
126 |
params); |
|
127 |
if (encoder == null) { |
|
128 |
System.out.println("imageEncoder is null"); |
|
129 |
System.exit(0); |
|
130 |
} |
|
131 |
encoder.encode((RenderedImage) img); |
|
132 |
} |
|
133 |
out.close(); |
|
134 |
} |
|
135 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/symbol3D/point/SimplePoint3DSymbol.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.symbol3D.point; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.io.FileNotFoundException; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
|
|
8 |
import org.gvsig.gvsig3d.gui.FeatureFactory; |
|
9 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
10 |
import org.gvsig.osgvp.Node; |
|
11 |
import org.gvsig.osgvp.Vec3; |
|
12 |
import org.gvsig.osgvp.Vec4; |
|
13 |
import org.gvsig.osgvp.osgDB; |
|
14 |
import org.gvsig.osgvp.exceptions.node.LoadNodeException; |
|
15 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
|
16 |
import org.gvsig.osgvp.features.PixelPoint; |
|
17 |
import org.gvsig.osgvp.features.Sphere; |
|
18 |
|
|
19 |
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol; |
|
20 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
21 |
|
|
22 |
public class SimplePoint3DSymbol extends Abstract3DSymbol { |
|
23 |
|
|
24 |
// Los tipo puntos tienen q tener una unica instancia de pixel point. |
|
25 |
// Podrian tener un hasMap como en el caso del piloto |
|
26 |
private static Map<Double, PixelPoint> pointsMap; |
|
27 |
private Vec4 rgba; |
|
28 |
private double size; |
|
29 |
private Node node; |
|
30 |
|
|
31 |
public SimplePoint3DSymbol(ISymbol symbol) { |
|
32 |
super(symbol); |
|
33 |
IMarkerSymbol marketSymbol = (IMarkerSymbol) symbol; |
|
34 |
|
|
35 |
// Symbol color and alpha value |
|
36 |
Color color = marketSymbol.getColor(); |
|
37 |
rgba = new Vec4(color.getRed() / 255f, color.getGreen() / 255f, color |
|
38 |
.getBlue() / 255f, color.getAlpha()); |
|
39 |
|
|
40 |
size = marketSymbol.getSize(); |
|
41 |
|
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public Node generateSymbol(List<Vec3> position) { |
|
46 |
// TODO Auto-generated method stub |
|
47 |
// return FeatureFactory.generateQuadPoligon(position.get(0),new |
|
48 |
// Vec4(1.0,0.0,0.0,1.0),null,400); |
|
49 |
if (node == null) |
|
50 |
node = FeatureFactory.insertPointL(position, rgba, (int) size); |
|
51 |
Vec3 newPosition = new Vec3(0, 0, 0); |
|
52 |
FeatureFactory.addPointToNode(node, newPosition, rgba, (int) size); |
|
53 |
return node; |
|
54 |
} |
|
55 |
|
|
56 |
public Node generateSymbol(Vec3 position) { |
|
57 |
// TODO Auto-generated method stub |
|
58 |
// return FeatureFactory.generateQuadPoligon(position.get(0),new |
|
59 |
// Vec4(1.0,0.0,0.0,1.0),null,400); |
|
60 |
// if (node == null) |
|
61 |
// node = FeatureFactory.insertPointL(position, rgba, (int) size); |
|
62 |
// Vec3 newPosition = new Vec3(0, 0, 0); |
|
63 |
// FeatureFactory.addPointToNode(node, newPosition, rgba, (int) size); |
|
64 |
// return node; |
|
65 |
// Sphere sphere = null; |
|
66 |
// try { |
|
67 |
// sphere = new Sphere(); |
|
68 |
// sphere.setRadius((float) size); |
|
69 |
// sphere.setColor(rgba); |
|
70 |
// sphere.setCenter(position); |
|
71 |
// } catch (NodeException e) { |
|
72 |
// // TODO Auto-generated catch block |
|
73 |
// e.printStackTrace(); |
|
74 |
// } |
|
75 |
Node n = null; |
|
76 |
try { |
|
77 |
n = osgDB.readNodeFile("D:\\modelos 3d\\axes.osg") ; |
|
78 |
} catch (LoadNodeException e) { |
|
79 |
// TODO Auto-generated catch block |
|
80 |
e.printStackTrace(); |
|
81 |
} catch (FileNotFoundException e) { |
|
82 |
// TODO Auto-generated catch block |
|
83 |
e.printStackTrace(); |
|
84 |
} |
|
85 |
return n; |
|
86 |
} |
|
87 |
|
|
88 |
private Node getPointNode(double key) { |
|
89 |
PixelPoint pixelPoint = null; |
|
90 |
|
|
91 |
if (pointsMap.containsKey(new Double(key))) { |
|
92 |
// System.out.println("ya contiene esa key"); |
|
93 |
pixelPoint = pointsMap.get(new Double(key)); |
|
94 |
} else { |
|
95 |
try { |
|
96 |
pixelPoint = new PixelPoint(); |
|
97 |
} catch (NodeException e) { |
|
98 |
// TODO Auto-generated catch block |
|
99 |
e.printStackTrace(); |
|
100 |
} |
|
101 |
pointsMap.put(new Double(key), pixelPoint); |
|
102 |
} |
|
103 |
|
|
104 |
return pixelPoint; |
|
105 |
} |
|
106 |
|
|
107 |
} |
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap/src/org/gvsig/gvsig3d/simbology3D/symbol3D/polyline/SimpleLine3DSymbol.java | ||
---|---|---|
1 |
package org.gvsig.gvsig3d.simbology3D.symbol3D.polyline; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.gvsig.gvsig3d.gui.FeatureFactory; |
|
7 |
import org.gvsig.gvsig3d.simbology3D.symbol3D.Abstract3DSymbol; |
|
8 |
import org.gvsig.osgvp.Node; |
|
9 |
import org.gvsig.osgvp.Vec3; |
|
10 |
import org.gvsig.osgvp.Vec4; |
|
11 |
|
|
12 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
|
13 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
14 |
|
|
15 |
public class SimpleLine3DSymbol extends Abstract3DSymbol { |
|
16 |
|
|
17 |
protected Vec4 rgba; |
|
18 |
protected float lineWidth; |
|
19 |
|
|
20 |
public SimpleLine3DSymbol(ISymbol symbol) { |
|
21 |
super(symbol); |
|
22 |
|
|
23 |
ILineSymbol lineSymbol = (ILineSymbol) symbol; |
|
24 |
// Getting symbol properties |
|
25 |
|
|
26 |
// Symbol color and alpha value |
|
27 |
Color color = lineSymbol.getColor(); |
|
28 |
float alpha = lineSymbol.getAlpha() / 255f; |
|
29 |
rgba = new Vec4(color.getRed() / 255f, color.getGreen() / 255f, color |
|
30 |
.getBlue() / 255f, alpha); |
|
31 |
|
|
32 |
// LineWidth and stroke |
|
33 |
lineWidth = 2f; |
|
34 |
lineWidth = (float) lineSymbol.getLineWidth(); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public Node generateSymbol(List<Vec3> position) { |
|
39 |
return FeatureFactory.insertLine(position, rgba, lineWidth); |
|
40 |
} |
|
41 |
|
|
42 |
} |
Also available in: Unified diff