Revision 470 2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/impl/DefaultView3DPanel.java
DefaultView3DPanel.java | ||
---|---|---|
32 | 32 |
import javax.swing.JPanel; |
33 | 33 |
|
34 | 34 |
import org.gvsig.fmap.mapcontext.MapContext; |
35 |
import org.gvsig.tools.observer.BaseNotification; |
|
36 |
import org.gvsig.tools.observer.Notification; |
|
37 |
import org.gvsig.tools.observer.ObservableHelper; |
|
38 |
import org.gvsig.tools.observer.Observer; |
|
35 | 39 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
36 | 40 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
37 | 41 |
import org.gvsig.view3d.swing.api.MapControl3D; |
... | ... | |
44 | 48 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
45 | 49 |
* |
46 | 50 |
*/ |
47 |
public class DefaultView3DPanel extends JPanel implements View3DPanel { |
|
51 |
public class DefaultView3DPanel extends JPanel implements View3DPanel, ComponentListener {
|
|
48 | 52 |
|
49 | 53 |
private static final long serialVersionUID = -87105248886531868L; |
54 |
|
|
55 |
private ObservableHelper observableHelper; |
|
50 | 56 |
|
51 | 57 |
private MapControl3D mapControl3D; |
52 | 58 |
|
... | ... | |
60 | 66 |
View3DSwingManager swingManager = View3DSwingLocator.getManager(); |
61 | 67 |
this.mapControl3D = |
62 | 68 |
swingManager.createMapControl3D(theMapContext, type); |
69 |
this.observableHelper = new ObservableHelper(); |
|
63 | 70 |
|
64 | 71 |
this.add(mapControl3D.asJComponent(), BorderLayout.CENTER); |
65 | 72 |
|
66 |
this.addComponentListener(new ComponentListener() { |
|
67 |
|
|
68 |
public void componentShown(ComponentEvent e) { |
|
69 |
} |
|
70 |
|
|
71 |
public void componentResized(ComponentEvent e) { |
|
72 |
} |
|
73 |
|
|
74 |
public void componentMoved(ComponentEvent e) { |
|
75 |
} |
|
76 |
|
|
77 |
public void componentHidden(ComponentEvent e) { |
|
78 |
getMapControl3D().dispose(); |
|
79 |
} |
|
80 |
}); |
|
73 |
this.addComponentListener(this); |
|
81 | 74 |
} |
82 | 75 |
|
83 | 76 |
public JComponent asJComponent() { |
... | ... | |
93 | 86 |
wm.showWindow(this, "_View3D_window", |
94 | 87 |
WindowManager.MODE.WINDOW); |
95 | 88 |
} |
89 |
|
|
90 |
@Override |
|
91 |
public boolean requestFocusInWindow() { |
|
92 |
return super.requestFocusInWindow(); |
|
93 |
} |
|
96 | 94 |
|
95 |
public void addObserver(Observer o) { |
|
96 |
if(observableHelper != null){ |
|
97 |
observableHelper.addObserver(o); |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
public void deleteObserver(Observer o) { |
|
102 |
if(observableHelper != null){ |
|
103 |
observableHelper.deleteObserver(o); |
|
104 |
} |
|
105 |
|
|
106 |
} |
|
107 |
|
|
108 |
public void deleteObservers() { |
|
109 |
if(observableHelper != null){ |
|
110 |
observableHelper.deleteObservers(); |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
public void componentResized(ComponentEvent e) { |
|
115 |
} |
|
116 |
|
|
117 |
public void componentMoved(ComponentEvent e) { |
|
118 |
} |
|
119 |
|
|
120 |
public void componentShown(ComponentEvent e) { |
|
121 |
} |
|
122 |
|
|
123 |
public void componentHidden(ComponentEvent e) { |
|
124 |
|
|
125 |
Notification beforeDisposeNotification = |
|
126 |
new BaseNotification(View3DPanel.BEFORE_DISPOSE_PANEL_NOTIFICATION, |
|
127 |
null); |
|
128 |
|
|
129 |
observableHelper.notifyObservers(this,beforeDisposeNotification); |
|
130 |
|
|
131 |
getMapControl3D().dispose(); |
|
132 |
|
|
133 |
Notification afterDisposeNotification = |
|
134 |
new BaseNotification(View3DPanel.AFTER_DISPOSE_PANEL_NOTIFICATION, |
|
135 |
null); |
|
136 |
|
|
137 |
observableHelper.notifyObservers(this,afterDisposeNotification); |
|
138 |
|
|
139 |
} |
|
140 |
|
|
97 | 141 |
} |
Also available in: Unified diff