svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.library / org.gvsig.raster.legend / org.gvsig.raster.legend.imageio / src / main / java / org / gvsig / fmap / dal / file / imageio / legend / ImageIOGetColorInterpretation.java @ 43876
History | View | Annotate | Download (2.24 KB)
1 |
package org.gvsig.fmap.dal.file.imageio.legend; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.image.BufferedImage; |
5 |
import java.awt.image.ColorModel; |
6 |
import java.awt.image.ComponentColorModel; |
7 |
import java.awt.image.IndexColorModel; |
8 |
import java.awt.image.WritableRaster; |
9 |
import java.util.ArrayList; |
10 |
import java.util.List; |
11 |
import org.gvsig.fmap.dal.file.imageio.ImageIOStoreProvider; |
12 |
|
13 |
import org.gvsig.fmap.dal.raster.RasterStore; |
14 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
15 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
16 |
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation; |
17 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
18 |
import org.gvsig.raster.lib.legend.api.colortable.colortableclass.ColorTableClass; |
19 |
import org.gvsig.tools.ToolsLocator; |
20 |
import org.gvsig.tools.dynobject.DynClass; |
21 |
import org.gvsig.tools.dynobject.DynMethod; |
22 |
import org.gvsig.tools.dynobject.DynObject; |
23 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
24 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
25 |
|
26 |
|
27 |
public class ImageIOGetColorInterpretation implements DynMethod { |
28 |
|
29 |
private static Integer code = null; |
30 |
|
31 |
static public void register(DynClass storeClass) { |
32 |
if (code != null) { |
33 |
return;
|
34 |
} |
35 |
code = ToolsLocator.getDynObjectManager() |
36 |
.registerDynMethod(storeClass, new ImageIOGetColorInterpretation());
|
37 |
|
38 |
} |
39 |
|
40 |
@Override
|
41 |
public int getCode() throws DynMethodNotSupportedException { |
42 |
return code;
|
43 |
} |
44 |
|
45 |
@Override
|
46 |
public String getDescription() { |
47 |
return "ImageIO based Color Interpretation"; |
48 |
} |
49 |
|
50 |
@Override
|
51 |
public String getName() { |
52 |
return RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME;
|
53 |
} |
54 |
|
55 |
@Override
|
56 |
public Object invoke(DynObject self, Object[] args) throws DynMethodException { |
57 |
ImageIOStoreProvider provider = (ImageIOStoreProvider) self; |
58 |
|
59 |
RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager(); |
60 |
|
61 |
BufferedImage image = provider.getImage();
|
62 |
return legendManager.createColorInterpretation(image, provider.getName());
|
63 |
} |
64 |
|
65 |
@Override
|
66 |
public Object clone() throws CloneNotSupportedException { |
67 |
return super.clone(); |
68 |
} |
69 |
} |