Revision 30103 branches/v2_0_0_prep/extensions/org.gvsig.symbology/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/impl/AbstractVectorialLegend.java
AbstractVectorialLegend.java | ||
---|---|---|
59 | 59 |
import org.gvsig.fmap.mapcontext.MapContext; |
60 | 60 |
import org.gvsig.fmap.mapcontext.ViewPort; |
61 | 61 |
import org.gvsig.fmap.mapcontext.layers.vectorial.IntersectsEnvelopeEvaluator; |
62 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
63 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
62 | 64 |
import org.gvsig.fmap.mapcontext.rendering.legend.LegendException; |
63 | 65 |
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport; |
64 | 66 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol; |
... | ... | |
68 | 70 |
import org.gvsig.tools.task.Cancellable; |
69 | 71 |
|
70 | 72 |
/** |
73 |
* Base implementation for Vectorial data Legends. |
|
74 |
* |
|
75 |
* Provides a draw method implementation which loads the {@link Feature}s and |
|
76 |
* uses the {@link ISymbol} objects to draw the {@link Geometry} objects. |
|
77 |
* |
|
71 | 78 |
* @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a> |
72 | 79 |
*/ |
73 |
public abstract class AbstractVectorialLegend extends AbstractLegend { |
|
80 |
public abstract class AbstractVectorialLegend extends AbstractLegend implements |
|
81 |
IVectorLegend { |
|
74 | 82 |
|
75 | 83 |
private static final GeometryManager geomManager = GeometryLocator |
76 | 84 |
.getGeometryManager(); |
... | ... | |
79 | 87 |
|
80 | 88 |
public ZSort getZSort() { |
81 | 89 |
return zSort; |
82 |
|
|
83 | 90 |
} |
84 | 91 |
|
85 | 92 |
public void setZSort(ZSort zSort) { |
... | ... | |
138 | 145 |
containsAll = viewPortEnvelope.contains(myEnvelope); |
139 | 146 |
|
140 | 147 |
// Create the context for the DRAW Geometry operation |
141 |
// DrawOperationContext doc = new DrawOperationContext();
|
|
148 |
// DrawOperationContext doc = new DrawOperationContext();
|
|
142 | 149 |
// FIXME Why double??? |
143 | 150 |
double dpi = MapContext.getScreenDPI(); |
144 |
// doc.setViewPort(viewPort);
|
|
145 |
// doc.setScale(scale);
|
|
146 |
// doc.setCancellable(cancel);
|
|
147 |
// doc.setDPI(dpi);
|
|
151 |
// doc.setViewPort(viewPort);
|
|
152 |
// doc.setScale(scale);
|
|
153 |
// doc.setCancellable(cancel);
|
|
154 |
// doc.setDPI(dpi);
|
|
148 | 155 |
|
149 | 156 |
// Create the drawing notification to be reused on each iteration |
150 | 157 |
DefaultFeatureDrawnNotification drawnNotification = new DefaultFeatureDrawnNotification(); |
... | ... | |
257 | 264 |
} |
258 | 265 |
|
259 | 266 |
// retrieve the symbol associated to such feature |
260 |
ISymbol sym = getDefaultSymbol(); |
|
267 |
// ISymbol sym = getDefaultSymbol(); |
|
268 |
ISymbol sym = getSymbolByFeature(feat); |
|
261 | 269 |
|
262 | 270 |
if (sym == null) { |
263 | 271 |
continue; |
... | ... | |
283 | 291 |
// Check if this symbol is sized with |
284 | 292 |
// CartographicSupport |
285 | 293 |
CartographicSupport csSym = null; |
286 |
// int symbolType = sym.getSymbolType();
|
|
294 |
// int symbolType = sym.getSymbolType();
|
|
287 | 295 |
boolean bDrawCartographicSupport = false; |
288 | 296 |
|
289 | 297 |
int x = -1; |
... | ... | |
295 | 303 |
// FIXME: this need to check the symbol size too |
296 | 304 |
boolean onePoint = sym.isOneDotOrPixel(geom, xyCoordsDbl, |
297 | 305 |
viewPort, (int) dpi); |
298 |
|
|
306 |
|
|
299 | 307 |
// Avoid out of bounds exceptions because is out of |
300 | 308 |
// graphics extension |
301 | 309 |
if (onePoint) { |
... | ... | |
358 | 366 |
.getOnePointRgb()); |
359 | 367 |
} else { |
360 | 368 |
drawGeometry(geom, mySym, viewPort, |
361 |
graphics[symbolLevel], dpi, |
|
362 |
cancel); |
|
363 |
// if (!bDrawCartographicSupport) { |
|
364 |
// doc.setGraphics(graphics[symbolLevel]); |
|
365 |
// doc.setSymbol(mySym); |
|
366 |
// geom |
|
367 |
// .invokeOperation(DrawInts.CODE, |
|
368 |
// doc); |
|
369 |
// } else { |
|
370 |
// doc.setGraphics(graphics[symbolLevel]); |
|
371 |
// doc.setSymbol(mySym); |
|
372 |
// geom |
|
373 |
// .invokeOperation(DrawInts.CODE, |
|
374 |
// doc); |
|
375 |
// } |
|
369 |
graphics[symbolLevel], dpi, cancel); |
|
370 |
// if (!bDrawCartographicSupport) { |
|
371 |
// doc.setGraphics(graphics[symbolLevel]); |
|
372 |
// doc.setSymbol(mySym); |
|
373 |
// geom |
|
374 |
// .invokeOperation(DrawInts.CODE, |
|
375 |
// doc); |
|
376 |
// } else { |
|
377 |
// doc.setGraphics(graphics[symbolLevel]); |
|
378 |
// doc.setSymbol(mySym); |
|
379 |
// geom |
|
380 |
// .invokeOperation(DrawInts.CODE, |
|
381 |
// doc); |
|
382 |
// } |
|
376 | 383 |
} |
377 | 384 |
} |
378 | 385 |
} else { |
... | ... | |
384 | 391 |
if (!bDrawCartographicSupport) { |
385 | 392 |
drawGeometry(geom, sym, viewPort, |
386 | 393 |
graphics[symbolLevel], dpi, cancel); |
387 |
// doc.setGraphics(graphics[symbolLevel]);
|
|
388 |
// doc.setSymbol(sym);
|
|
389 |
// geom.invokeOperation(DrawInts.CODE, doc);
|
|
394 |
// doc.setGraphics(graphics[symbolLevel]);
|
|
395 |
// doc.setSymbol(sym);
|
|
396 |
// geom.invokeOperation(DrawInts.CODE, doc);
|
|
390 | 397 |
} else { |
391 | 398 |
drawGeometry(geom, (ISymbol) csSym, viewPort, |
392 | 399 |
graphics[symbolLevel], dpi, cancel); |
393 |
// doc.setGraphics(graphics[symbolLevel]);
|
|
394 |
// doc.setSymbol((ISymbol) csSym);
|
|
395 |
// geom.invokeOperation(DrawInts.CODE, doc);
|
|
400 |
// doc.setGraphics(graphics[symbolLevel]);
|
|
401 |
// doc.setSymbol((ISymbol) csSym);
|
|
402 |
// geom.invokeOperation(DrawInts.CODE, doc);
|
|
396 | 403 |
} |
397 | 404 |
} |
398 | 405 |
|
... | ... | |
440 | 447 |
if (!bDrawCartographicSupport) { |
441 | 448 |
drawGeometry(geom, sym, viewPort, g, dpi, |
442 | 449 |
cancel); |
443 |
// doc.setGraphics(g);
|
|
444 |
// doc.setSymbol(sym);
|
|
445 |
// geom.invokeOperation(DrawInts.CODE, doc);
|
|
450 |
// doc.setGraphics(g);
|
|
451 |
// doc.setSymbol(sym);
|
|
452 |
// geom.invokeOperation(DrawInts.CODE, doc);
|
|
446 | 453 |
} else { |
447 | 454 |
drawGeometry(geom, (ISymbol) csSym, viewPort, |
448 | 455 |
g, dpi, cancel); |
449 |
// doc.setGraphics(g);
|
|
450 |
// doc.setSymbol((ISymbol) csSym);
|
|
451 |
// geom.invokeOperation(DrawInts.CODE, doc);
|
|
456 |
// doc.setGraphics(g);
|
|
457 |
// doc.setSymbol((ISymbol) csSym);
|
|
458 |
// geom.invokeOperation(DrawInts.CODE, doc);
|
|
452 | 459 |
} |
453 | 460 |
} |
454 | 461 |
} |
... | ... | |
486 | 493 |
|
487 | 494 |
} catch (ReadException e) { |
488 | 495 |
throw new LegendDrawingException(e); |
489 |
// } catch (GeometryOperationNotSupportedException e) {
|
|
490 |
// throw new LegendDrawingException(e);
|
|
496 |
// } catch (GeometryOperationNotSupportedException e) {
|
|
497 |
// throw new LegendDrawingException(e);
|
|
491 | 498 |
} catch (CreateGeometryException e) { |
492 | 499 |
throw new LegendDrawingException(e); |
493 | 500 |
} catch (BaseException e) { |
... | ... | |
495 | 502 |
} |
496 | 503 |
|
497 | 504 |
} |
498 |
|
|
499 | 505 |
|
500 | 506 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
501 | 507 |
double scale, Object object, ICoordTrans coordTrans, |
502 | 508 |
FeatureStore featureStore, PrintAttributes properties) |
503 | 509 |
throws LegendException { |
504 | 510 |
// TODO Auto-generated method stub |
505 |
|
|
511 |
|
|
506 | 512 |
} |
507 |
|
|
513 |
|
|
514 |
/** |
|
515 |
* Draws a {@link Geometry} with the given {@link ISymbol}, over the |
|
516 |
* {@link Graphics2D} object. |
|
517 |
*/ |
|
508 | 518 |
private void drawGeometry(Geometry geom, ISymbol symbol, ViewPort viewPort, |
509 | 519 |
Graphics2D graphics, double dpi, Cancellable cancellable) |
510 | 520 |
throws CreateGeometryException { |
... | ... | |
533 | 543 |
} |
534 | 544 |
} |
535 | 545 |
|
546 |
/** |
|
547 |
* Transforms a Geometry from map coordinates to the view coordinates. |
|
548 |
*/ |
|
536 | 549 |
private Geometry transformToInts(Geometry gp, AffineTransform at) |
537 | 550 |
throws CreateGeometryException { |
538 | 551 |
GeneralPathX newGp = new GeneralPathX(); |
... | ... | |
625 | 638 |
return geom; |
626 | 639 |
} |
627 | 640 |
|
641 |
/** |
|
642 |
* Returns the names of the {@link Feature} attributes required for the |
|
643 |
* {@link ILegend} to operate. |
|
644 |
* |
|
645 |
* @param featureStore |
|
646 |
* the store where the {@link Feature}s belong to |
|
647 |
* @return the names of required {@link Feature} attribute names |
|
648 |
* @throws DataException |
|
649 |
* if there is an error getting the attribute names |
|
650 |
*/ |
|
628 | 651 |
protected abstract String[] getRequiredFeatureAttributeNames( |
629 | 652 |
FeatureStore featureStore) throws DataException; |
630 | 653 |
} |
Also available in: Unified diff