Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.wms / org.gvsig.wms.provider.legend / src / main / java / org / gvsig / wms / provider / legend / WMSRasterGetColorInterpretation.java @ 8690

History | View | Annotate | Download (4.42 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.wms.provider.legend;
25

    
26
import org.slf4j.LoggerFactory;
27

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

    
41
/**
42
 * @author dmartinezizquierdo
43
 *
44
 */
45
public class WMSRasterGetColorInterpretation implements DynMethod {
46

    
47
    final static private org.slf4j.Logger logger = LoggerFactory.getLogger(WMSRasterGetColorInterpretation.class);
48

    
49
    private static Integer code = null;
50

    
51
    static void register(DynClass storeClass) {
52
        if (code != null) {
53
            return;
54
        }
55
        code = ToolsLocator.getDynObjectManager()
56
                .registerDynMethod(storeClass, new WMSRasterGetColorInterpretation());
57

    
58
    }
59

    
60
    @Override
61
    public int getCode() throws DynMethodNotSupportedException {
62
        return code;
63
    }
64

    
65
    @Override
66
    public String getDescription() {
67
        return "GoogleMaps Color Interpretation";
68
    }
69

    
70
    @Override
71
    public String getName() {
72
        return RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME;
73
    }
74

    
75
    @Override
76
    public Object invoke(DynObject self, Object[] args)
77
 throws DynMethodException {
78
        ColorInterpretation colorInterpretation = null;
79

    
80
        RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager();
81

    
82
        WMSRasterProvider provider = (WMSRasterProvider)self;
83
        String format = (String) provider.getParameters().getDynValue(WMSRasterProviderParameters.WMS_FORMAT_PARAMETER_NAME);
84
//        if (format.equalsIgnoreCase("png32")){
85
            colorInterpretation = legendManager.createColorInterpretation(ColorInterpretation.ARGB);
86
//        } else {
87
//            colorInterpretation = legendManager.createColorInterpretation(ColorInterpretation.PALETTE);
88

    
89
//          //FIXME:
90
//          ColorTable colorTable;
91
//
92
//          List<ColorTableClass> colorTableClasses=new ArrayList<ColorTableClass>();
93
//          double[] minMax={0d,255d};
94
//
95
//          Double increment=1.0;
96
//
97
//          for (int i=0;i<=255;i++){
98
//              String className=i+"";
99
//              double value=((minMax[0]+(i*increment)));
100
//              double interpolation=50.0;
101
//              int intARGB = ((i & 0xFF) << 24) | // alpha
102
//                  ((i & 0xFF) << 16) | // red
103
//                  ((i & 0xFF) << 8) | // green
104
//                  ((i & 0xFF) << 0); // blue
105
//              Color color=new Color(intARGB);
106
//              ColorTableClass colorTableClass = legendManager.createColorTableClass(className, value, interpolation, color);
107
//              colorTableClasses.add(colorTableClass);
108
//          }
109
//          colorTable = legendManager.createColorTable(OSMRasterProvider.NAME+"_color_table",
110
//              colorTableClasses, true);
111
//          colorInterpretation.setPalette(colorTable);
112
//          colorInterpretation.setPaletteBand(0);
113
//
114

    
115
//        }
116

    
117
        return colorInterpretation;
118
    }
119

    
120
    @Override
121
    public Object clone() throws CloneNotSupportedException {
122
        return super.clone();
123
    }
124
}