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

History | View | Annotate | Download (4.9 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.lib.api.properties.GeneralProperties3D;
34
import org.gvsig.view3d.lib.api.properties.MapControlProperties3D;
35
import org.gvsig.view3d.swing.api.MapControl3D;
36
import org.gvsig.view3d.swing.api.View3DPanel;
37
import org.gvsig.view3d.swing.api.View3DSwingManager;
38
import org.gvsig.view3d.swing.api.properties.GeneralProperties3DPanel;
39
import org.gvsig.view3d.swing.api.properties.LayerProperties3DPanel;
40
import org.gvsig.view3d.swing.api.properties.ViewProperties3DPanel;
41
import org.gvsig.view3d.swing.impl.properties.DefaultGeneralProperties3DPanel;
42
import org.gvsig.view3d.swing.impl.properties.DefaultLayerProperties3DPanel;
43
import org.gvsig.view3d.swing.impl.properties.DefaultViewProperties3DPanel;
44
import org.slf4j.Logger;
45
import org.slf4j.LoggerFactory;
46

    
47
/**
48
 * Default implementation of {@link View3DSwingManager}.
49
 * 
50
 * @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
51
 */
52
public class DefaultView3DSwingManager implements View3DSwingManager{
53

    
54
    private static final Logger LOG =
55
        LoggerFactory.getLogger(DefaultView3DSwingManager.class);
56

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

    
74
        return mapControl3D;
75
    }
76

    
77
    public View3DPanel createView3DPanel(MapContext theMapContext,String title, TYPE type,
78
        ExtendedPropertiesSupport viewProperties) {
79
        
80
        if(theMapContext == null || type == null){
81
            LOG.error("Can't create View3DPanel because MapContext or TYPE are null");
82
            throw new IllegalArgumentException();
83
        }
84
        
85
        return new DefaultView3DPanel(theMapContext,title, type, viewProperties);
86
    }
87

    
88
    public LayerProperties3DPanel createLayerProperties3DPanel(FLayer layer) {
89
        return new DefaultLayerProperties3DPanel(layer);
90
    }
91

    
92
    public List<MapControl3D> getMapControl3D(
93
        ExtendedPropertiesSupport viewProperties) {
94

    
95
        List<MapControl3D> mapControls3D = new ArrayList<MapControl3D>();
96

    
97
        MapControl3D sphereMapControl3D =
98
            (MapControl3D) viewProperties.getProperty("spehereMapControl3D");
99
        MapControl3D flatMapControl3D =
100
            (MapControl3D) viewProperties.getProperty("flatMapControl3D");
101

    
102
        if (sphereMapControl3D != null) {
103
            mapControls3D.add(sphereMapControl3D);
104
        }
105

    
106
        if (flatMapControl3D != null) {
107
            mapControls3D.add(flatMapControl3D);
108
        }
109

    
110
        return mapControls3D;
111
    }
112
    
113
    public MapControl3D getMapControl3D(ExtendedPropertiesSupport viewProperties, TYPE type) {
114
        
115
        if(type == TYPE.SPHERE){
116
            return (MapControl3D) viewProperties.getProperty("spehereMapControl3D");
117
        } else if (type == TYPE.FLAT){
118
            return (MapControl3D) viewProperties.getProperty("flatMapControl3D");
119
        }
120
        return null;
121
    }
122

    
123
    public ViewProperties3DPanel createViewProperties3DPanel(
124
        MapControlProperties3D properties) {
125
        return new DefaultViewProperties3DPanel(properties);
126
    }
127

    
128
    public GeneralProperties3DPanel createGeneralProperties3DPanel(
129
        GeneralProperties3D properties) {
130
        return new DefaultGeneralProperties3DPanel(properties);
131
    }
132

    
133
}