Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.raster.bingmaps / org.gvsig.raster.bingmaps.provider.legend / src / main / java / org / gvsig / raster / bingmaps / provider / legend / BingMapsRasterGetLegend.java @ 8780

History | View | Annotate | Download (3.17 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23

    
24
package org.gvsig.raster.bingmaps.provider.legend;
25

    
26

    
27
import org.slf4j.LoggerFactory;
28

    
29
import org.gvsig.fmap.dal.raster.api.RasterStore;
30
import org.gvsig.raster.bingmaps.provider.BingMapsRasterProvider;
31
import org.gvsig.raster.lib.legend.api.RasterLegend;
32
import org.gvsig.raster.lib.legend.api.RasterLegendLocator;
33
import org.gvsig.raster.lib.legend.api.RasterLegendManager;
34
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation;
35
import org.gvsig.tools.ToolsLocator;
36
import org.gvsig.tools.dynobject.DynClass;
37
import org.gvsig.tools.dynobject.DynMethod;
38
import org.gvsig.tools.dynobject.DynObject;
39
import org.gvsig.tools.dynobject.exception.DynMethodException;
40
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException;
41

    
42
/**
43
 * Dynamic method to add a get Legend funcionality
44
 * @author dmartinezizquierdo
45
 *
46
 */
47
public class BingMapsRasterGetLegend implements DynMethod {
48

    
49
    final static private org.slf4j.Logger logger = LoggerFactory.getLogger(BingMapsRasterGetLegend.class);
50

    
51
    private static Integer code = null;
52

    
53

    
54
    static void register(DynClass storeClass) {
55
        if (code != null) {
56
            return;
57
        }
58
        code = ToolsLocator.getDynObjectManager()
59
                .registerDynMethod(storeClass, new BingMapsRasterGetLegend());
60

    
61
    }
62

    
63
    @Override
64
    public int getCode() throws DynMethodNotSupportedException {
65
        return code;
66
    }
67

    
68
    @Override
69
    public String getDescription() {
70
        return "Tile Cache Legend";
71
    }
72

    
73
    @Override
74
    public String getName() {
75
        return RasterStore.DYNMETHOD_GETLEGEND_NAME;
76
    }
77

    
78
    @Override
79
    public Object invoke(DynObject self, Object[] args) throws DynMethodException {
80
        RasterLegend legend = null;
81

    
82
        BingMapsRasterProvider provider = (BingMapsRasterProvider) self;
83
        RasterLegendManager legendManager=RasterLegendLocator.getRasterLegendManager();
84

    
85
        ColorInterpretation colorInterpretation =(ColorInterpretation)provider.
86
            invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME, null);
87

    
88
        legend= legendManager.createLegend(colorInterpretation);
89

    
90
        return legend;
91
    }
92

    
93
    @Override
94
    public Object clone() throws CloneNotSupportedException {
95
        return super.clone();
96
    }
97
}