Revision 42353 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/symbol/text/impl/SimpleTextSymbol.java
SimpleTextSymbol.java | ||
---|---|---|
77 | 77 |
final static private Logger LOG = LoggerFactory.getLogger(SimpleTextSymbol.class); |
78 | 78 |
|
79 | 79 |
public static final String SIMPLE_TEXT_SYMBOL_PERSISTENCE_DEFINITION_NAME = "SimpleTextSymbol"; |
80 |
|
|
80 |
|
|
81 | 81 |
private static final String FIELD_TEXT = "text"; |
82 | 82 |
private static final String FIELD_FONT = "font"; |
83 | 83 |
private static final String FIELD_TEXT_COLOR = "textColor"; |
84 | 84 |
private static final String FIELD_ROTATION = "rotation"; |
85 | 85 |
private static final String FIELD_AUTO_RESIZE = "autoResize"; |
86 |
|
|
86 |
|
|
87 | 87 |
private static final String FIELD_HAS_HALO = "hasHalo"; |
88 | 88 |
private static final String FIELD_HALO_COLOR = "haloColor"; |
89 | 89 |
private static final String FIELD_HALO_WIDTH = "haloWidth"; |
90 | 90 |
|
91 | 91 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
92 |
|
|
92 |
|
|
93 | 93 |
/* |
94 | 94 |
* This value must be get using getText() if the 'null' |
95 | 95 |
* value has to prevented |
96 | 96 |
*/ |
97 | 97 |
private String text = ""; |
98 | 98 |
private Font font; |
99 |
|
|
99 |
|
|
100 | 100 |
private Color haloColor = Color.WHITE; |
101 | 101 |
private float haloWidth = 3; |
102 | 102 |
private boolean drawWithHalo = false; |
... | ... | |
122 | 122 |
if (!isShapeVisible()) { |
123 | 123 |
return; |
124 | 124 |
} |
125 |
|
|
126 |
Point point = (Point)geom; |
|
125 |
|
|
126 |
Point point = (Point)geom.cloneGeometry();
|
|
127 | 127 |
point.transform(affineTransform); |
128 |
|
|
128 |
|
|
129 | 129 |
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
130 | 130 |
g.translate(point.getX(), point.getY()); |
131 | 131 |
|
132 | 132 |
g.rotate(rotation); |
133 |
|
|
133 |
|
|
134 | 134 |
if (isDrawWithHalo()) { |
135 | 135 |
char[] charText = new char[getText().length()]; |
136 | 136 |
getText().getChars(0, charText.length, charText, 0); |
... | ... | |
275 | 275 |
public void setTextColor(Color color) { |
276 | 276 |
this.textColor = color; |
277 | 277 |
} |
278 |
|
|
278 |
|
|
279 | 279 |
public Color getColor() { |
280 | 280 |
return getTextColor(); |
281 | 281 |
} |
282 |
|
|
282 |
|
|
283 | 283 |
public void setColor(Color color) { |
284 | 284 |
setTextColor(color); |
285 | 285 |
} |
... | ... | |
376 | 376 |
this.autoresize = autoresizeFlag; |
377 | 377 |
} |
378 | 378 |
|
379 |
|
|
379 |
|
|
380 | 380 |
public Object clone() throws CloneNotSupportedException { |
381 | 381 |
SimpleTextSymbol copy = (SimpleTextSymbol) super.clone(); |
382 | 382 |
|
... | ... | |
384 | 384 |
} |
385 | 385 |
|
386 | 386 |
public void loadFromState(PersistentState state) |
387 |
|
|
387 |
|
|
388 | 388 |
throws PersistenceException { |
389 | 389 |
// Set parent fill symbol properties |
390 | 390 |
super.loadFromState(state); |
... | ... | |
426 | 426 |
SimpleTextSymbol.class, |
427 | 427 |
SIMPLE_TEXT_SYMBOL_PERSISTENCE_DEFINITION_NAME, |
428 | 428 |
SIMPLE_TEXT_SYMBOL_PERSISTENCE_DEFINITION_NAME+" Persistence definition", |
429 |
null,
|
|
429 |
null, |
|
430 | 430 |
null |
431 | 431 |
); |
432 | 432 |
// Extend the Symbol base definition |
... | ... | |
435 | 435 |
// Auto resize? |
436 | 436 |
definition.addDynFieldBoolean(FIELD_AUTO_RESIZE) |
437 | 437 |
.setMandatory(true); |
438 |
|
|
438 |
|
|
439 | 439 |
// Font |
440 | 440 |
definition.addDynFieldObject(FIELD_FONT) |
441 | 441 |
.setClassOfValue(Font.class) |
442 | 442 |
.setMandatory(true); |
443 |
|
|
443 |
|
|
444 | 444 |
// Rotation |
445 | 445 |
definition.addDynFieldDouble(FIELD_ROTATION) |
446 | 446 |
.setMandatory(true); |
447 |
|
|
447 |
|
|
448 | 448 |
// Text |
449 | 449 |
definition.addDynFieldString(FIELD_TEXT); |
450 |
|
|
450 |
|
|
451 | 451 |
// Text color |
452 | 452 |
definition.addDynFieldObject(FIELD_TEXT_COLOR) |
453 | 453 |
.setClassOfValue(Color.class) |
454 | 454 |
.setMandatory(true); |
455 |
|
|
455 |
|
|
456 | 456 |
// halo |
457 | 457 |
definition.addDynFieldBoolean(FIELD_HAS_HALO).setMandatory(true); |
458 | 458 |
definition.addDynFieldObject(FIELD_HALO_COLOR).setClassOfValue( |
... | ... | |
461 | 461 |
} |
462 | 462 |
return Boolean.TRUE; |
463 | 463 |
} |
464 |
|
|
464 |
|
|
465 | 465 |
} |
466 | 466 |
|
467 | 467 |
public static class RegisterSymbol implements Callable { |
... | ... | |
469 | 469 |
public Object call() throws Exception { |
470 | 470 |
int[] shapeTypes; |
471 | 471 |
SymbolManager manager = MapContextLocator.getSymbolManager(); |
472 |
|
|
472 |
|
|
473 | 473 |
//This method registered the deleted type Geometry.TYPES.TEXT. I suppose that now |
474 | 474 |
//it has to register geometry |
475 | 475 |
shapeTypes = new int[] { Geometry.TYPES.GEOMETRY }; |
... | ... | |
479 | 479 |
|
480 | 480 |
return Boolean.TRUE; |
481 | 481 |
} |
482 |
|
|
482 |
|
|
483 | 483 |
} |
484 | 484 |
|
485 |
|
|
485 |
|
|
486 | 486 |
public Color getHaloColor() { |
487 | 487 |
return haloColor; |
488 | 488 |
} |
... | ... | |
511 | 511 |
this.drawWithHalo = drawWithHalo; |
512 | 512 |
} |
513 | 513 |
|
514 |
|
|
514 |
|
|
515 | 515 |
} |
Also available in: Unified diff