Statistics
| Revision:

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 @ 459

History | View | Annotate | Download (3.01 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.swing.api.ToolsSwingLocator;
36
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
37
import org.gvsig.view3d.swing.api.MapControl3D;
38
import org.gvsig.view3d.swing.api.View3DPanel;
39
import org.gvsig.view3d.swing.api.View3DSwingLocator;
40
import org.gvsig.view3d.swing.api.View3DSwingManager;
41
import org.gvsig.view3d.swing.api.View3DSwingManager.TYPE;
42

    
43
/**
44
 * @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
45
 *
46
 */
47
public class DefaultView3DPanel extends JPanel implements View3DPanel {
48

    
49
    private static final long serialVersionUID = -87105248886531868L;
50

    
51
    private MapControl3D mapControl3D;
52

    
53
    /**
54
     * @param theMapContext
55
     * @param type
56
     */
57
    public DefaultView3DPanel(MapContext theMapContext, TYPE type) {
58
        super(new BorderLayout());
59
                
60
        View3DSwingManager swingManager = View3DSwingLocator.getManager();
61
        this.mapControl3D =
62
            swingManager.createMapControl3D(theMapContext, type);
63

    
64
        this.add(mapControl3D.asJComponent(), BorderLayout.CENTER);
65
        
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
        });
81
    }
82

    
83
    public JComponent asJComponent() {
84
        return this;
85
    }
86

    
87
    public MapControl3D getMapControl3D() {
88
        return this.mapControl3D;
89
    }
90

    
91
    public void show() {
92
        WindowManager wm = ToolsSwingLocator.getWindowManager();
93
        wm.showWindow(this, "_View3D_window",
94
            WindowManager.MODE.WINDOW);
95
    }
96

    
97
}