Revision 474 2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/impl/DefaultMapControl3D.java
DefaultMapControl3D.java | ||
---|---|---|
74 | 74 |
import org.slf4j.LoggerFactory; |
75 | 75 |
|
76 | 76 |
/** |
77 |
* Default implementation of {@link MapControl3D}. |
|
78 |
* |
|
77 | 79 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
78 |
* |
|
79 | 80 |
*/ |
80 | 81 |
@SuppressWarnings("deprecation") |
81 | 82 |
public class DefaultMapControl3D extends JPanel implements MapControl3D { |
... | ... | |
84 | 85 |
|
85 | 86 |
private static final Logger LOG = LoggerFactory |
86 | 87 |
.getLogger(DefaultMapControl3D.class); |
87 |
|
|
88 |
|
|
88 | 89 |
private ObservableHelper observableHelper; |
89 | 90 |
|
90 | 91 |
/** |
... | ... | |
106 | 107 |
private StatusBar statusBar; |
107 | 108 |
|
108 | 109 |
private TYPE type; |
109 |
|
|
110 |
|
|
110 | 111 |
private Cancellable cancellable; |
111 | 112 |
|
113 |
/** |
|
114 |
* Default constructor of {@link DefaultMapControl3D}. Initializes local |
|
115 |
* fileds, sets configuration depends on {@link TYPE} and adds |
|
116 |
* <code>MapContext</code> layers. |
|
117 |
* |
|
118 |
* @param theMapContext |
|
119 |
* associated <code>MapContext</code> |
|
120 |
* @param type |
|
121 |
* Type of this {@link DefaultMapControl3D}. See {@link TYPE}. |
|
122 |
*/ |
|
112 | 123 |
public DefaultMapControl3D(MapContext theMapContext, TYPE type) { |
113 | 124 |
|
114 | 125 |
super(new BorderLayout()); |
... | ... | |
201 | 212 |
} |
202 | 213 |
|
203 | 214 |
public void dispose() { |
204 |
|
|
215 |
|
|
205 | 216 |
Thread disposeThread = new Thread(new Runnable() { |
206 |
|
|
217 |
|
|
207 | 218 |
public void run() { |
208 | 219 |
Notification beforeDisposeNotification = |
209 | 220 |
new BaseNotification( |
210 |
MapControl3D.BEFORE_DISPOSE_MAPCONTEX3D_NOTIFICATION, null); |
|
221 |
MapControl3D.BEFORE_DISPOSE_MAPCONTEX3D_NOTIFICATION, |
|
222 |
null); |
|
211 | 223 |
|
212 | 224 |
observableHelper.notifyObservers(DefaultMapControl3D.this, |
213 | 225 |
beforeDisposeNotification); |
214 | 226 |
|
215 |
while(WorldWind.getRetrievalService().hasActiveTasks()){
|
|
227 |
while (WorldWind.getRetrievalService().hasActiveTasks()) {
|
|
216 | 228 |
try { |
217 | 229 |
Thread.sleep(100); |
218 | 230 |
} catch (InterruptedException e) { |
... | ... | |
225 | 237 |
|
226 | 238 |
Notification afterDisposeNotification = |
227 | 239 |
new BaseNotification( |
228 |
MapControl3D.AFTER_DISPOSE_MAPCONTEX3D_NOTIFICATION, null); |
|
240 |
MapControl3D.AFTER_DISPOSE_MAPCONTEX3D_NOTIFICATION, |
|
241 |
null); |
|
229 | 242 |
|
230 |
observableHelper |
|
231 |
.notifyObservers(DefaultMapControl3D.this, afterDisposeNotification);
|
|
243 |
observableHelper.notifyObservers(DefaultMapControl3D.this,
|
|
244 |
afterDisposeNotification); |
|
232 | 245 |
} |
233 | 246 |
}, "Dispose World Wind thread"); |
234 |
|
|
247 |
|
|
235 | 248 |
disposeThread.start(); |
236 | 249 |
} |
237 |
|
|
238 |
public Cancellable getCancellable(){ |
|
239 |
if(this.cancellable == null){
|
|
250 |
|
|
251 |
public Cancellable getCancellable() {
|
|
252 |
if (this.cancellable == null) {
|
|
240 | 253 |
this.cancellable = new Cancellable() { |
241 |
|
|
254 |
|
|
242 | 255 |
private boolean cancel = false; |
243 |
|
|
256 |
|
|
244 | 257 |
public void setCanceled(boolean canceled) { |
245 | 258 |
this.cancel = canceled; |
246 | 259 |
} |
247 |
|
|
260 |
|
|
248 | 261 |
public boolean isCanceled() { |
249 | 262 |
return cancel; |
250 | 263 |
} |
251 | 264 |
}; |
252 | 265 |
} |
253 |
|
|
266 |
|
|
254 | 267 |
return this.cancellable; |
255 | 268 |
} |
256 | 269 |
|
... | ... | |
281 | 294 |
} |
282 | 295 |
return this.wwd; |
283 | 296 |
} |
284 |
|
|
285 |
private void disposeWwd(){ |
|
297 |
|
|
298 |
private void disposeWwd() {
|
|
286 | 299 |
if (getWwd() != null) { |
287 | 300 |
this.wwd = null; |
288 | 301 |
} |
... | ... | |
436 | 449 |
// TODO |
437 | 450 |
throw new UnsupportedOperationException(); |
438 | 451 |
} |
439 |
|
|
452 |
|
|
440 | 453 |
public void addObserver(Observer o) { |
441 |
if(observableHelper != null){
|
|
454 |
if (observableHelper != null) {
|
|
442 | 455 |
observableHelper.addObserver(o); |
443 | 456 |
} |
444 | 457 |
} |
445 | 458 |
|
446 | 459 |
public void deleteObserver(Observer o) { |
447 |
if(observableHelper != null){
|
|
460 |
if (observableHelper != null) {
|
|
448 | 461 |
observableHelper.deleteObserver(o); |
449 | 462 |
} |
450 |
|
|
463 |
|
|
451 | 464 |
} |
452 | 465 |
|
453 | 466 |
public void deleteObservers() { |
454 |
if(observableHelper != null){
|
|
467 |
if (observableHelper != null) {
|
|
455 | 468 |
observableHelper.deleteObservers(); |
456 | 469 |
} |
457 | 470 |
} |
Also available in: Unified diff