Revision 47476 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/dynamiclegend/DefaultDynamicLabelingStrategy.java
DefaultDynamicLabelingStrategy.java | ||
---|---|---|
28 | 28 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
29 | 29 |
import org.gvsig.fmap.geom.Geometry; |
30 | 30 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
31 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
32 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
33 | 31 |
import org.gvsig.fmap.geom.primitive.Envelope; |
34 | 32 |
import org.gvsig.fmap.geom.primitive.Point; |
35 | 33 |
import org.gvsig.fmap.mapcontext.MapContext; |
... | ... | |
40 | 38 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingMethod; |
41 | 39 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.IPlacementConstraints; |
42 | 40 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.IZoomConstraints; |
43 |
import org.gvsig.symbology.SymbologyLocator; |
|
44 | 41 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy; |
45 | 42 |
import static org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy.MIN_TEXT_SIZE; |
43 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.AbstractCartographicSupport; |
|
46 | 44 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.CartographicSupportToolkit; |
47 | 45 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.impl.SimpleTextSymbol; |
48 | 46 |
import org.gvsig.tools.dispose.DisposableIterator; |
... | ... | |
58 | 56 |
* |
59 | 57 |
* @author osc |
60 | 58 |
*/ |
61 |
public class DefaultDynamicLabelingStrategy implements DynamicLabelingStrategy { |
|
59 |
public class DefaultDynamicLabelingStrategy extends AbstractCartographicSupport implements DynamicLabelingStrategy {
|
|
62 | 60 |
|
63 | 61 |
private Feature feature; |
64 | 62 |
public String LROTATION = "LROTATION"; |
... | ... | |
81 | 79 |
private FeatureSymbolTable featureSymbolTable = null; |
82 | 80 |
private FLyrVect layer; |
83 | 81 |
private List<Geometry> drawnGeometryLabels; |
84 |
private boolean printMode = false; |
|
85 |
private IZoomConstraints zoom = null; |
|
82 |
private final boolean printMode = false;
|
|
83 |
private final IZoomConstraints zoom = null;
|
|
86 | 84 |
private static final Logger logger = LoggerFactory.getLogger(AttrInTableLabelingStrategy.class); |
87 |
private int referenceSystem; |
|
88 |
private String textField; |
|
89 | 85 |
|
90 | 86 |
|
91 | 87 |
public SymbolTable getFeatureSymbolTable() { |
... | ... | |
296 | 292 |
expFontStyle = expression; |
297 | 293 |
} |
298 | 294 |
|
295 |
@Override |
|
299 | 296 |
public void setFeature(Feature f) { |
300 | 297 |
feature = f; |
301 | 298 |
if (featureSymbolTable==null) { |
... | ... | |
336 | 333 |
|
337 | 334 |
@Override |
338 | 335 |
public Expression getUnitExp() { |
339 |
// String value = "-1"; |
|
340 |
// Expression exp = getExpressionFromString(value); |
|
341 |
// return exp; |
|
342 | 336 |
return expUnit; |
343 | 337 |
} |
344 | 338 |
|
345 | 339 |
public Expression getReferenceSystemExp() { |
346 |
// String value = "0"; |
|
347 |
// Expression exp = getExpressionFromString(value); |
|
348 | 340 |
return expReferenceSystem; |
349 | 341 |
} |
350 | 342 |
|
... | ... | |
353 | 345 |
|
354 | 346 |
try { |
355 | 347 |
return geom.centroid(); |
356 |
} catch (GeometryOperationNotSupportedException e) {
|
|
348 |
} catch (Exception e) { |
|
357 | 349 |
return null; |
358 |
} catch (GeometryOperationException e) { |
|
359 |
return null; |
|
360 | 350 |
} |
361 | 351 |
} |
362 | 352 |
|
363 | 353 |
@Override |
364 | 354 |
public void draw(BufferedImage mapImage, Graphics2D mapGraphics, double scale, ViewPort viewPort, Cancellable cancel, double dpi) throws ReadException { |
365 |
// double scale = getScale(viewPort, props); |
|
366 | 355 |
PrintAttributes props = null; |
367 | 356 |
if (layer == null) { |
368 | 357 |
return; |
... | ... | |
374 | 363 |
FeatureSet set = null; |
375 | 364 |
DisposableIterator iterator = null; |
376 | 365 |
try { |
377 |
// AttrInTableLabelingStrategy.FilteredLogger logger = new AttrInTableLabelingStrategy.FilteredLogger(AttrInTableLabelingStrategy.logger, 10); |
|
378 | 366 |
|
379 | 367 |
// limit the labeling to the visible extent |
380 |
List<String> fields = new ArrayList<String>();
|
|
368 |
List<String> fields = new ArrayList<>(); |
|
381 | 369 |
|
382 | 370 |
FeatureStore featureStore = layer.getFeatureStore(); |
383 | 371 |
ICoordTrans ct = layer.getCoordTrans(); |
... | ... | |
462 | 450 |
} else if (true) { //(getComputedHeight() ) { |
463 | 451 |
// text size is defined in the table |
464 | 452 |
size = getComputedHeight(); |
465 |
} else { |
|
466 |
// otherwise will use the size in the symbol |
|
467 |
size = sym.getFont().getSize(); |
|
453 |
// } else {
|
|
454 |
// // otherwise will use the size in the symbol
|
|
455 |
// size = sym.getFont().getSize();
|
|
468 | 456 |
} |
469 | 457 |
|
470 | 458 |
double the_dpi = viewPort.getDPI(); |
... | ... | |
495 | 483 |
double font_size = size * 72 / the_dpi; |
496 | 484 |
sym.setFontSize(font_size); |
497 | 485 |
|
498 |
// if (false) { //useFixedColor) { |
|
499 |
// color = getComputedFixedColor(); |
|
500 |
// } else if (true) { //colorFieldName != null) { |
|
501 |
// // text size is defined in the table |
|
502 | 486 |
if (selection.isSelected(feat)) { |
503 | 487 |
color = MapContext.getSelectionColor(); |
504 | 488 |
} else { |
... | ... | |
587 | 571 |
throw new UnsupportedOperationException("Not supported yet."); |
588 | 572 |
} |
589 | 573 |
|
574 |
@Override |
|
590 | 575 |
public void setUnit(Expression expression) { |
591 | 576 |
expUnit = expression; |
592 | 577 |
} |
... | ... | |
618 | 603 |
} |
619 | 604 |
|
620 | 605 |
@Override |
621 |
public double toCartographicSize(ViewPort viewPort, double dpi, Geometry geom) { |
|
622 |
throw new UnsupportedOperationException("Not supported yet."); |
|
623 |
} |
|
624 |
|
|
625 |
@Override |
|
626 |
public void setCartographicSize(double cartographicSize, Geometry geom) { |
|
627 |
throw new UnsupportedOperationException("Not supported yet."); |
|
628 |
} |
|
629 |
|
|
630 |
@Override |
|
631 |
public double getCartographicSize(ViewPort viewPort, double dpi, Geometry geom) { |
|
632 |
throw new UnsupportedOperationException("Not supported yet."); |
|
633 |
} |
|
634 |
|
|
635 |
@Override |
|
636 | 606 |
public void setFont(Expression expression) { |
637 | 607 |
expFont = expression; |
638 | 608 |
} |
Also available in: Unified diff