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 / extrusion / impl / ExtrusionPolygonSymbol.java @ 369
History | View | Annotate | Download (4.76 KB)
1 |
package org.gvsig.gvsig3d.impl.symbology3d.extrusion.impl; |
---|---|
2 |
|
3 |
import org.gvsig.fmap.geom.Geometry; |
4 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
5 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
6 |
import org.gvsig.gvsig3d.impl.symbology3d.fill.impl.SimpleFill3DSymbol; |
7 |
import org.gvsig.gvsig3d.symbology3d.extrusion.IExtrusionSymbol; |
8 |
import org.gvsig.gvsig3d.symbology3d.fill.ISimpleFill3DSymbol; |
9 |
import org.gvsig.osgvp.core.osg.Node; |
10 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
11 |
import org.gvsig.osgvp.geometry.GeoPolygonList3D; |
12 |
import org.gvsig.osgvp.symbology.fill.ExtrudedFill; |
13 |
import org.gvsig.osgvp.symbology.fill.SimpleFill; |
14 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.AbstractFillSymbol; |
15 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.SimpleFillSymbol; |
16 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.AbstractSymbol; |
17 |
import org.gvsig.tools.ToolsLocator; |
18 |
import org.gvsig.tools.dynobject.DynStruct; |
19 |
import org.gvsig.tools.persistence.PersistenceManager; |
20 |
import org.gvsig.tools.persistence.PersistentState; |
21 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
22 |
import org.gvsig.tools.util.Callable; |
23 |
import org.gvsig.tools.util.Caller; |
24 |
import org.gvsig.tools.util.impl.DefaultCaller; |
25 |
|
26 |
/**
|
27 |
* @author AI2
|
28 |
* @version $Id$
|
29 |
*
|
30 |
*/
|
31 |
public class ExtrusionPolygonSymbol extends SimpleFill3DSymbol implements |
32 |
IExtrusionSymbol { |
33 |
|
34 |
private float extrusion = 0.0f; |
35 |
|
36 |
public ExtrusionPolygonSymbol() {
|
37 |
// TODO Auto-generated constructor stub
|
38 |
try {
|
39 |
this.sm = new ExtrudedFill(); |
40 |
this._geometry = new GeoPolygonList3D(); |
41 |
|
42 |
sm.setColor(this.getColor());
|
43 |
} catch (NodeException e) {
|
44 |
// TODO Auto-generated catch block
|
45 |
e.printStackTrace(); |
46 |
} |
47 |
} |
48 |
|
49 |
public ExtrusionPolygonSymbol(float f) { |
50 |
// TODO Auto-generated constructor stub
|
51 |
try {
|
52 |
this.sm = new ExtrudedFill(); |
53 |
this._geometry = new GeoPolygonList3D(); |
54 |
sm.setColor(this.getColor());
|
55 |
this.setExtrusion(f);
|
56 |
this.setDescription(new Float(f).toString()); |
57 |
} catch (NodeException e) {
|
58 |
// TODO Auto-generated catch block
|
59 |
e.printStackTrace(); |
60 |
} |
61 |
} |
62 |
|
63 |
public float getExtrusion() { |
64 |
return this.extrusion; |
65 |
} |
66 |
|
67 |
public void setExtrusion(float extrusion) { |
68 |
this.extrusion = extrusion;
|
69 |
((ExtrudedFill) this.sm).setExtrusionHeight(extrusion);
|
70 |
} |
71 |
|
72 |
public Node getRenderNode() {
|
73 |
return sm.buildSceneGraph(_geometry);
|
74 |
} |
75 |
|
76 |
// public static class RegisterSymbol implements Callable {
|
77 |
//
|
78 |
// public Object call() throws Exception {
|
79 |
// int[] shapeTypes;
|
80 |
// SymbolManager manager = MapContextLocator.getSymbolManager();
|
81 |
//
|
82 |
// shapeTypes =
|
83 |
// new int[] { Geometry.TYPES.SURFACE, Geometry.TYPES.MULTISURFACE};
|
84 |
// manager.registerSymbol(IExtrusionSymbol.SYMBOL_NAME,
|
85 |
// shapeTypes,
|
86 |
// ExtrusionPolygonSymbol.class,"project.document.view3d");
|
87 |
//
|
88 |
// return Boolean.TRUE;
|
89 |
// }
|
90 |
// }
|
91 |
public boolean is3D() { |
92 |
// TODO Auto-generated method stub
|
93 |
return true; |
94 |
} |
95 |
|
96 |
public void setCoordinateSystemType(int cst) { |
97 |
_coordinateSystemType = cst; |
98 |
|
99 |
} |
100 |
|
101 |
public void loadFromState(PersistentState state) |
102 |
throws PersistenceException {
|
103 |
// Set parent fill symbol properties
|
104 |
super.loadFromState(state);
|
105 |
|
106 |
// // Set own properties
|
107 |
// setStyle(state.getInt(FIELD_MARKERSTYLE));
|
108 |
// setOutlined(state.getBoolean(FIELD_OUTLINED));
|
109 |
// if (isOutlined()) {
|
110 |
// setOutlineColor((Color) state.get(FIELD_OUTLINECOLOR));
|
111 |
// setOutlineSize(state.getDouble(FIELD_OUTLINESIZE));
|
112 |
// }
|
113 |
} |
114 |
|
115 |
public void saveToState(PersistentState state) throws PersistenceException { |
116 |
// Save parent fill symbol properties
|
117 |
super.saveToState(state);
|
118 |
|
119 |
// Save own properties
|
120 |
// state.set(FIELD_MARKERSTYLE, getStyle());
|
121 |
// state.set(FIELD_OUTLINED, isOutlined());
|
122 |
// if (isOutlined()) {
|
123 |
// state.set(FIELD_OUTLINECOLOR, getOutlineColor());
|
124 |
// state.set(FIELD_OUTLINESIZE, getOutlineSize());
|
125 |
// }
|
126 |
} |
127 |
|
128 |
public static class RegisterPersistence implements Callable { |
129 |
|
130 |
public Object call() throws Exception { |
131 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
132 |
if (manager.getDefinition("Symbol") == null) { |
133 |
Caller caller = new DefaultCaller();
|
134 |
caller.add(new AbstractSymbol.RegisterPersistence());
|
135 |
caller.call(); |
136 |
} |
137 |
|
138 |
if (manager.getDefinition("SimpleFill3DSymbol") == null) { |
139 |
Caller caller = new DefaultCaller();
|
140 |
caller.add(new SimpleFill3DSymbol.RegisterPersistence());
|
141 |
caller.call(); |
142 |
} |
143 |
|
144 |
DynStruct definition = manager.addDefinition( |
145 |
ExtrusionPolygonSymbol.class, "ExtrusionPolygonSymbol",
|
146 |
"ExtrusionPolygonSymbol Persistence definition", null, null); |
147 |
|
148 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, |
149 |
"FillSymbol");
|
150 |
|
151 |
return Boolean.TRUE; |
152 |
} |
153 |
} |
154 |
|
155 |
} |