Statistics
| Revision:

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 @ 350

History | View | Annotate | Download (6.07 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.core.osg.Node;
23
import org.gvsig.osgvp.exceptions.node.NodeException;
24
import org.gvsig.osgvp.geometry.GeoMultiPolygon3D;
25
import org.gvsig.osgvp.geometry.GeoPolygon3D;
26
import org.gvsig.osgvp.geometry.GeoPolygonList3D;
27
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.AbstractFillSymbol;
28
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ILineStyle;
29
import org.gvsig.tools.task.Cancellable;
30
import org.gvsig.tools.util.Callable;
31
import org.slf4j.Logger;
32
import org.slf4j.LoggerFactory;
33

    
34
public class SimpleLine3DSymbol extends AbstractFillSymbol implements ISimpleLine3DSymbol{
35
        
36
        public static final String SIMPLE_FILL3D_SYMBOL_PERSISTENCE_DEFINITION_NAME = "SimpleFill3DSymbol";
37
        private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
38
        private static final Logger LOG = LoggerFactory.getLogger(SimpleFill3DSymbol.class);
39
        public GeoPolygonList3D _geometry;
40
        public GeoMultiPolygon3D _mpolygon;
41
        
42
        protected float _height=100;
43
        
44
        public SimpleLine3DSymbol() 
45
        {
46
                super();
47
                try {
48
                        _geometry = new GeoPolygonList3D();
49
                } catch (NodeException e) {
50
                        // TODO Auto-generated catch block
51
                        e.printStackTrace();
52
                }
53
        }
54

    
55
        
56
        public void setLineColor(Color color) {
57
                // TODO Auto-generated method stub
58
                
59
        }
60

    
61
        public ILineStyle getLineStyle() {
62
                // TODO Auto-generated method stub
63
                return null;
64
        }
65

    
66
        public void setLineStyle(ILineStyle lineStyle) {
67
                // TODO Auto-generated method stub
68
                
69
        }
70

    
71
        public void setLineWidth(double width) {
72
                // TODO Auto-generated method stub
73
                
74
        }
75

    
76
        public double getLineWidth() {
77
                // TODO Auto-generated method stub
78
                return 0;
79
        }
80

    
81
        public int getAlpha() {
82
                // TODO Auto-generated method stub
83
                return 0;
84
        }
85

    
86
        public void setAlpha(int outlineAlpha) {
87
                // TODO Auto-generated method stub
88
                
89
        }
90

    
91
        public ISymbol getSymbolForSelection() {
92
                // TODO Auto-generated method stub
93
                return null;
94
        }
95

    
96
        public void draw(Graphics2D g, AffineTransform affineTransform,
97
                        Geometry geom, Feature f, Cancellable cancel) {
98
                        Color c = getFillColor();
99
                //geom.getClass().getName()
100
                
101

    
102
                //WAITING for gvSIG ARCHITECTS to do something with polygons with holes in shp files
103
                //in the meanwhile nothing is gonna happen with this kind of polygons
104
                if (geom.getGeometryType().isTypeOf(Geometry.TYPES.SURFACE))
105
                {
106
                        Surface s = (Surface)geom.cloneGeometry();
107
                        _geometry.addMultiPolygon(getGeoMultiPolygon(s));
108
                }
109
                if (geom.getGeometryType().isTypeOf(Geometry.TYPES.CURVE))
110
                {
111
                        Curve s = (Curve)geom.cloneGeometry();
112
                        _geometry.addMultiPolygon(getGeoMultiPolygon(s));
113
                }
114
        }
115
        
116
        public GeoMultiPolygon3D getGeoMultiPolygon(Surface surface)
117
        {
118
                GeoMultiPolygon3D gmpoly = null;
119
                GeoPolygon3D poly = null;
120
                try {
121
                        gmpoly=        new GeoMultiPolygon3D();
122
                        poly = new GeoPolygon3D();
123
                } catch (NodeException e) {
124
                        // TODO Auto-generated catch block
125
                        e.printStackTrace();
126
                }
127
                int numVerts = surface.getNumVertices();
128
                if (surface.getGeometryType().isSubTypeOf(Geometry.SUBTYPES.GEOM3D))
129
                        for(int i=0;i<numVerts;i++)                
130
                                poly.addPoint(surface.getCoordinateAt(i, 0),surface.getCoordinateAt(i, 1),surface.getCoordinateAt(i, 2));
131
                else
132
                        for(int i=0;i<numVerts;i++)
133
                                poly.addPoint(surface.getCoordinateAt(i, 0),surface.getCoordinateAt(i, 1),1.0);
134
                gmpoly.addPolygon(poly);
135
                
136
                return gmpoly;
137
        }
138
        
139
        public GeoMultiPolygon3D getGeoMultiPolygon(Curve curve)
140
        {
141
                GeoMultiPolygon3D gmpoly = null;
142
                GeoPolygon3D poly = null;
143
                try {
144
                        gmpoly=        new GeoMultiPolygon3D();
145
                        poly = new GeoPolygon3D();
146
                } catch (NodeException e) {
147
                        // TODO Auto-generated catch block
148
                        e.printStackTrace();
149
                }
150
                int numVerts = curve.getNumVertices();
151
                if (curve.getGeometryType().isSubTypeOf(Geometry.SUBTYPES.GEOM3D))
152
                        for(int i=0;i<numVerts;i++)                
153
                                poly.addPoint(curve.getCoordinateAt(i, 0),curve.getCoordinateAt(i, 1),curve.getCoordinateAt(i, 2));
154
                else
155
                        for(int i=0;i<numVerts;i++)
156
                                poly.addPoint(curve.getCoordinateAt(i, 0),curve.getCoordinateAt(i, 1),_height);
157
                gmpoly.addPolygon(poly);
158
                
159
                return gmpoly;
160
        }
161
        public GeoPolygonList3D getGeometry(){
162
                return _geometry;
163
        }
164
        
165
        
166
        public int getSymbolType() {
167
                // TODO Auto-generated method stub
168
                return 0;
169
        }
170

    
171
        public void drawInsideRectangle(Graphics2D g,
172
                        AffineTransform scaleInstance, Rectangle r,
173
                        PrintAttributes properties) throws SymbolDrawingException {
174
                // TODO Auto-generated method stub
175
                
176
        }
177

    
178
        public void print(Graphics2D g, AffineTransform at, Geometry shape,
179
                        PrintAttributes properties) {
180
                // TODO Auto-generated method stub
181
                
182
        }
183
        public static class RegisterSymbol implements Callable {
184

    
185
                public Object call() throws Exception {
186
                        int[] shapeTypes;
187
                        SymbolManager manager = MapContextLocator.getSymbolManager();
188

    
189
                        shapeTypes =
190
                                new int[] {Geometry.TYPES.CURVE, Geometry.TYPES.ARC,
191
                        Geometry.TYPES.ELLIPTICARC, Geometry.TYPES.MULTICURVE};
192
                        manager.registerSymbol(ISimpleLine3DSymbol.SYMBOL_NAME,
193
                                        shapeTypes,
194
                                        SimpleLine3DSymbol.class,"project.document.view3d");
195

    
196
                        return Boolean.TRUE;
197
                }
198

    
199
        }
200
        public void setFixedHeight(float height) {
201
        _height=height;
202
                
203
        }
204

    
205

    
206
        public void setCoordinateSystemType(int cst) {
207
                // TODO Auto-generated method stub
208
                
209
        }
210

    
211

    
212
        public Node getRenderNode() {
213
                // TODO Auto-generated method stub
214
                return null;
215
        }
216

    
217
}