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 / fill / impl / SimpleFill3DSymbol.java @ 316
History | View | Annotate | Download (4.49 KB)
1 |
package org.gvsig.gvsig3d.impl.symbology3d.fill.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.Geometry.SUBTYPES; |
14 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
15 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
16 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
17 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
18 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException; |
19 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
20 |
import org.gvsig.gvsig3d.impl.symbology3d.marker.impl.SimpleMarker3DSymbol; |
21 |
import org.gvsig.gvsig3d.symbology3d.fill.ISimpleFill3DSymbol; |
22 |
import org.gvsig.gvsig3d.symbology3d.marker.ISimpleMarker3DSymbol; |
23 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
24 |
import org.gvsig.osgvp.geometry.GeoPointArray3D; |
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.fill.impl.SimpleFillSymbol; |
28 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.AbstractMarkerSymbol; |
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 |
|
35 |
/**
|
36 |
*
|
37 |
* @author jtorres
|
38 |
*
|
39 |
*/
|
40 |
|
41 |
public class SimpleFill3DSymbol extends AbstractFillSymbol implements ISimpleFill3DSymbol{ |
42 |
|
43 |
public static final String SIMPLE_FILL3D_SYMBOL_PERSISTENCE_DEFINITION_NAME = "SimpleFill3DSymbol"; |
44 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
45 |
private static final Logger LOG = LoggerFactory.getLogger(SimpleFill3DSymbol.class); |
46 |
public GeoPolygonList3D _geometry;
|
47 |
|
48 |
|
49 |
public SimpleFill3DSymbol()
|
50 |
{ |
51 |
super();
|
52 |
try {
|
53 |
_geometry = new GeoPolygonList3D();
|
54 |
System.out.println("new FillSymbol"); |
55 |
} catch (NodeException e) {
|
56 |
// TODO Auto-generated catch block
|
57 |
e.printStackTrace(); |
58 |
} |
59 |
} |
60 |
|
61 |
public ISymbol getSymbolForSelection() {
|
62 |
// TODO Auto-generated method stub
|
63 |
return null; |
64 |
} |
65 |
|
66 |
public void draw(Graphics2D g, AffineTransform affineTransform, |
67 |
Geometry geom, Feature f, Cancellable cancel) { |
68 |
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 |
// }
|
83 |
|
84 |
} |
85 |
|
86 |
public int getSymbolType() { |
87 |
// TODO Auto-generated method stub
|
88 |
return 0; |
89 |
} |
90 |
|
91 |
public void drawInsideRectangle(Graphics2D g, |
92 |
AffineTransform scaleInstance, Rectangle r, |
93 |
PrintAttributes properties) throws SymbolDrawingException {
|
94 |
|
95 |
Rectangle rect = new Rectangle(r.x, r.y, r.width, r.height); |
96 |
rect.setFrame(((int) rect.getMinX())+1, ((int) rect.getMinY())+1, ((int) rect.getWidth())-2, ((int) rect.getHeight())-2); |
97 |
Geometry geom; |
98 |
try {
|
99 |
geom = geomManager.createSurface(new GeneralPathX(rect.getPathIterator(null)), SUBTYPES.GEOM2D); |
100 |
} catch (CreateGeometryException e) {
|
101 |
LOG.error("Creating a surface", e);
|
102 |
throw new SymbolDrawingException(getSymbolType()); |
103 |
} |
104 |
|
105 |
Color c = getFillColor();
|
106 |
if (c != null && hasFill()) { |
107 |
g.setColor(c); |
108 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
109 |
} |
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 |
|
119 |
} |
120 |
public static class RegisterSymbol implements Callable { |
121 |
|
122 |
public Object call() throws Exception { |
123 |
int[] shapeTypes; |
124 |
SymbolManager manager = MapContextLocator.getSymbolManager(); |
125 |
|
126 |
shapeTypes = |
127 |
new int[] { Geometry.TYPES.SURFACE, Geometry.TYPES.MULTISURFACE}; |
128 |
manager.registerSymbol(ISimpleFill3DSymbol.SYMBOL_NAME, |
129 |
shapeTypes, |
130 |
SimpleFill3DSymbol.class,"project.document.view3d");
|
131 |
|
132 |
return Boolean.TRUE; |
133 |
} |
134 |
|
135 |
} |
136 |
public void print(Graphics2D g, AffineTransform at, Geometry shape, |
137 |
PrintAttributes properties) { |
138 |
// TODO Auto-generated method stub
|
139 |
|
140 |
} |
141 |
|
142 |
} |