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 / DefaultView3DSwingManager.java @ 488

History | View | Annotate | Download (4.13 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.util.ArrayList;
28
import java.util.List;
29

    
30
import org.gvsig.fmap.mapcontext.MapContext;
31
import org.gvsig.fmap.mapcontext.layers.ExtendedPropertiesSupport;
32
import org.gvsig.fmap.mapcontext.layers.FLayer;
33
import org.gvsig.view3d.swing.api.LayerProperties3DPanel;
34
import org.gvsig.view3d.swing.api.MapControl3D;
35
import org.gvsig.view3d.swing.api.View3DPanel;
36
import org.gvsig.view3d.swing.api.View3DSwingManager;
37
import org.gvsig.view3d.swing.impl.properties.layer.DefaultLayerProperties3DPanel;
38
import org.slf4j.Logger;
39
import org.slf4j.LoggerFactory;
40

    
41
/**
42
 * Default implementation of {@link View3DSwingManager}.
43
 * 
44
 * @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
45
 */
46
public class DefaultView3DSwingManager implements View3DSwingManager{//, Observer {
47

    
48
    private static final Logger LOG =
49
        LoggerFactory.getLogger(DefaultView3DSwingManager.class);
50

    
51
    public MapControl3D createMapControl3D(MapContext theMapContext, TYPE type,
52
        ExtendedPropertiesSupport viewProperties) {
53
        
54
        if(theMapContext == null || type == null){
55
            LOG.error("Can't create MapControl3D because MapContext or TYPE are null");
56
            throw new IllegalArgumentException();
57
        }
58
        
59
        MapControl3D mapControl3D =
60
            new DefaultMapControl3D(theMapContext, type, viewProperties);
61
        
62
        if(type == TYPE.SPHERE){
63
            viewProperties.setProperty("spehereMapControl3D", mapControl3D);
64
        } else if(type == TYPE.FLAT){
65
            viewProperties.setProperty("flatMapControl3D", mapControl3D);
66
        }
67

    
68
        return mapControl3D;
69
    }
70

    
71
    public View3DPanel createView3DPanel(MapContext theMapContext, TYPE type,
72
        ExtendedPropertiesSupport viewProperties) {
73
        
74
        if(theMapContext == null || type == null){
75
            LOG.error("Can't create View3DPanel because MapContext or TYPE are null");
76
            throw new IllegalArgumentException();
77
        }
78
        
79
        return new DefaultView3DPanel(theMapContext, type, viewProperties);
80
    }
81

    
82
    public LayerProperties3DPanel createLayerProperties3DPanel(FLayer layer) {
83
        return new DefaultLayerProperties3DPanel(layer);
84
    }
85

    
86
    public List<MapControl3D> getMapControl3D(
87
        ExtendedPropertiesSupport viewProperties) {
88

    
89
        List<MapControl3D> mapControls3D = new ArrayList<MapControl3D>();
90

    
91
        MapControl3D sphereMapControl3D =
92
            (MapControl3D) viewProperties.getProperty("spehereMapControl3D");
93
        MapControl3D flatMapControl3D =
94
            (MapControl3D) viewProperties.getProperty("flatMapControl3D");
95

    
96
        if (sphereMapControl3D != null) {
97
            mapControls3D.add(sphereMapControl3D);
98
        }
99

    
100
        if (flatMapControl3D != null) {
101
            mapControls3D.add(flatMapControl3D);
102
        }
103

    
104
        return mapControls3D;
105
    }
106
    
107
    public MapControl3D getMapControl3D(ExtendedPropertiesSupport viewProperties, TYPE type) {
108
        
109
        if(type == TYPE.SPHERE){
110
            return (MapControl3D) viewProperties.getProperty("spehereMapControl3D");
111
        } else if (type == TYPE.FLAT){
112
            return (MapControl3D) viewProperties.getProperty("flatMapControl3D");
113
        }
114
        return null;
115
    }
116
}