svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.raster.legend / org.gvsig.raster.legend.imageio / src / main / java / org / gvsig / fmap / dal / file / imageio / legend / ImageIOGetLegend.java @ 44831
History | View | Annotate | Download (2.07 KB)
1 | 44831 | jjdelcerro | package org.gvsig.fmap.dal.file.imageio.legend; |
---|---|---|---|
2 | |||
3 | import org.gvsig.fmap.dal.raster.RasterStore; |
||
4 | import org.gvsig.fmap.dal.spi.DataStoreProvider; |
||
5 | import org.gvsig.raster.lib.legend.api.RasterLegend; |
||
6 | import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
||
7 | import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
||
8 | import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation; |
||
9 | import org.gvsig.tools.ToolsLocator; |
||
10 | import org.gvsig.tools.dynobject.DynClass; |
||
11 | import org.gvsig.tools.dynobject.DynMethod; |
||
12 | import org.gvsig.tools.dynobject.DynObject; |
||
13 | import org.gvsig.tools.dynobject.exception.DynMethodException; |
||
14 | import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
||
15 | |||
16 | |||
17 | public class ImageIOGetLegend implements DynMethod { |
||
18 | |||
19 | private int code; |
||
20 | |||
21 | static public void register(DynClass storeClass) { |
||
22 | ImageIOGetLegend method = new ImageIOGetLegend();
|
||
23 | method.code = ToolsLocator.getDynObjectManager().registerDynMethod(storeClass,method); |
||
24 | } |
||
25 | |||
26 | @Override
|
||
27 | public int getCode() throws DynMethodNotSupportedException { |
||
28 | return code;
|
||
29 | } |
||
30 | |||
31 | @Override
|
||
32 | public String getDescription() { |
||
33 | return "ImageIO based Legend"; |
||
34 | } |
||
35 | |||
36 | @Override
|
||
37 | public String getName() { |
||
38 | return RasterStore.DYNMETHOD_GETLEGEND_NAME;
|
||
39 | } |
||
40 | |||
41 | @Override
|
||
42 | public Object invoke(DynObject self, Object[] args) |
||
43 | throws DynMethodException {
|
||
44 | try {
|
||
45 | DataStoreProvider provider=(DataStoreProvider)self; |
||
46 | RasterLegendManager legendManager=RasterLegendLocator.getRasterLegendManager(); |
||
47 | |||
48 | ColorInterpretation colorInterpretation =(ColorInterpretation)provider. |
||
49 | invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME, null);
|
||
50 | |||
51 | RasterLegend legend= legendManager.createLegend(colorInterpretation); |
||
52 | |||
53 | return legend;
|
||
54 | |||
55 | } catch (DynMethodNotSupportedException e) {
|
||
56 | //FIXME
|
||
57 | throw new RuntimeException(e); |
||
58 | } |
||
59 | } |
||
60 | |||
61 | @Override
|
||
62 | public Object clone() throws CloneNotSupportedException { |
||
63 | return super.clone(); |
||
64 | } |
||
65 | } |