Revision 306 2.0/trunk/org.gvsig.gvsig3d/org.gvsig.gvsig3d.lib/org.gvsig.gvsig3d.lib.impl/src/main/java/org/gvsig/gvsig3d/impl/layers/FLayers3DImpl.java
FLayers3DImpl.java | ||
---|---|---|
4 | 4 |
import org.gvsig.fmap.mapcontext.ViewPort; |
5 | 5 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
6 | 6 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
7 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
|
7 | 8 |
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent; |
8 | 9 |
import org.gvsig.fmap.mapcontext.layers.LayerPositionEvent; |
9 | 10 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
10 | 11 |
import org.gvsig.gvsig3d.Gvsig3DException; |
11 | 12 |
import org.gvsig.gvsig3d.Gvsig3DLocator; |
12 | 13 |
import org.gvsig.gvsig3d.Gvsig3DManager; |
14 |
import org.gvsig.gvsig3d.impl.map3d.Layer3DPropsImpl; |
|
13 | 15 |
import org.gvsig.gvsig3d.map3d.Layer3DProps; |
14 | 16 |
import org.gvsig.gvsig3d.map3d.MapContext3D; |
15 | 17 |
import org.gvsig.gvsig3d.map3d.layers.FLayers3D; |
18 |
import org.gvsig.tools.ToolsLocator; |
|
19 |
import org.gvsig.tools.dynobject.DynStruct; |
|
20 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
21 |
import org.gvsig.tools.persistence.Persistent; |
|
22 |
import org.gvsig.tools.persistence.PersistentState; |
|
23 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
24 |
import org.gvsig.tools.util.Callable; |
|
16 | 25 |
|
17 |
public class FLayers3DImpl extends FLayers3D{ |
|
18 |
|
|
26 |
public class FLayers3DImpl extends FLayers3D { |
|
27 |
|
|
28 |
public static final String PARAMETERS_DEFINITION_NAME = "FLayers3DImpl"; |
|
29 |
|
|
30 |
public FLayers3DImpl() { |
|
31 |
|
|
32 |
super(); |
|
33 |
|
|
34 |
} |
|
35 |
|
|
19 | 36 |
/** |
20 | 37 |
* Constructor that can be used to create a MapContext containing the |
21 | 38 |
* FLayers3D |
... | ... | |
27 | 44 |
*/ |
28 | 45 |
public FLayers3DImpl(MapContext fmap, FLayers parent, ViewPort vp) { |
29 | 46 |
|
30 |
//super();
|
|
47 |
super(); |
|
31 | 48 |
this.setMapContext(fmap); |
32 | 49 |
this.setParentLayer(parent); |
33 |
|
|
50 |
|
|
34 | 51 |
Gvsig3DManager manager = Gvsig3DLocator.getManager(); |
35 | 52 |
// add 3D properties, mainly to keep track of hooked state |
36 | 53 |
Layer3DProps props3D; |
... | ... | |
38 | 55 |
props3D = manager.createDefaultLayer3DPropsInstance(this); |
39 | 56 |
props3D.setLayer(this); |
40 | 57 |
setProperty("3DLayerExtension", props3D); |
41 |
|
|
58 |
|
|
42 | 59 |
if (fmap == null) { |
43 |
MapContext newMap = manager.createDefaultMapContext3DInstance(this, vp); |
|
60 |
MapContext newMap = manager.createDefaultMapContext3DInstance( |
|
61 |
this, vp); |
|
44 | 62 |
this.fmap = newMap; |
45 | 63 |
props3D.setHooked(true); |
46 | 64 |
} else { |
... | ... | |
50 | 68 |
// TODO Auto-generated catch block |
51 | 69 |
e.printStackTrace(); |
52 | 70 |
} |
53 |
|
|
71 |
|
|
54 | 72 |
} |
55 | 73 |
|
56 | 74 |
// overrides for layer collection events |
57 |
|
|
75 |
|
|
58 | 76 |
@Override |
59 | 77 |
public void addLayer(FLayer layer) { |
60 |
|
|
78 |
|
|
61 | 79 |
System.out.println("ADD LAYER!!!!!"); |
62 |
// if(layer instanceof FLyrVect){ |
|
63 |
// FLyrVect vectLayer = (FLyrVect) layer; |
|
64 |
// try { |
|
65 |
// if ((layer instanceof FLyrVect) && (vectLayer.getgetRecordset().getDriver() instanceof GvsigDriverOSG)) { |
|
66 |
// // This is a little hack, so you need to set a parent to avoid a exception |
|
67 |
// super.addLayer(new FLyrOSG(vectLayer)); |
|
68 |
// vectLayer.setProjection(null); |
|
69 |
// return; |
|
70 |
// } |
|
71 |
// } catch (ReadDriverException e) { |
|
72 |
// // TODO Auto-generated catch block |
|
73 |
// e.printStackTrace(); |
|
74 |
// } |
|
75 |
// } |
|
80 |
// if(layer instanceof FLyrVect){ |
|
81 |
// FLyrVect vectLayer = (FLyrVect) layer; |
|
82 |
// try { |
|
83 |
// if ((layer instanceof FLyrVect) && |
|
84 |
// (vectLayer.getgetRecordset().getDriver() instanceof GvsigDriverOSG)) |
|
85 |
// { |
|
86 |
// // This is a little hack, so you need to set a parent to avoid a |
|
87 |
// exception |
|
88 |
// super.addLayer(new FLyrOSG(vectLayer)); |
|
89 |
// vectLayer.setProjection(null); |
|
90 |
// return; |
|
91 |
// } |
|
92 |
// } catch (ReadDriverException e) { |
|
93 |
// // TODO Auto-generated catch block |
|
94 |
// e.printStackTrace(); |
|
95 |
// } |
|
96 |
// } |
|
76 | 97 |
super.addLayer(layer); |
77 | 98 |
} |
78 | 99 |
|
79 | 100 |
protected void callLayerAdded(LayerCollectionEvent event) { |
80 | 101 |
if (isHooked()) { |
81 |
FLayer layer = event.getAffectedLayer();
|
|
82 |
((MapContext3D)fmap).layerAdded(this, layer);
|
|
102 |
FLayer layer = event.getAffectedLayer();
|
|
103 |
((MapContext3D) fmap).layerAdded(this, layer);
|
|
83 | 104 |
} |
84 | 105 |
super.callLayerAdded(event); |
85 | 106 |
} |
... | ... | |
87 | 108 |
protected void callLayerRemoved(LayerCollectionEvent event) { |
88 | 109 |
if (isHooked()) { |
89 | 110 |
FLayer layer = event.getAffectedLayer(); |
90 |
((MapContext3D)fmap).layerRemoved(this, layer); |
|
111 |
((MapContext3D) fmap).layerRemoved(this, layer);
|
|
91 | 112 |
} |
92 | 113 |
super.callLayerRemoved(event); |
93 | 114 |
} |
94 | 115 |
|
95 | 116 |
protected void callLayerMoved(LayerPositionEvent event) { |
96 | 117 |
super.callLayerMoved(event); |
97 |
if (isHooked())
|
|
98 |
((MapContext3D)fmap).layerMoved(this, event.getAffectedLayer(),
|
|
99 |
event.getOldPos(), event.getNewPos());
|
|
118 |
if (isHooked()) |
|
119 |
((MapContext3D) fmap).layerMoved(this, event.getAffectedLayer(),
|
|
120 |
event.getOldPos(), event.getNewPos());
|
|
100 | 121 |
} |
101 | 122 |
|
102 | 123 |
public boolean isHooked() { |
103 |
// Layer3DProps props3D = Layer3DProps.getLayer3DProps(this); |
|
104 |
// if (((MapContext3D)fmap).getLayers()==this) // this is the root FLayers3D |
|
105 |
// props3D.setHooked(true); |
|
106 |
// |
|
107 |
// return props3D.getHooked(); |
|
124 |
// Layer3DProps props3D = Layer3DProps.getLayer3DProps(this); |
|
125 |
// if (((MapContext3D)fmap).getLayers()==this) // this is the root |
|
126 |
// FLayers3D |
|
127 |
// props3D.setHooked(true); |
|
128 |
// |
|
129 |
// return props3D.getHooked(); |
|
108 | 130 |
return true; |
109 | 131 |
} |
110 |
|
|
111 |
|
|
112 | 132 |
|
113 |
|
|
133 |
public static class RegisterPersistence implements Callable { |
|
114 | 134 |
|
135 |
public Object call() throws Exception { |
|
136 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
137 |
if (manager.getDefinition(FLayers.class) == null) { |
|
138 |
FLayers.registerPersistent(); |
|
139 |
} |
|
140 |
DynStruct definition = manager.addDefinition(FLayers3DImpl.class, |
|
141 |
"FLayers3DImpl", "FLayers3DImpl Persistence definition", |
|
142 |
null, null); |
|
143 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, |
|
144 |
"FLayers"); |
|
145 |
|
|
146 |
return Boolean.TRUE; |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
115 | 150 |
} |
Also available in: Unified diff