gvsig-3d / 2.0 / trunk / org.gvsig.gvsig3d / org.gvsig.gvsig3d.lib / org.gvsig.gvsig3d.lib.impl / src / main / java / org / gvsig / gvsig3d / impl / symbology3d / line / impl / SimpleLine3DSymbol.java @ 317
History | View | Annotate | Download (5.76 KB)
1 |
package org.gvsig.gvsig3d.impl.symbology3d.line.impl; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Graphics2D; |
5 |
import java.awt.Rectangle; |
6 |
import java.awt.geom.AffineTransform; |
7 |
|
8 |
import org.gvsig.compat.print.PrintAttributes; |
9 |
import org.gvsig.fmap.dal.feature.Feature; |
10 |
import org.gvsig.fmap.geom.Geometry; |
11 |
import org.gvsig.fmap.geom.GeometryLocator; |
12 |
import org.gvsig.fmap.geom.GeometryManager; |
13 |
import org.gvsig.fmap.geom.primitive.Curve; |
14 |
import org.gvsig.fmap.geom.primitive.Surface; |
15 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
16 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
17 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException; |
18 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
19 |
import org.gvsig.gvsig3d.impl.symbology3d.fill.impl.SimpleFill3DSymbol; |
20 |
import org.gvsig.gvsig3d.symbology3d.fill.ISimpleFill3DSymbol; |
21 |
import org.gvsig.gvsig3d.symbology3d.line.ISimpleLine3DSymbol; |
22 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
23 |
import org.gvsig.osgvp.geometry.GeoMultiPolygon3D; |
24 |
import org.gvsig.osgvp.geometry.GeoPolygon3D; |
25 |
import org.gvsig.osgvp.geometry.GeoPolygonList3D; |
26 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.AbstractFillSymbol; |
27 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ILineStyle; |
28 |
import org.gvsig.tools.task.Cancellable; |
29 |
import org.gvsig.tools.util.Callable; |
30 |
import org.slf4j.Logger; |
31 |
import org.slf4j.LoggerFactory; |
32 |
|
33 |
public class SimpleLine3DSymbol extends AbstractFillSymbol implements ISimpleLine3DSymbol{ |
34 |
|
35 |
public static final String SIMPLE_FILL3D_SYMBOL_PERSISTENCE_DEFINITION_NAME = "SimpleFill3DSymbol"; |
36 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
37 |
private static final Logger LOG = LoggerFactory.getLogger(SimpleFill3DSymbol.class); |
38 |
public GeoPolygonList3D _geometry;
|
39 |
public GeoMultiPolygon3D _mpolygon;
|
40 |
|
41 |
|
42 |
|
43 |
public SimpleLine3DSymbol()
|
44 |
{ |
45 |
super();
|
46 |
try {
|
47 |
_geometry = new GeoPolygonList3D();
|
48 |
} catch (NodeException e) {
|
49 |
// TODO Auto-generated catch block
|
50 |
e.printStackTrace(); |
51 |
} |
52 |
} |
53 |
|
54 |
|
55 |
public void setLineColor(Color color) { |
56 |
// TODO Auto-generated method stub
|
57 |
|
58 |
} |
59 |
|
60 |
public ILineStyle getLineStyle() {
|
61 |
// TODO Auto-generated method stub
|
62 |
return null; |
63 |
} |
64 |
|
65 |
public void setLineStyle(ILineStyle lineStyle) { |
66 |
// TODO Auto-generated method stub
|
67 |
|
68 |
} |
69 |
|
70 |
public void setLineWidth(double width) { |
71 |
// TODO Auto-generated method stub
|
72 |
|
73 |
} |
74 |
|
75 |
public double getLineWidth() { |
76 |
// TODO Auto-generated method stub
|
77 |
return 0; |
78 |
} |
79 |
|
80 |
public int getAlpha() { |
81 |
// TODO Auto-generated method stub
|
82 |
return 0; |
83 |
} |
84 |
|
85 |
public void setAlpha(int outlineAlpha) { |
86 |
// TODO Auto-generated method stub
|
87 |
|
88 |
} |
89 |
|
90 |
public ISymbol getSymbolForSelection() {
|
91 |
// TODO Auto-generated method stub
|
92 |
return null; |
93 |
} |
94 |
|
95 |
public void draw(Graphics2D g, AffineTransform affineTransform, |
96 |
Geometry geom, Feature f, Cancellable cancel) { |
97 |
Color c = getFillColor();
|
98 |
//geom.getClass().getName()
|
99 |
|
100 |
|
101 |
//WAITING for gvSIG ARCHITECTS to do something with polygons with holes in shp files
|
102 |
//in the meanwhile nothing is gonna happen with this kind of polygons
|
103 |
if (geom.getGeometryType().isTypeOf(Geometry.TYPES.SURFACE))
|
104 |
{ |
105 |
Surface s = (Surface)geom.cloneGeometry(); |
106 |
_geometry.addMultiPolygon(getGeoMultiPolygon(s)); |
107 |
} |
108 |
if (geom.getGeometryType().isTypeOf(Geometry.TYPES.CURVE))
|
109 |
{ |
110 |
Curve s = (Curve)geom.cloneGeometry(); |
111 |
_geometry.addMultiPolygon(getGeoMultiPolygon(s)); |
112 |
} |
113 |
} |
114 |
|
115 |
public GeoMultiPolygon3D getGeoMultiPolygon(Surface surface)
|
116 |
{ |
117 |
GeoMultiPolygon3D gmpoly = null;
|
118 |
GeoPolygon3D poly = null;
|
119 |
try {
|
120 |
gmpoly= new GeoMultiPolygon3D();
|
121 |
poly = new GeoPolygon3D();
|
122 |
} catch (NodeException e) {
|
123 |
// TODO Auto-generated catch block
|
124 |
e.printStackTrace(); |
125 |
} |
126 |
int numVerts = surface.getNumVertices();
|
127 |
if (surface.getGeometryType().isSubTypeOf(Geometry.SUBTYPES.GEOM3D))
|
128 |
for(int i=0;i<numVerts;i++) |
129 |
poly.addPoint(surface.getCoordinateAt(i, 0),surface.getCoordinateAt(i, 1),surface.getCoordinateAt(i, 2)); |
130 |
else
|
131 |
for(int i=0;i<numVerts;i++) |
132 |
poly.addPoint(surface.getCoordinateAt(i, 0),surface.getCoordinateAt(i, 1),1.0); |
133 |
gmpoly.addPolygon(poly); |
134 |
|
135 |
return gmpoly;
|
136 |
} |
137 |
|
138 |
public GeoMultiPolygon3D getGeoMultiPolygon(Curve curve)
|
139 |
{ |
140 |
GeoMultiPolygon3D gmpoly = null;
|
141 |
GeoPolygon3D poly = null;
|
142 |
try {
|
143 |
gmpoly= new GeoMultiPolygon3D();
|
144 |
poly = new GeoPolygon3D();
|
145 |
} catch (NodeException e) {
|
146 |
// TODO Auto-generated catch block
|
147 |
e.printStackTrace(); |
148 |
} |
149 |
int numVerts = curve.getNumVertices();
|
150 |
if (curve.getGeometryType().isSubTypeOf(Geometry.SUBTYPES.GEOM3D))
|
151 |
for(int i=0;i<numVerts;i++) |
152 |
poly.addPoint(curve.getCoordinateAt(i, 0),curve.getCoordinateAt(i, 1),curve.getCoordinateAt(i, 2)); |
153 |
else
|
154 |
for(int i=0;i<numVerts;i++) |
155 |
poly.addPoint(curve.getCoordinateAt(i, 0),curve.getCoordinateAt(i, 1),1.0); |
156 |
gmpoly.addPolygon(poly); |
157 |
|
158 |
return gmpoly;
|
159 |
} |
160 |
public GeoPolygonList3D getGeometry(){
|
161 |
return _geometry;
|
162 |
} |
163 |
|
164 |
|
165 |
public int getSymbolType() { |
166 |
// TODO Auto-generated method stub
|
167 |
return 0; |
168 |
} |
169 |
|
170 |
public void drawInsideRectangle(Graphics2D g, |
171 |
AffineTransform scaleInstance, Rectangle r, |
172 |
PrintAttributes properties) throws SymbolDrawingException {
|
173 |
// TODO Auto-generated method stub
|
174 |
|
175 |
} |
176 |
|
177 |
public void print(Graphics2D g, AffineTransform at, Geometry shape, |
178 |
PrintAttributes properties) { |
179 |
// TODO Auto-generated method stub
|
180 |
|
181 |
} |
182 |
public static class RegisterSymbol implements Callable { |
183 |
|
184 |
public Object call() throws Exception { |
185 |
int[] shapeTypes; |
186 |
SymbolManager manager = MapContextLocator.getSymbolManager(); |
187 |
|
188 |
shapeTypes = |
189 |
new int[] {Geometry.TYPES.CURVE, Geometry.TYPES.ARC, |
190 |
Geometry.TYPES.ELLIPTICARC, Geometry.TYPES.MULTICURVE}; |
191 |
manager.registerSymbol(ISimpleLine3DSymbol.SYMBOL_NAME, |
192 |
shapeTypes, |
193 |
SimpleLine3DSymbol.class,"project.document.view3d");
|
194 |
|
195 |
return Boolean.TRUE; |
196 |
} |
197 |
|
198 |
} |
199 |
|
200 |
} |