Revision 43206 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/impl/AbstractVectorialLegend.java
AbstractVectorialLegend.java | ||
---|---|---|
45 | 45 |
import org.gvsig.fmap.dal.exception.ReadException; |
46 | 46 |
import org.gvsig.fmap.dal.feature.Feature; |
47 | 47 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
48 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
48 | 49 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
49 | 50 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
50 | 51 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
... | ... | |
78 | 79 |
import org.gvsig.tools.dynobject.DynStruct; |
79 | 80 |
import org.gvsig.tools.evaluator.Evaluator; |
80 | 81 |
import org.gvsig.tools.exception.BaseException; |
82 |
import org.gvsig.tools.logger.FilteredLogger; |
|
81 | 83 |
import org.gvsig.tools.persistence.PersistenceManager; |
82 | 84 |
import org.gvsig.tools.persistence.PersistentState; |
83 | 85 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
... | ... | |
233 | 235 |
} |
234 | 236 |
it = featureSet.fastIterator(); |
235 | 237 |
// Iteration over each feature |
238 |
FilteredLogger logger = new FilteredLogger(LOG,"Drawing "+featureStore.getName(), 10); |
|
236 | 239 |
while (!cancel.isCanceled() && it.hasNext()) { |
237 | 240 |
Feature feat = (Feature) it.next(); |
238 |
Geometry geom = feat.getDefaultGeometry(); |
|
239 |
if (geom==null) { |
|
240 |
continue; |
|
241 |
} |
|
242 |
// Reprojection if needed |
|
243 |
if (coordTrans != null) { |
|
244 |
geom = geom.cloneGeometry(); |
|
245 |
geom.reProject(coordTrans); |
|
246 |
} |
|
241 |
try { |
|
242 |
Geometry geom = feat.getDefaultGeometry(); |
|
243 |
if (geom==null) { |
|
244 |
continue; |
|
245 |
} |
|
246 |
// Reprojection if needed |
|
247 |
if (coordTrans != null) { |
|
248 |
geom = geom.cloneGeometry(); |
|
249 |
geom.reProject(coordTrans); |
|
250 |
} |
|
247 | 251 |
|
248 |
// retrieve the symbol associated to such feature |
|
249 |
ISymbol sym = getSymbolByFeature(feat); |
|
250 |
if (sym == null) { |
|
251 |
continue; |
|
252 |
} |
|
253 |
if (useZSort) { |
|
254 |
int[] symLevels = zSort.getLevels(sym); |
|
255 |
if (symLevels != null) { |
|
252 |
// retrieve the symbol associated to such feature
|
|
253 |
ISymbol sym = getSymbolByFeature(feat);
|
|
254 |
if (sym == null) {
|
|
255 |
continue;
|
|
256 |
}
|
|
257 |
if (useZSort) {
|
|
258 |
int[] symLevels = zSort.getLevels(sym);
|
|
259 |
if (symLevels != null) {
|
|
256 | 260 |
|
257 |
// Check if this symbol is a multilayer |
|
258 |
if (sym instanceof IMultiLayerSymbol) { |
|
259 |
// if so, get the layer corresponding to the |
|
260 |
// current level. If none, continue to next |
|
261 |
// iteration |
|
262 |
IMultiLayerSymbol mlSym = (IMultiLayerSymbol) sym; |
|
263 |
for (int i = 0; i < mlSym.getLayerCount(); i++) { |
|
264 |
ISymbol mySym = mlSym.getLayer(i); |
|
265 |
if (symLevels[i] == mapPass) { |
|
266 |
sym = mySym; |
|
267 |
break; |
|
261 |
// Check if this symbol is a multilayer |
|
262 |
if (sym instanceof IMultiLayerSymbol) { |
|
263 |
// if so, get the layer corresponding to the |
|
264 |
// current level. If none, continue to next |
|
265 |
// iteration |
|
266 |
IMultiLayerSymbol mlSym = (IMultiLayerSymbol) sym; |
|
267 |
for (int i = 0; i < mlSym.getLayerCount(); i++) { |
|
268 |
ISymbol mySym = mlSym.getLayer(i); |
|
269 |
if (symLevels[i] == mapPass) { |
|
270 |
sym = mySym; |
|
271 |
break; |
|
272 |
} |
|
268 | 273 |
} |
269 |
} |
|
270 | 274 |
|
271 |
} else { |
|
272 |
// else, just draw the symbol in its level |
|
273 |
if (symLevels[0] != mapPass) { |
|
274 |
continue; |
|
275 |
} else { |
|
276 |
// else, just draw the symbol in its level |
|
277 |
if (symLevels[0] != mapPass) { |
|
278 |
continue; |
|
279 |
} |
|
275 | 280 |
} |
276 | 281 |
} |
277 | 282 |
} |
278 |
} |
|
279 | 283 |
|
280 |
// Check if this symbol is sized with CartographicSupport |
|
281 |
CartographicSupport csSym = null; |
|
282 |
int symbolType = sym.getSymbolType(); |
|
284 |
// Check if this symbol is sized with CartographicSupport
|
|
285 |
CartographicSupport csSym = null;
|
|
286 |
int symbolType = sym.getSymbolType();
|
|
283 | 287 |
|
284 |
if (symbolType == Geometry.TYPES.POINT |
|
285 |
|| symbolType == Geometry.TYPES.CURVE |
|
286 |
|| sym instanceof CartographicSupport) { |
|
288 |
if (symbolType == Geometry.TYPES.POINT
|
|
289 |
|| symbolType == Geometry.TYPES.CURVE
|
|
290 |
|| sym instanceof CartographicSupport) {
|
|
287 | 291 |
|
288 |
csSym = (CartographicSupport) sym; |
|
289 |
} |
|
292 |
csSym = (CartographicSupport) sym;
|
|
293 |
}
|
|
290 | 294 |
|
291 |
DrawOperationContext doc = new DrawOperationContext(); |
|
292 |
doc.setGraphics(g); |
|
293 |
doc.setViewPort(viewPort); |
|
294 |
if (csSym == null) { |
|
295 |
doc.setSymbol(sym); |
|
296 |
} else { |
|
297 |
doc.setDPI(dpi); |
|
298 |
doc.setCancellable(cancel); |
|
299 |
doc.setSymbol((ISymbol) csSym); |
|
295 |
DrawOperationContext doc = new DrawOperationContext(); |
|
296 |
doc.setGraphics(g); |
|
297 |
doc.setViewPort(viewPort); |
|
298 |
if (csSym == null) { |
|
299 |
doc.setSymbol(sym); |
|
300 |
} else { |
|
301 |
doc.setDPI(dpi); |
|
302 |
doc.setCancellable(cancel); |
|
303 |
doc.setSymbol((ISymbol) csSym); |
|
304 |
} |
|
305 |
geom.invokeOperation(DrawInts.CODE, doc); |
|
306 |
} catch(Exception ex) { |
|
307 |
FeatureReference ref = null; |
|
308 |
if( feat!=null ) { |
|
309 |
ref = feat.getReference(); |
|
310 |
} |
|
311 |
logger.warn("Can't draw feature ("+ref+").", ex); |
|
300 | 312 |
} |
301 |
geom.invokeOperation(DrawInts.CODE, doc); |
|
302 | 313 |
} |
303 | 314 |
} |
304 |
} catch (ReadException e) { |
|
305 |
throw new LegendDrawingException(e); |
|
306 |
} catch (GeometryOperationNotSupportedException e) { |
|
307 |
throw new LegendDrawingException(e); |
|
308 |
} catch (GeometryOperationException e) { |
|
309 |
throw new LegendDrawingException(e); |
|
310 | 315 |
} catch (DataException e) { |
311 | 316 |
throw new LegendDrawingException(e); |
312 |
} catch (MapContextException e) { |
|
313 |
throw new LegendDrawingException(e); |
|
314 | 317 |
} finally { |
315 | 318 |
if (it != null) { |
316 | 319 |
it.dispose(); |
Also available in: Unified diff