svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.impl / src / main / java / org / gvsig / fmap / mapcontext / raster / impl / MapContextRasterLibrary.java @ 43891
History | View | Annotate | Download (7.1 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 |
package org.gvsig.fmap.mapcontext.raster.impl; |
24 |
|
25 |
import org.slf4j.Logger; |
26 |
import org.slf4j.LoggerFactory; |
27 |
|
28 |
import org.gvsig.compat.CompatLibrary; |
29 |
import org.gvsig.fmap.dal.DALLibrary; |
30 |
import org.gvsig.fmap.dal.raster.RasterStore; |
31 |
import org.gvsig.fmap.mapcontext.MapContextLibrary; |
32 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
33 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
34 |
import org.gvsig.raster.lib.buffer.api.BufferLocator; |
35 |
import org.gvsig.raster.lib.buffer.api.OperationManager; |
36 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
37 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
38 |
import org.gvsig.raster.lib.legend.impl.DefaultColorInterpretation; |
39 |
import org.gvsig.raster.lib.legend.impl.DefaultColorTable; |
40 |
import org.gvsig.raster.lib.legend.impl.DefaultColorTableClass; |
41 |
import org.gvsig.raster.lib.legend.impl.DefaultRasterLegend; |
42 |
import org.gvsig.raster.lib.legend.impl.DefaultRasterLegendManager; |
43 |
import org.gvsig.raster.lib.legend.impl.DefaultTransparency; |
44 |
import org.gvsig.raster.lib.legend.impl.DefaultTransparencyRange; |
45 |
import org.gvsig.raster.lib.legend.impl.io.GimpGradientColorTableIO; |
46 |
import org.gvsig.raster.lib.legend.impl.io.GimpGradientColorTableIOFactory; |
47 |
import org.gvsig.raster.lib.legend.impl.io.GimpPaletteColorTableIO; |
48 |
import org.gvsig.raster.lib.legend.impl.io.GimpPaletteColorTableIOFactory; |
49 |
import org.gvsig.raster.lib.legend.impl.io.gvSIGColorTableIO; |
50 |
import org.gvsig.raster.lib.legend.impl.io.gvSIGColorTableIOFactory; |
51 |
import org.gvsig.raster.lib.legend.impl.operations.brightness.BrightnessOperationFactory; |
52 |
import org.gvsig.raster.lib.legend.impl.operations.cmyktorgb.CMYKToRGBOperationFactory; |
53 |
import org.gvsig.raster.lib.legend.impl.operations.colorbalancecmy.ColorBalanceCMYOperationFactory; |
54 |
import org.gvsig.raster.lib.legend.impl.operations.colorbalancehsl.ColorBalanceHSLOperationFactory; |
55 |
import org.gvsig.raster.lib.legend.impl.operations.colorbalancergb.ColorBalanceRGBOperationFactory; |
56 |
import org.gvsig.raster.lib.legend.impl.operations.colortable.ColorTableOperationFactory; |
57 |
import org.gvsig.raster.lib.legend.impl.operations.contrast.ContrastOperationFactory; |
58 |
import org.gvsig.raster.lib.legend.impl.operations.equalization.EqualizationOperationFactory; |
59 |
import org.gvsig.raster.lib.legend.impl.operations.grayscale.GrayScaleOperationFactory; |
60 |
import org.gvsig.raster.lib.legend.impl.operations.hsltorgb.HSLToRGBOperationFactory; |
61 |
import org.gvsig.raster.lib.legend.impl.operations.rgbtocmyk.RGBToCMYKOperationFactory; |
62 |
import org.gvsig.raster.lib.legend.impl.operations.rgbtohsl.RGBToHSLOperationFactory; |
63 |
import org.gvsig.tools.library.AbstractLibrary; |
64 |
import org.gvsig.tools.library.LibraryException; |
65 |
import org.gvsig.tools.util.Caller; |
66 |
import org.gvsig.tools.util.impl.DefaultCaller; |
67 |
|
68 |
/**
|
69 |
* Library used to initialize Raster Layer.
|
70 |
* Probably should be integrated in MapContextLibrary
|
71 |
*
|
72 |
*/
|
73 |
public class MapContextRasterLibrary extends AbstractLibrary { |
74 |
final static private Logger LOG = LoggerFactory.getLogger(MapContextRasterLibrary.class); |
75 |
|
76 |
@Override
|
77 |
public void doRegistration() { |
78 |
registerAsAPI(MapContextRasterLibrary.class); |
79 |
require(DALLibrary.class); |
80 |
require(CompatLibrary.class); |
81 |
} |
82 |
|
83 |
@Override
|
84 |
protected void doInitialize() throws LibraryException { |
85 |
RasterLegendLocator.registerRasterLegendManager(DefaultRasterLegendManager.class); |
86 |
|
87 |
} |
88 |
|
89 |
@Override
|
90 |
protected void doPostInitialize() throws LibraryException { |
91 |
MapContextManager manager = MapContextLocator.getMapContextManager(); |
92 |
manager.registerLayer(RasterStore.class, DefaultRasterLayer.class); |
93 |
|
94 |
Caller caller = new DefaultCaller();
|
95 |
caller.add( new DefaultRasterLayer.RegisterPersistence() );
|
96 |
|
97 |
if( !caller.call() ) {
|
98 |
throw new LibraryException(MapContextLibrary.class, caller.getExceptions()); |
99 |
} |
100 |
|
101 |
// Register persistent definition
|
102 |
DefaultColorTableClass.registerPersistence(); |
103 |
DefaultColorTable.registerPersistence(); |
104 |
DefaultColorInterpretation.registerPersistence(); |
105 |
DefaultRasterLegend.registerPersistence(); |
106 |
DefaultTransparency.registerPersistence(); |
107 |
DefaultTransparencyRange.registerPersistence(); |
108 |
|
109 |
// Register ColorTableIO factories
|
110 |
RasterLegendManager rasterLegendManager = RasterLegendLocator.getRasterLegendManager(); |
111 |
rasterLegendManager.registerColorTableIOFactory(gvSIGColorTableIO.NAME, |
112 |
new gvSIGColorTableIOFactory());
|
113 |
rasterLegendManager.registerColorTableIOFactory(GimpGradientColorTableIO.NAME, |
114 |
new GimpGradientColorTableIOFactory());
|
115 |
rasterLegendManager.registerColorTableIOFactory(GimpPaletteColorTableIO.NAME, |
116 |
new GimpPaletteColorTableIOFactory());
|
117 |
|
118 |
OperationManager operationManager = BufferLocator.getOperationManager(); |
119 |
operationManager.registerOperationFactory(new BrightnessOperationFactory());
|
120 |
operationManager.registerOperationFactory(new ContrastOperationFactory());
|
121 |
operationManager.registerOperationFactory(new GrayScaleOperationFactory());
|
122 |
|
123 |
operationManager.registerOperationFactory(new ColorBalanceRGBOperationFactory());
|
124 |
operationManager.registerOperationFactory(new ColorBalanceCMYOperationFactory());
|
125 |
operationManager.registerOperationFactory(new ColorBalanceHSLOperationFactory());
|
126 |
|
127 |
operationManager.registerOperationFactory(new RGBToCMYKOperationFactory());
|
128 |
operationManager.registerOperationFactory(new RGBToHSLOperationFactory());
|
129 |
operationManager.registerOperationFactory(new HSLToRGBOperationFactory());
|
130 |
operationManager.registerOperationFactory(new CMYKToRGBOperationFactory());
|
131 |
|
132 |
operationManager.registerOperationFactory(new EqualizationOperationFactory());
|
133 |
// BufferLocator.getBufferManager().registerOperationFactory(new PansharpeningOperationFactory());
|
134 |
|
135 |
operationManager.registerOperationFactory(new ColorTableOperationFactory());
|
136 |
|
137 |
MapContextManager mapContextManager = MapContextLocator.getMapContextManager(); |
138 |
mapContextManager.registerLegend( |
139 |
DefaultRasterLegend.LEGEND_NAME, |
140 |
DefaultRasterLegend.class); |
141 |
mapContextManager.setDefaultRasterLegend(DefaultRasterLegend.LEGEND_NAME); |
142 |
|
143 |
|
144 |
} |
145 |
|
146 |
} |