Revision 6317 org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.mapcontext.raster/org.gvsig.fmap.mapcontext.raster.impl/src/main/java/org/gvsig/fmap/mapcontext/raster/impl/DefaultRasterLayer.java
DefaultRasterLayer.java | ||
---|---|---|
37 | 37 |
import java.util.TreeSet; |
38 | 38 |
|
39 | 39 |
import org.cresques.cts.ICoordTrans; |
40 |
|
|
40 | 41 |
import org.gvsig.compat.print.PrintAttributes; |
41 | 42 |
import org.gvsig.fmap.dal.DataStore; |
42 | 43 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
62 | 63 |
import org.gvsig.metadata.exceptions.MetadataException; |
63 | 64 |
import org.gvsig.raster.lib.buffer.api.Band; |
64 | 65 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
66 |
import org.gvsig.raster.lib.legend.api.ColorInterpretation; |
|
65 | 67 |
import org.gvsig.raster.lib.legend.api.ColorTable; |
66 | 68 |
import org.gvsig.raster.lib.legend.api.ColorTableClass; |
67 | 69 |
import org.gvsig.raster.lib.legend.api.RasterLegend; |
68 | 70 |
import org.gvsig.tools.ToolsLocator; |
71 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
69 | 72 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
70 | 73 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
71 | 74 |
import org.gvsig.tools.exception.BaseException; |
72 | 75 |
import org.gvsig.tools.task.Cancellable; |
73 | 76 |
import org.gvsig.tools.task.SimpleTaskStatus; |
74 | 77 |
import org.gvsig.tools.task.TaskStatusManager; |
78 |
|
|
75 | 79 |
import org.slf4j.LoggerFactory; |
76 | 80 |
|
77 | 81 |
/** |
... | ... | |
93 | 97 |
|
94 | 98 |
/** |
95 | 99 |
* Creates a new DefaultRasterLayer |
96 |
* @throws LoadLayerException
|
|
100 |
* @throws LoadLayerException |
|
97 | 101 |
*/ |
98 | 102 |
public DefaultRasterLayer() throws LoadLayerException{ |
99 | 103 |
super(); |
... | ... | |
104 | 108 |
* @param store |
105 | 109 |
* @param legend |
106 | 110 |
*/ |
107 |
public DefaultRasterLayer(RasterStore store, RasterLegend legend){ |
|
111 |
public DefaultRasterLayer(RasterStore store, RasterLegend legend) {
|
|
108 | 112 |
super(); |
109 |
this.store=store; |
|
110 |
this.legend=legend; |
|
113 |
ToolsLocator.getDisposableManager().bind(store); |
|
114 |
this.store = store; |
|
115 |
this.legend = legend; |
|
111 | 116 |
} |
112 | 117 |
|
113 |
|
|
114 | 118 |
public void setLegend(RasterLegend legend) throws LegendLayerException { |
115 | 119 |
if (this.legend == legend) { |
116 | 120 |
return; |
... | ... | |
134 | 138 |
// callLegendChanged(e); |
135 | 139 |
} |
136 | 140 |
|
141 |
|
|
137 | 142 |
/** |
138 | 143 |
* Devuelve la Leyenda de la capa. |
139 | 144 |
* |
... | ... | |
151 | 156 |
|
152 | 157 |
@Override |
153 | 158 |
public void setDataStore(DataStore dataStore) throws LoadLayerException { |
154 |
if (this.store!=null){ |
|
155 |
throw new LoadLayerException("Store already created"); |
|
156 |
}else{ |
|
157 |
this.store=(RasterStore)dataStore; |
|
158 |
initLegend(); |
|
159 |
|
|
160 |
if (this.store != null) { |
|
161 |
ToolsLocator.getDisposableManager().release(this.store); |
|
162 |
DisposeUtils.disposeQuietly(this.store); |
|
159 | 163 |
} |
164 |
|
|
165 |
this.store = (RasterStore) dataStore; |
|
166 |
ToolsLocator.getDisposableManager().bind(dataStore); |
|
167 |
initLegend(); |
|
160 | 168 |
} |
161 | 169 |
|
162 | 170 |
/** |
... | ... | |
243 | 251 |
} |
244 | 252 |
|
245 | 253 |
RasterQuery rasterQuery = createRasterQuery(); |
254 |
ColorInterpretation colorInterpretation = legend.getColorInterpretation(); |
|
255 |
String[] renderBands = colorInterpretation.getValues();//.buildRenderBands(); |
|
256 |
for (int i = 0; i < renderBands.length; i++) { |
|
257 |
int band = colorInterpretation.getBand(renderBands[i]); |
|
258 |
rasterQuery.addBand(this.store.createBandQuery(band)); |
|
259 |
} |
|
246 | 260 |
|
247 | 261 |
try { |
248 | 262 |
|
... | ... | |
253 | 267 |
SimpleTaskStatus taskStatus = manager.createDefaultSimpleTaskStatus("Draw "+getDataStore().getName()); |
254 | 268 |
|
255 | 269 |
((RasterLegend) legend).draw(g, getRasterStore().getRasterSet(rasterQuery), viewPort, taskStatus); |
256 |
|
|
270 |
|
|
257 | 271 |
logger.debug("Layer " + this.getName() + " drawn in " |
258 | 272 |
+ (System.currentTimeMillis() - tini) + " milliseconds."); |
259 | 273 |
|
... | ... | |
393 | 407 |
|
394 | 408 |
@Override |
395 | 409 |
protected void doDispose() throws BaseException { |
396 |
// TODO Do nothing |
|
397 |
|
|
410 |
ToolsLocator.getDisposableManager().release(this.store); |
|
411 |
DisposeUtils.dispose(store); |
|
412 |
this.legend = null; |
|
413 |
this.baseQuery = null; |
|
398 | 414 |
} |
399 | 415 |
|
400 | 416 |
} |
Also available in: Unified diff