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

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

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

    
56
    private static final Logger LOG =
57
        LoggerFactory.getLogger(DefaultView3DSwingManager.class);
58
    
59
    private GeneralProperties3D generalProperties;
60

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

    
78
        return mapControl3D;
79
    }
80

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

    
92
    public LayerProperties3DPanel createLayerProperties3DPanel(FLayer layer) {
93
        return new DefaultLayerProperties3DPanel(layer);
94
    }
95

    
96
    public List<MapControl3D> getMapControl3D(
97
        ExtendedPropertiesSupport viewProperties) {
98

    
99
        List<MapControl3D> mapControls3D = new ArrayList<MapControl3D>();
100

    
101
        MapControl3D sphereMapControl3D =
102
            (MapControl3D) viewProperties.getProperty("sphereMapControl3D");
103
        MapControl3D flatMapControl3D =
104
            (MapControl3D) viewProperties.getProperty("flatMapControl3D");
105

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

    
110
        if (flatMapControl3D != null) {
111
            mapControls3D.add(flatMapControl3D);
112
        }
113

    
114
        return mapControls3D;
115
    }
116
    
117
    public MapControl3D getMapControl3D(ExtendedPropertiesSupport viewProperties, TYPE type) {
118
        
119
        if(type == TYPE.SPHERE){
120
            return (MapControl3D) viewProperties.getProperty("sphereMapControl3D");
121
        } else if (type == TYPE.FLAT){
122
            return (MapControl3D) viewProperties.getProperty("flatMapControl3D");
123
        }
124
        return null;
125
    }
126

    
127
    public ViewProperties3DPanel createViewProperties3DPanel(
128
        MapControlProperties3D properties) {
129
        return new DefaultViewProperties3DPanel(properties);
130
    }
131

    
132
    public GeneralProperties3DPanel createGeneralProperties3DPanel(
133
        GeneralProperties3D properties) {
134
        return new DefaultGeneralProperties3DPanel(properties);
135
    }
136
    
137
    public MapControlProperties3D getMapControl3DProperties(
138
        ExtendedPropertiesSupport viewProperties) {
139
        
140
        MapControlProperties3D properties =
141
            (MapControlProperties3D) viewProperties
142
                .getProperty("mapControl3DProperties");
143
        
144
        if(properties == null){
145
            properties = new DefaultMapControlProperties3D();
146
            setMapControlProperties3D(viewProperties, properties);
147
        }
148
        
149
        return properties;
150
    }
151

    
152
    public void setMapControlProperties3D(
153
        ExtendedPropertiesSupport viewProperties,
154
        MapControlProperties3D mapControl3DProperties) {
155
        
156
        viewProperties.setProperty("mapControl3DProperties",
157
            mapControl3DProperties);
158
    }
159

    
160
    public GeneralProperties3D getGeneral3DProperties() {
161
        if(generalProperties == null){
162
            generalProperties = new DefaultGeneralProperties3D();
163
        }
164
        return generalProperties;
165
    }
166

    
167
    public void setGeneral3DProperties(GeneralProperties3D properties) {
168
        if(properties != null){
169
            this.generalProperties = properties;
170
        }
171
        
172
    }
173

    
174
}