gvsig-3d / 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 @ 474
History | View | Annotate | Download (3.88 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright ? 2007-2015 gvSIG Association
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
|
25 |
package org.gvsig.view3d.swing.impl; |
26 |
|
27 |
import java.awt.BorderLayout; |
28 |
import java.awt.event.ComponentEvent; |
29 |
import java.awt.event.ComponentListener; |
30 |
|
31 |
import javax.swing.JComponent; |
32 |
import javax.swing.JPanel; |
33 |
|
34 |
import org.gvsig.fmap.mapcontext.MapContext; |
35 |
import org.gvsig.tools.observer.ObservableHelper; |
36 |
import org.gvsig.tools.observer.Observer; |
37 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
38 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
39 |
import org.gvsig.view3d.swing.api.MapControl3D; |
40 |
import org.gvsig.view3d.swing.api.View3DPanel; |
41 |
import org.gvsig.view3d.swing.api.View3DSwingLocator; |
42 |
import org.gvsig.view3d.swing.api.View3DSwingManager; |
43 |
import org.gvsig.view3d.swing.api.View3DSwingManager.TYPE; |
44 |
|
45 |
/**
|
46 |
* Default implementaion of {@link View3DPanel}.
|
47 |
*
|
48 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
|
49 |
*/
|
50 |
public class DefaultView3DPanel extends JPanel implements View3DPanel { |
51 |
|
52 |
private static final long serialVersionUID = -87105248886531868L; |
53 |
|
54 |
private ObservableHelper observableHelper;
|
55 |
|
56 |
private MapControl3D mapControl3D;
|
57 |
|
58 |
/**
|
59 |
* Default constructor of {@link DefaultView3DPanel}. Creates an
|
60 |
* {@link MapControl3D}, initialize local fileds and register listeners.
|
61 |
*
|
62 |
* @param theMapContext
|
63 |
* associated <code>MapContext</code>
|
64 |
* @param type
|
65 |
* Type of this {@link DefaultMapControl3D}. See {@link TYPE}.
|
66 |
*/
|
67 |
public DefaultView3DPanel(MapContext theMapContext, TYPE type) {
|
68 |
super(new BorderLayout()); |
69 |
|
70 |
View3DSwingManager swingManager = View3DSwingLocator.getManager(); |
71 |
this.mapControl3D =
|
72 |
swingManager.createMapControl3D(theMapContext, type); |
73 |
this.observableHelper = new ObservableHelper(); |
74 |
|
75 |
this.add(mapControl3D.asJComponent(), BorderLayout.CENTER); |
76 |
|
77 |
this.addComponentListener(new ComponentListener() { |
78 |
|
79 |
public void componentShown(ComponentEvent e) { |
80 |
} |
81 |
|
82 |
public void componentResized(ComponentEvent e) { |
83 |
} |
84 |
|
85 |
public void componentMoved(ComponentEvent e) { |
86 |
} |
87 |
|
88 |
public void componentHidden(ComponentEvent e) { |
89 |
getMapControl3D().dispose(); |
90 |
} |
91 |
}); |
92 |
} |
93 |
|
94 |
public JComponent asJComponent() { |
95 |
return this; |
96 |
} |
97 |
|
98 |
public MapControl3D getMapControl3D() {
|
99 |
return this.mapControl3D; |
100 |
} |
101 |
|
102 |
public void show() { |
103 |
WindowManager wm = ToolsSwingLocator.getWindowManager(); |
104 |
wm.showWindow(this, "_View3D_window", WindowManager.MODE.WINDOW); |
105 |
} |
106 |
|
107 |
public void addObserver(Observer o) { |
108 |
if (observableHelper != null) { |
109 |
observableHelper.addObserver(o); |
110 |
} |
111 |
} |
112 |
|
113 |
public void deleteObserver(Observer o) { |
114 |
if (observableHelper != null) { |
115 |
observableHelper.deleteObserver(o); |
116 |
} |
117 |
|
118 |
} |
119 |
|
120 |
public void deleteObservers() { |
121 |
if (observableHelper != null) { |
122 |
observableHelper.deleteObservers(); |
123 |
} |
124 |
} |
125 |
} |