Revision 317 2.0/trunk/org.gvsig.gvsig3d/org.gvsig.gvsig3d.lib/org.gvsig.gvsig3d.lib.impl/src/main/java/org/gvsig/gvsig3d/impl/symbology3d/fill/impl/SimpleFill3DSymbol.java

View differences:

SimpleFill3DSymbol.java
13 13
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
14 14
import org.gvsig.fmap.geom.exception.CreateGeometryException;
15 15
import org.gvsig.fmap.geom.primitive.GeneralPathX;
16
import org.gvsig.fmap.geom.primitive.GeneralPathXIterator;
17
import org.gvsig.fmap.geom.primitive.Surface;
16 18
import org.gvsig.fmap.mapcontext.MapContextLocator;
17 19
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
18 20
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException;
......
21 23
import org.gvsig.gvsig3d.symbology3d.fill.ISimpleFill3DSymbol;
22 24
import org.gvsig.gvsig3d.symbology3d.marker.ISimpleMarker3DSymbol;
23 25
import org.gvsig.osgvp.exceptions.node.NodeException;
26
import org.gvsig.osgvp.geometry.GeoMultiPolygon3D;
24 27
import org.gvsig.osgvp.geometry.GeoPointArray3D;
28
import org.gvsig.osgvp.geometry.GeoPolygon3D;
25 29
import org.gvsig.osgvp.geometry.GeoPolygonList3D;
26 30
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.AbstractFillSymbol;
27 31
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.SimpleFillSymbol;
......
44 48
	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
45 49
	private static final Logger LOG = LoggerFactory.getLogger(SimpleFill3DSymbol.class);
46 50
	public GeoPolygonList3D _geometry;
51
	public GeoMultiPolygon3D _mpolygon;
47 52

  
48
	
49 53
	public SimpleFill3DSymbol() 
50 54
	{
51 55
		super();
52 56
		try {
53 57
			_geometry = new GeoPolygonList3D();
54
			System.out.println("new FillSymbol");
55 58
		} catch (NodeException e) {
56 59
			// TODO Auto-generated catch block
57 60
			e.printStackTrace();
58 61
		}
59 62
	}
60
	
63

  
61 64
	public ISymbol getSymbolForSelection() {
62 65
		// TODO Auto-generated method stub
63 66
		return null;
64 67
	}
65 68

  
69

  
70

  
66 71
	public void draw(Graphics2D g, AffineTransform affineTransform,
67 72
			Geometry geom, Feature f, Cancellable cancel) {
73

  
68 74
		Color c = getFillColor();
69
		org.gvsig.fmap.geom.primitive.Surface s = (org.gvsig.fmap.geom.primitive.Surface)geom.cloneGeometry();
70
		s.getNumVertices();
71
		System.out.println("surfacer3D: "+ s.getNumVertices());
72
//		if (c!=null && hasFill()) {
73
//			g.setColor(c);
74
//			
75
//			
76
//			
77
//			g.fill(geom.getShape(affineTransform));
78
//		}
79
//      Border color		
80
//		if (getOutline() != null && hasOutline()) {
81
//			getOutline().draw(g, affineTransform, geom, f, cancel);
82
//		}
75
		//geom.getClass().getName()
83 76
		
77

  
78
		//WAITING for gvSIG ARCHITECTS to do something with polygons with holes in shp files
79
		//in the meanwhile nothing is gonna happen with this kind of polygons
80
		if (geom.getGeometryType().isTypeOf(Geometry.TYPES.SURFACE))
81
		{
82
			Surface s = (Surface)geom.cloneGeometry();
83
			_geometry.addMultiPolygon(getGeoMultiPolygon(s));
84
		}
85
		
86
		
87
		//		if (c!=null && hasFill()) {
88
		//			g.setColor(c);
89
		//			
90
		//			
91
		//			
92
		//			g.fill(geom.getShape(affineTransform));
93
		//		}
94
		//      Border color		
95
		//		if (getOutline() != null && hasOutline()) {
96
		//			getOutline().draw(g, affineTransform, geom, f, cancel);
97
		//		}
98

  
84 99
	}
85

  
100
	
101
	
102
	public GeoMultiPolygon3D getGeoMultiPolygon(Surface surface)
103
	{
104
		GeoMultiPolygon3D gmpoly = null;
105
		GeoPolygon3D poly = null;
106
		try {
107
			gmpoly=	new GeoMultiPolygon3D();
108
			poly = new GeoPolygon3D();
109
		} catch (NodeException e) {
110
			// TODO Auto-generated catch block
111
			e.printStackTrace();
112
		}
113
		int numVerts = surface.getNumVertices();
114
		if (surface.getGeometryType().isSubTypeOf(Geometry.SUBTYPES.GEOM3D))
115
			for(int i=0;i<numVerts;i++)		
116
				poly.addPoint(surface.getCoordinateAt(i, 0),surface.getCoordinateAt(i, 1),surface.getCoordinateAt(i, 2));
117
		else
118
			for(int i=0;i<numVerts;i++)
119
				poly.addPoint(surface.getCoordinateAt(i, 0),surface.getCoordinateAt(i, 1),1.0);
120
		gmpoly.addPolygon(poly);
121
		
122
		return gmpoly;
123
	}
124
	public GeoPolygonList3D getGeometry(){
125
		return _geometry;
126
	}
86 127
	public int getSymbolType() {
87 128
		// TODO Auto-generated method stub
88 129
		return 0;
......
91 132
	public void drawInsideRectangle(Graphics2D g,
92 133
			AffineTransform scaleInstance, Rectangle r,
93 134
			PrintAttributes properties) throws SymbolDrawingException {
94
		
135

  
95 136
		Rectangle rect = new Rectangle(r.x, r.y, r.width, r.height);
96 137
		rect.setFrame(((int) rect.getMinX())+1, ((int) rect.getMinY())+1, ((int) rect.getWidth())-2, ((int) rect.getHeight())-2);
97 138
		Geometry geom;
......
107 148
			g.setColor(c);
108 149
			g.fillRect(rect.x, rect.y, rect.width, rect.height);
109 150
		}
110
// Border Polygons
111
//		
112
//		if (getOutline() != null && hasOutline()) {
113
//			if (properties==null)
114
//				getOutline().draw(g, scaleInstance, geom, null, null);
115
//			else
116
//				print(g, new AffineTransform(), geom, properties);
117
//		}
118
		
151
		// Border Polygons
152
		//		
153
		//		if (getOutline() != null && hasOutline()) {
154
		//			if (properties==null)
155
		//				getOutline().draw(g, scaleInstance, geom, null, null);
156
		//			else
157
		//				print(g, new AffineTransform(), geom, properties);
158
		//		}
159

  
119 160
	}
120 161
	public static class RegisterSymbol implements Callable {
121 162

  
......
136 177
	public void print(Graphics2D g, AffineTransform at, Geometry shape,
137 178
			PrintAttributes properties) {
138 179
		// TODO Auto-generated method stub
139
		
180

  
140 181
	}
141 182

  
183

  
142 184
}

Also available in: Unified diff