gvsig-3d / 2.1 / 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 @ 385
History | View | Annotate | Download (5.96 KB)
1 |
/* gvSIG 3D extension for gvSIG
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2012 Prodevelop.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Prodevelop, S.L.
|
22 |
* Pza. Don Juan de Villarrasa, 14 - 5
|
23 |
* 46001 Valencia
|
24 |
* Spain
|
25 |
*
|
26 |
* +34 963 510 612
|
27 |
* +34 963 510 968
|
28 |
* prode@prodevelop.es
|
29 |
* http://www.prodevelop.es
|
30 |
*/
|
31 |
/*
|
32 |
* AUTHORS:
|
33 |
* 2012 AI2 - Instituto Universitario de Automatica e Informatica Industrial.
|
34 |
* Universitat Politecnica de Valencia (UPV)
|
35 |
* http://www.ai2.upv.es
|
36 |
*/
|
37 |
|
38 |
|
39 |
package org.gvsig.gvsig3d.impl.symbology3d.extrusion.impl; |
40 |
|
41 |
import org.gvsig.fmap.geom.Geometry; |
42 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
43 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
44 |
import org.gvsig.gvsig3d.impl.symbology3d.fill.impl.SimpleFill3DSymbol; |
45 |
import org.gvsig.gvsig3d.symbology3d.extrusion.IExtrusionSymbol; |
46 |
import org.gvsig.gvsig3d.symbology3d.fill.ISimpleFill3DSymbol; |
47 |
import org.gvsig.osgvp.core.osg.Node; |
48 |
import org.gvsig.osgvp.exceptions.node.NodeException; |
49 |
import org.gvsig.osgvp.geometry.GeoPolygonList3D; |
50 |
import org.gvsig.osgvp.symbology.fill.ExtrudedFill; |
51 |
import org.gvsig.osgvp.symbology.fill.SimpleFill; |
52 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.AbstractFillSymbol; |
53 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.SimpleFillSymbol; |
54 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.AbstractSymbol; |
55 |
import org.gvsig.tools.ToolsLocator; |
56 |
import org.gvsig.tools.dynobject.DynStruct; |
57 |
import org.gvsig.tools.persistence.PersistenceManager; |
58 |
import org.gvsig.tools.persistence.PersistentState; |
59 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
60 |
import org.gvsig.tools.util.Callable; |
61 |
import org.gvsig.tools.util.Caller; |
62 |
import org.gvsig.tools.util.impl.DefaultCaller; |
63 |
|
64 |
/**
|
65 |
* @author Jesus Zarzoso- jzarzoso@ai2.upv.es
|
66 |
* @version $Id$
|
67 |
*
|
68 |
*/
|
69 |
public class ExtrusionPolygonSymbol extends SimpleFill3DSymbol implements |
70 |
IExtrusionSymbol { |
71 |
|
72 |
private float extrusion = 0.0f; |
73 |
|
74 |
public ExtrusionPolygonSymbol() {
|
75 |
// TODO Auto-generated constructor stub
|
76 |
try {
|
77 |
this.sm = new ExtrudedFill(); |
78 |
this._geometry = new GeoPolygonList3D(); |
79 |
|
80 |
sm.setColor(this.getColor());
|
81 |
} catch (NodeException e) {
|
82 |
// TODO Auto-generated catch block
|
83 |
e.printStackTrace(); |
84 |
} |
85 |
} |
86 |
|
87 |
public ExtrusionPolygonSymbol(float f) { |
88 |
// TODO Auto-generated constructor stub
|
89 |
try {
|
90 |
this.sm = new ExtrudedFill(); |
91 |
this._geometry = new GeoPolygonList3D(); |
92 |
sm.setColor(this.getColor());
|
93 |
this.setExtrusion(f);
|
94 |
this.setDescription(new Float(f).toString()); |
95 |
} catch (NodeException e) {
|
96 |
// TODO Auto-generated catch block
|
97 |
e.printStackTrace(); |
98 |
} |
99 |
} |
100 |
|
101 |
public float getExtrusion() { |
102 |
return this.extrusion; |
103 |
} |
104 |
|
105 |
public void setExtrusion(float extrusion) { |
106 |
this.extrusion = extrusion;
|
107 |
((ExtrudedFill) this.sm).setExtrusionHeight(extrusion);
|
108 |
} |
109 |
|
110 |
public Node getRenderNode() {
|
111 |
return sm.buildSceneGraph(_geometry);
|
112 |
} |
113 |
|
114 |
// public static class RegisterSymbol implements Callable {
|
115 |
//
|
116 |
// public Object call() throws Exception {
|
117 |
// int[] shapeTypes;
|
118 |
// SymbolManager manager = MapContextLocator.getSymbolManager();
|
119 |
//
|
120 |
// shapeTypes =
|
121 |
// new int[] { Geometry.TYPES.SURFACE, Geometry.TYPES.MULTISURFACE};
|
122 |
// manager.registerSymbol(IExtrusionSymbol.SYMBOL_NAME,
|
123 |
// shapeTypes,
|
124 |
// ExtrusionPolygonSymbol.class,"project.document.view3d");
|
125 |
//
|
126 |
// return Boolean.TRUE;
|
127 |
// }
|
128 |
// }
|
129 |
public boolean is3D() { |
130 |
// TODO Auto-generated method stub
|
131 |
return true; |
132 |
} |
133 |
|
134 |
public void setCoordinateSystemType(int cst) { |
135 |
_coordinateSystemType = cst; |
136 |
|
137 |
} |
138 |
|
139 |
public void loadFromState(PersistentState state) |
140 |
throws PersistenceException {
|
141 |
// Set parent fill symbol properties
|
142 |
super.loadFromState(state);
|
143 |
|
144 |
// // Set own properties
|
145 |
// setStyle(state.getInt(FIELD_MARKERSTYLE));
|
146 |
// setOutlined(state.getBoolean(FIELD_OUTLINED));
|
147 |
// if (isOutlined()) {
|
148 |
// setOutlineColor((Color) state.get(FIELD_OUTLINECOLOR));
|
149 |
// setOutlineSize(state.getDouble(FIELD_OUTLINESIZE));
|
150 |
// }
|
151 |
} |
152 |
|
153 |
public void saveToState(PersistentState state) throws PersistenceException { |
154 |
// Save parent fill symbol properties
|
155 |
super.saveToState(state);
|
156 |
|
157 |
// Save own properties
|
158 |
// state.set(FIELD_MARKERSTYLE, getStyle());
|
159 |
// state.set(FIELD_OUTLINED, isOutlined());
|
160 |
// if (isOutlined()) {
|
161 |
// state.set(FIELD_OUTLINECOLOR, getOutlineColor());
|
162 |
// state.set(FIELD_OUTLINESIZE, getOutlineSize());
|
163 |
// }
|
164 |
} |
165 |
|
166 |
public static class RegisterPersistence implements Callable { |
167 |
|
168 |
public Object call() throws Exception { |
169 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
170 |
if (manager.getDefinition("Symbol") == null) { |
171 |
Caller caller = new DefaultCaller();
|
172 |
caller.add(new AbstractSymbol.RegisterPersistence());
|
173 |
caller.call(); |
174 |
} |
175 |
|
176 |
if (manager.getDefinition("SimpleFill3DSymbol") == null) { |
177 |
Caller caller = new DefaultCaller();
|
178 |
caller.add(new SimpleFill3DSymbol.RegisterPersistence());
|
179 |
caller.call(); |
180 |
} |
181 |
|
182 |
DynStruct definition = manager.addDefinition( |
183 |
ExtrusionPolygonSymbol.class, "ExtrusionPolygonSymbol",
|
184 |
"ExtrusionPolygonSymbol Persistence definition", null, null); |
185 |
|
186 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, |
187 |
"FillSymbol");
|
188 |
|
189 |
return Boolean.TRUE; |
190 |
} |
191 |
} |
192 |
|
193 |
} |