gvsig-3d / 2.1 / trunk / org.gvsig.gvsig3d / org.gvsig.gvsig3d.lib / org.gvsig.gvsig3d.lib.impl / src / main / java / org / gvsig / gvsig3d / impl / DefaultGvsig3DManager.java @ 385
History | View | Annotate | Download (12 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; |
40 |
|
41 |
import org.cresques.cts.IProjection; |
42 |
import org.gvsig.fmap.mapcontext.ViewPort; |
43 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
44 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
45 |
import org.gvsig.gvsig3d.Gvsig3DException; |
46 |
import org.gvsig.gvsig3d.Gvsig3DManager; |
47 |
import org.gvsig.gvsig3d.hud.Hud; |
48 |
import org.gvsig.gvsig3d.impl.hud.HudImpl; |
49 |
import org.gvsig.gvsig3d.impl.layers.FLayers3DImpl; |
50 |
import org.gvsig.gvsig3d.impl.map3d.GraphicLayer3DImpl; |
51 |
import org.gvsig.gvsig3d.impl.map3d.Layer3DPropsImpl; |
52 |
import org.gvsig.gvsig3d.impl.map3d.MapContext3DImpl; |
53 |
import org.gvsig.gvsig3d.impl.map3d.MapControl3DImpl; |
54 |
import org.gvsig.gvsig3d.impl.map3d.Viewport3DImpl; |
55 |
import org.gvsig.gvsig3d.impl.navigation.NavigationMaskImpl; |
56 |
import org.gvsig.gvsig3d.impl.navigation.NavigationModeImpl; |
57 |
import org.gvsig.gvsig3d.impl.symbology3d.fill.impl.SimpleFill3DSymbol; |
58 |
import org.gvsig.gvsig3d.impl.symbology3d.line.impl.SimpleLine3DSymbol; |
59 |
import org.gvsig.gvsig3d.impl.symbology3d.marker.impl.SimpleMarker3DSymbol; |
60 |
import org.gvsig.gvsig3d.lib.spi.Gvsig3DProviderLocator; |
61 |
import org.gvsig.gvsig3d.map3d.GraphicLayer3D; |
62 |
import org.gvsig.gvsig3d.map3d.Layer3DProps; |
63 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
64 |
import org.gvsig.gvsig3d.map3d.MapControl3D; |
65 |
import org.gvsig.gvsig3d.map3d.ViewPort3D; |
66 |
import org.gvsig.gvsig3d.map3d.layers.FLayers3D; |
67 |
import org.gvsig.gvsig3d.navigation.NavigationMask; |
68 |
import org.gvsig.gvsig3d.navigation.NavigationMode; |
69 |
import org.gvsig.gvsig3d.symbology3d.fill.ISimpleFill3DSymbol; |
70 |
import org.gvsig.gvsig3d.symbology3d.line.ISimpleLine3DSymbol; |
71 |
import org.gvsig.gvsig3d.symbology3d.marker.ISimpleMarker3DSymbol; |
72 |
import org.gvsig.osgvp.terrain.Terrain; |
73 |
import org.gvsig.osgvp.terrain.TerrainCameraManipulator; |
74 |
import org.gvsig.osgvp.terrain.TerrainViewer; |
75 |
import org.gvsig.osgvp.viewer.IViewerContainer; |
76 |
import org.gvsig.tools.ToolsLocator; |
77 |
import org.gvsig.tools.dynobject.DynObject; |
78 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
79 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
80 |
import org.gvsig.tools.service.AbstractManager; |
81 |
import org.gvsig.tools.service.Service; |
82 |
import org.gvsig.tools.service.ServiceException; |
83 |
import org.slf4j.Logger; |
84 |
import org.slf4j.LoggerFactory; |
85 |
|
86 |
/**
|
87 |
* Default {@link Gvsig3DManager} implementation.
|
88 |
*
|
89 |
* @author Jesus Zarzoso- jzarzoso@ai2.upv.es
|
90 |
* @version $Id$
|
91 |
*/
|
92 |
public class DefaultGvsig3DManager extends AbstractManager implements |
93 |
Gvsig3DManager { |
94 |
|
95 |
final static private Logger logger = LoggerFactory |
96 |
.getLogger(Gvsig3DManager.class); |
97 |
|
98 |
final static private String GVSIG3D_MANAGER_MAPCONTEXT3D = "Gvsig3D.manager.mapcontext3D"; |
99 |
final static private String GVSIG3D_MANAGER_MAPCONTEXT3D_DEFAULT = "default"; |
100 |
final static private String GVSIG3D_MANAGER_MAPCONTEXT3D_DESCRIPTION = "gvSIG3D MapContext Class"; |
101 |
|
102 |
final static private String GVSIG3D_MANAGER_MAPCONTROL3D = "Gvsig3D.manager.mapcontrol3D"; |
103 |
final static private String GVSIG3D_MANAGER_MAPCONTROL3D_DEFAULT = "default"; |
104 |
final static private String GVSIG3D_MANAGER_MAPCONTROL3D_DESCRIPTION = "gvSIG3D MapControl Class"; |
105 |
|
106 |
final static private String GVSIG3D_MANAGER_GRAPHICSLAYER3D = "Gvsig3D.manager.graphicslayer3D"; |
107 |
final static private String GVSIG3D_MANAGER_GRAPHICSLAYER3D_DEFAULT = "default"; |
108 |
final static private String GVSIG3D_MANAGER_GRAPHICSLAYER3D_DESCRIPTION = "gvSIG3D MapControl Class"; |
109 |
|
110 |
final static private String GVSIG3D_MANAGER_LAYER3DPROPS = "Gvsig3D.manager.layer3Dprops"; |
111 |
final static private String GVSIG3D_MANAGER_LAYER3DPROPS_DEFAULT = "default"; |
112 |
final static private String GVSIG3D_MANAGER_LAYER3DPROPS_DESCRIPTION = "gvSIG3D Layer3Dprops Class"; |
113 |
|
114 |
final static private String GVSIG3D_MANAGER_VIEWPORT3D = "Gvsig3D.manager.viewport3D"; |
115 |
final static private String GVSIG3D_MANAGER_VIEWPORT3D_DEFAULT = "default"; |
116 |
final static private String GVSIG3D_MANAGER_VIEWPORT3D_DESCRIPTION = "gvSIG3D Viewport3D Class"; |
117 |
|
118 |
final static private String GVSIG3D_MANAGER_FLAYERS3D = "Gvsig3D.manager.flayers3D"; |
119 |
final static private String GVSIG3D_MANAGER_FLAYERS3D_DEFAULT = "default"; |
120 |
final static private String GVSIG3D_MANAGER_FLAYERS3D_DESCRIPTION = "gvSIG3D FLayers3D Class"; |
121 |
|
122 |
private ExtensionPointManager extensionPoints = ToolsLocator
|
123 |
.getExtensionPointManager(); |
124 |
|
125 |
/**
|
126 |
* Empty constructor.
|
127 |
*/
|
128 |
public DefaultGvsig3DManager() {
|
129 |
super(Gvsig3DProviderLocator.getManager());
|
130 |
extensionPoints.add(GVSIG3D_MANAGER_MAPCONTEXT3D, |
131 |
GVSIG3D_MANAGER_MAPCONTEXT3D_DESCRIPTION); |
132 |
extensionPoints.add(GVSIG3D_MANAGER_MAPCONTROL3D, |
133 |
GVSIG3D_MANAGER_MAPCONTROL3D_DESCRIPTION); |
134 |
extensionPoints.add(GVSIG3D_MANAGER_GRAPHICSLAYER3D, |
135 |
GVSIG3D_MANAGER_GRAPHICSLAYER3D_DESCRIPTION); |
136 |
extensionPoints.add(GVSIG3D_MANAGER_LAYER3DPROPS, |
137 |
GVSIG3D_MANAGER_LAYER3DPROPS_DESCRIPTION); |
138 |
extensionPoints.add(GVSIG3D_MANAGER_VIEWPORT3D, |
139 |
GVSIG3D_MANAGER_VIEWPORT3D_DESCRIPTION); |
140 |
} |
141 |
|
142 |
public Service getService(DynObject parameters) throws ServiceException { |
143 |
DefaultGvsig3DProviderServices providerServices = new DefaultGvsig3DProviderServices();
|
144 |
DefaultGvsig3DService cookie = new DefaultGvsig3DService(this, |
145 |
parameters, providerServices); |
146 |
return cookie;
|
147 |
} |
148 |
|
149 |
public void registerDefaultMapContext3D(Class mapContext3DClass) { |
150 |
if (!MapContext3D.class.isAssignableFrom(mapContext3DClass)) {
|
151 |
throw new IllegalArgumentException(mapContext3DClass.getName() |
152 |
+ " must implement the MapContext3D interface");
|
153 |
} |
154 |
|
155 |
ExtensionPoint extensionPoint = extensionPoints.add( |
156 |
GVSIG3D_MANAGER_MAPCONTEXT3D, |
157 |
GVSIG3D_MANAGER_MAPCONTEXT3D_DESCRIPTION); |
158 |
extensionPoint.append(GVSIG3D_MANAGER_MAPCONTEXT3D_DEFAULT, |
159 |
"Default MapContext3D", mapContext3DClass);
|
160 |
|
161 |
} |
162 |
|
163 |
public MapContext3D createDefaultMapContext3DInstance() {
|
164 |
|
165 |
return new MapContext3DImpl(); |
166 |
} |
167 |
|
168 |
public MapContext3D createDefaultMapContext3DInstance(ViewPort vp) {
|
169 |
return new MapContext3DImpl(vp); |
170 |
} |
171 |
|
172 |
public MapContext3D createDefaultMapContext3DInstance(FLayers fl, ViewPort vp) {
|
173 |
return new MapContext3DImpl(fl, vp); |
174 |
} |
175 |
|
176 |
public MapContext3D createMapContext3DInstance(String name) |
177 |
throws Gvsig3DException {
|
178 |
ExtensionPoint ep = extensionPoints.add(GVSIG3D_MANAGER_MAPCONTEXT3D); |
179 |
try {
|
180 |
return (MapContext3D) ep.create(name);
|
181 |
} catch (Exception e) { |
182 |
throw new Gvsig3DException(e); |
183 |
} |
184 |
} |
185 |
|
186 |
public void registerDefaultMapControl3D(Class mapControl3DClass) { |
187 |
if (!MapControl3D.class.isAssignableFrom(mapControl3DClass)) {
|
188 |
throw new IllegalArgumentException(mapControl3DClass.getName() |
189 |
+ " must implement the MapControl3D interface");
|
190 |
} |
191 |
|
192 |
ExtensionPoint extensionPoint = extensionPoints.add( |
193 |
GVSIG3D_MANAGER_MAPCONTROL3D, |
194 |
GVSIG3D_MANAGER_MAPCONTROL3D_DESCRIPTION); |
195 |
extensionPoint.append(GVSIG3D_MANAGER_MAPCONTROL3D_DEFAULT, |
196 |
"Default MapControl3D", mapControl3DClass);
|
197 |
|
198 |
} |
199 |
|
200 |
public MapControl3D createDefaultMapControl3DInstance() {
|
201 |
return new MapControl3DImpl(); |
202 |
} |
203 |
|
204 |
public MapControl3D createMapControl3DInstance(String name) |
205 |
throws Gvsig3DException {
|
206 |
ExtensionPoint ep = extensionPoints.add(GVSIG3D_MANAGER_MAPCONTROL3D); |
207 |
try {
|
208 |
return (MapControl3D) ep.create(name);
|
209 |
} catch (Exception e) { |
210 |
throw new Gvsig3DException(e); |
211 |
} |
212 |
} |
213 |
|
214 |
public void registerDefaultGraphicsLayer3D(Class graphicLayer3DClass) { |
215 |
if (!GraphicLayer3D.class.isAssignableFrom(graphicLayer3DClass)) {
|
216 |
throw new IllegalArgumentException(graphicLayer3DClass.getName() |
217 |
+ " must implement the GraphicLayer3D interface");
|
218 |
} |
219 |
|
220 |
ExtensionPoint extensionPoint = extensionPoints.add( |
221 |
GVSIG3D_MANAGER_GRAPHICSLAYER3D, |
222 |
GVSIG3D_MANAGER_GRAPHICSLAYER3D_DESCRIPTION); |
223 |
extensionPoint.append(GVSIG3D_MANAGER_GRAPHICSLAYER3D_DEFAULT, |
224 |
"Default GraphicsLayer3D", graphicLayer3DClass);
|
225 |
|
226 |
} |
227 |
|
228 |
public GraphicLayer3D createDefaultGraphicsLayer3DInstance(
|
229 |
TerrainViewer terrainViewer, Terrain terrain) { |
230 |
return new GraphicLayer3DImpl(terrainViewer, terrain); |
231 |
} |
232 |
|
233 |
public GraphicLayer3D createGraphicsLayer3DInstance(String name) |
234 |
throws Gvsig3DException {
|
235 |
ExtensionPoint ep = extensionPoints |
236 |
.add(GVSIG3D_MANAGER_GRAPHICSLAYER3D); |
237 |
try {
|
238 |
return (GraphicLayer3D) ep.create(name);
|
239 |
} catch (Exception e) { |
240 |
throw new Gvsig3DException(e); |
241 |
} |
242 |
} |
243 |
|
244 |
public void registerDefaultLayer3DProps(Class layer3dPropsClass) { |
245 |
if (!Layer3DProps.class.isAssignableFrom(layer3dPropsClass)) {
|
246 |
throw new IllegalArgumentException(layer3dPropsClass.getName() |
247 |
+ " must implement the Layer3DProps interface");
|
248 |
} |
249 |
|
250 |
ExtensionPoint extensionPoint = extensionPoints.add( |
251 |
GVSIG3D_MANAGER_LAYER3DPROPS, |
252 |
GVSIG3D_MANAGER_LAYER3DPROPS_DESCRIPTION); |
253 |
extensionPoint.append(GVSIG3D_MANAGER_LAYER3DPROPS_DEFAULT, |
254 |
"Default Layer3DProps", layer3dPropsClass);
|
255 |
|
256 |
} |
257 |
|
258 |
public Layer3DProps createDefaultLayer3DPropsInstance(FLayer layer) {
|
259 |
return new Layer3DPropsImpl(layer); |
260 |
} |
261 |
|
262 |
public Layer3DProps createLayer3DPropsInstance(String name) |
263 |
throws Gvsig3DException {
|
264 |
ExtensionPoint ep = extensionPoints.add(GVSIG3D_MANAGER_LAYER3DPROPS); |
265 |
try {
|
266 |
return (Layer3DProps) ep.create(name);
|
267 |
} catch (Exception e) { |
268 |
throw new Gvsig3DException(e); |
269 |
} |
270 |
} |
271 |
|
272 |
public void registerDefaultViewPort3D(Class viewPort3DClass) { |
273 |
if (!ViewPort3D.class.isAssignableFrom(viewPort3DClass)) {
|
274 |
throw new IllegalArgumentException(viewPort3DClass.getName() |
275 |
+ " must implement the ViewPort3D interface");
|
276 |
} |
277 |
|
278 |
ExtensionPoint extensionPoint = extensionPoints.add( |
279 |
GVSIG3D_MANAGER_VIEWPORT3D, |
280 |
GVSIG3D_MANAGER_VIEWPORT3D_DESCRIPTION); |
281 |
extensionPoint.append(GVSIG3D_MANAGER_VIEWPORT3D_DEFAULT, |
282 |
"Default Viewport3D", viewPort3DClass);
|
283 |
|
284 |
} |
285 |
|
286 |
public ViewPort3D createDefaultViewPort3DInstance() {
|
287 |
return new Viewport3DImpl(); |
288 |
} |
289 |
|
290 |
public ViewPort3D createDefaultViewPort3DInstance(IProjection proj) {
|
291 |
return new Viewport3DImpl(proj); |
292 |
} |
293 |
|
294 |
|
295 |
public ViewPort3D createViewPort3DInstance(String name) |
296 |
throws Gvsig3DException {
|
297 |
ExtensionPoint ep = extensionPoints.add(GVSIG3D_MANAGER_VIEWPORT3D); |
298 |
try {
|
299 |
return (ViewPort3D) ep.create(name);
|
300 |
} catch (Exception e) { |
301 |
throw new Gvsig3DException(e); |
302 |
} |
303 |
} |
304 |
|
305 |
public FLayers3D createFLayers3DInstance(String name) throws Gvsig3DException{ |
306 |
|
307 |
ExtensionPoint ep = extensionPoints.add(GVSIG3D_MANAGER_FLAYERS3D); |
308 |
try {
|
309 |
return (FLayers3D) ep.create(name);
|
310 |
} catch (Exception e) { |
311 |
throw new Gvsig3DException(e); |
312 |
} |
313 |
|
314 |
} |
315 |
|
316 |
public FLayers3D createDefaultFLayers3DInstance(ViewPort vp) {
|
317 |
return new FLayers3DImpl(null, null, vp); |
318 |
} |
319 |
|
320 |
public NavigationMode createDefaultNavigationModeInstance(
|
321 |
TerrainCameraManipulator tcm) { |
322 |
return new NavigationModeImpl(tcm); |
323 |
} |
324 |
|
325 |
public NavigationMask createDefaultNavigationMaskInstance(int btn, int key) { |
326 |
return new NavigationMaskImpl(btn,key); |
327 |
} |
328 |
|
329 |
public Hud createDefaultHudInstance(IViewerContainer canvas3d,
|
330 |
Terrain terrain) { |
331 |
return new HudImpl(canvas3d, terrain); |
332 |
} |
333 |
|
334 |
public ISimpleMarker3DSymbol createDefaultSimpleMarker() {
|
335 |
return new SimpleMarker3DSymbol(); |
336 |
} |
337 |
public ISimpleFill3DSymbol createDefaultFillMarker() {
|
338 |
return new SimpleFill3DSymbol(); |
339 |
} |
340 |
public ISimpleLine3DSymbol createDefaultLineMarker() {
|
341 |
return new SimpleLine3DSymbol(); |
342 |
} |
343 |
|
344 |
|
345 |
|
346 |
} |