gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.osm / org.gvsig.osm.provider.legend / src / main / java / org / gvsig / osm / provider / legend / OSMRasterGetColorInterpretation.java @ 6902
History | View | Annotate | Download (4.6 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.osm.provider.legend; |
25 |
|
26 |
import java.awt.Color; |
27 |
import java.util.ArrayList; |
28 |
import java.util.List; |
29 |
|
30 |
import org.slf4j.LoggerFactory; |
31 |
|
32 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
33 |
import org.gvsig.osm.provider.OSMRasterProvider; |
34 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
35 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
36 |
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation; |
37 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
38 |
import org.gvsig.raster.lib.legend.api.colortable.colortableclass.ColorTableClass; |
39 |
import org.gvsig.tools.ToolsLocator; |
40 |
import org.gvsig.tools.dynobject.DynClass; |
41 |
import org.gvsig.tools.dynobject.DynMethod; |
42 |
import org.gvsig.tools.dynobject.DynObject; |
43 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
44 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
45 |
|
46 |
|
47 |
|
48 |
/**
|
49 |
* @author fdiaz
|
50 |
*
|
51 |
*/
|
52 |
public class OSMRasterGetColorInterpretation implements DynMethod { |
53 |
|
54 |
final static private org.slf4j.Logger logger = LoggerFactory.getLogger(OSMRasterGetColorInterpretation.class); |
55 |
|
56 |
private static Integer code = null; |
57 |
|
58 |
static void register(DynClass storeClass) { |
59 |
if (code != null) { |
60 |
return;
|
61 |
} |
62 |
code = ToolsLocator.getDynObjectManager() |
63 |
.registerDynMethod(storeClass, new OSMRasterGetColorInterpretation());
|
64 |
|
65 |
} |
66 |
|
67 |
@Override
|
68 |
public int getCode() throws DynMethodNotSupportedException { |
69 |
return code;
|
70 |
} |
71 |
|
72 |
@Override
|
73 |
public String getDescription() { |
74 |
return "GoogleMaps Color Interpretation"; |
75 |
} |
76 |
|
77 |
@Override
|
78 |
public String getName() { |
79 |
return RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME;
|
80 |
} |
81 |
|
82 |
@Override
|
83 |
public Object invoke(DynObject self, Object[] args) throws DynMethodException { |
84 |
ColorInterpretation colorInterpretation = null;
|
85 |
|
86 |
RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager(); |
87 |
|
88 |
OSMRasterProvider provider = (OSMRasterProvider)self; |
89 |
// String format = (String) provider.getParameters().getDynValue(OSMRasterProvider.GOOGLEMAPS_FORMAT_PARAMTER_NAME);
|
90 |
// if (format.equalsIgnoreCase("png32")){
|
91 |
colorInterpretation = legendManager.createColorInterpretation(ColorInterpretation.ARGB); |
92 |
// } else {
|
93 |
// colorInterpretation = legendManager.createColorInterpretation(ColorInterpretation.PALETTE);
|
94 |
//
|
95 |
// ColorTable colorTable;
|
96 |
//
|
97 |
// //FIXME:
|
98 |
// List<ColorTableClass> colorTableClasses=new ArrayList<ColorTableClass>();
|
99 |
// double[] minMax={0d,255d};
|
100 |
//
|
101 |
// Double increment=1.0;
|
102 |
//
|
103 |
// for (int i=0;i<=255;i++){
|
104 |
// String className=i+"";
|
105 |
// double value=((minMax[0]+(i*increment)));
|
106 |
// double interpolation=50.0;
|
107 |
// int intARGB = ((i & 0xFF) << 24) | // alpha
|
108 |
// ((i & 0xFF) << 16) | // red
|
109 |
// ((i & 0xFF) << 8) | // green
|
110 |
// ((i & 0xFF) << 0); // blue
|
111 |
// Color color=new Color(intARGB);
|
112 |
// ColorTableClass colorTableClass = legendManager.createColorTableClass(className, value, interpolation, color);
|
113 |
// colorTableClasses.add(colorTableClass);
|
114 |
// }
|
115 |
// colorTable = legendManager.createColorTable(OSMRasterProvider.NAME+"_color_table",
|
116 |
// colorTableClasses, true);
|
117 |
// colorInterpretation.setPalette(colorTable);
|
118 |
// colorInterpretation.setPaletteBand(0);
|
119 |
//
|
120 |
// }
|
121 |
|
122 |
|
123 |
return colorInterpretation;
|
124 |
} |
125 |
|
126 |
@Override
|
127 |
public Object clone() throws CloneNotSupportedException { |
128 |
return super.clone(); |
129 |
} |
130 |
} |