Statistics
| Revision:

gvsig-3d / 2.1 / trunk / org.gvsig.view3d / org.gvsig.view3d.vector / org.gvsig.view3d.vector.lib / org.gvsig.view3d.vector.lib.impl / src / main / java / org / gvsig / view3d / vector / lib / impl / vector / DefaultVectorLoader.java @ 774

History | View | Annotate | Download (2.61 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2017 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
package org.gvsig.view3d.vector.lib.impl.vector;
25

    
26
import org.gvsig.fmap.dal.feature.FeatureStore;
27
import org.gvsig.fmap.mapcontext.layers.FLayer;
28
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
29
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
30
import org.gvsig.view3d.lib.api.exception.LoadException;
31
import org.gvsig.view3d.lib.api.loader.Loader;
32
import org.gvsig.view3d.lib.api.loader.LoaderParameters;
33
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters;
34

    
35
/**
36
 * 
37
 * @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
38
 *
39
 */
40
public class DefaultVectorLoader implements Loader {
41

    
42
    @Override
43
    public Object load(LoaderParameters parameters) throws LoadException {
44

    
45
        if (parameters == null) {
46
            throw new IllegalArgumentException("Can not load layer, parameters can not be null");
47
        }
48

    
49
        if (!(parameters instanceof VectorLoaderParameters)) {
50
            throw new IllegalArgumentException(
51
                "Can not load layer, parameters must implements VectorLoaderParameter interface");
52
        }
53

    
54
        FLayer layer = parameters.getLayer();
55
        if (!(layer instanceof FLyrVect)) {
56
            throw new IllegalArgumentException("Can not load layer, only vector layers can be load as 'Vector'");
57
        }
58
        FLyrVect layerVect = (FLyrVect) layer;
59
        FeatureStore featureStore = layerVect.getFeatureStore();
60
        IVectorLegend vectorLegend = null;
61
        if (layerVect.getLegend() instanceof IVectorLegend) {
62
            vectorLegend = (IVectorLegend) layerVect.getLegend();
63
        }
64
        return new DefaultVectorRenderableLayer((VectorLoaderParameters) parameters, featureStore, vectorLegend);
65
    }
66
}