Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.wcs / org.gvsig.wcs.provider.legend / src / main / java / org / gvsig / wcs / provider / legend / WCSRasterGetLegend.java @ 6905

History | View | Annotate | Download (3.17 KB)

1
package org.gvsig.wcs.provider.legend;
2
/* gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2016 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

    
26

    
27
import org.slf4j.LoggerFactory;
28

    
29
import org.gvsig.fmap.dal.raster.api.RasterStore;
30
import org.gvsig.raster.lib.legend.api.RasterLegend;
31
import org.gvsig.raster.lib.legend.api.RasterLegendLocator;
32
import org.gvsig.raster.lib.legend.api.RasterLegendManager;
33
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation;
34
import org.gvsig.raster.lib.legend.api.colortable.ColorTable;
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
import org.gvsig.wcs.provider.WCSRasterProvider;
42

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

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

    
52
    private static Integer code = null;
53

    
54

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

    
62
    }
63

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

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

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

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

    
83
        WCSRasterProvider provider = (WCSRasterProvider) self;
84
        RasterLegendManager legendManager=RasterLegendLocator.getRasterLegendManager();
85

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

    
89
        legend= legendManager.createLegend(colorInterpretation);
90

    
91
        return legend;
92
    }
93

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