root / branches / v2_0_0_prep / libraries / org.gvsig.symbology / org.gvsig.symbology.lib / org.gvsig.symbology.lib.impl / src / main / java / org / gvsig / symbology / fmap / mapcontext / rendering / legend / styling / AttrInTableLabelingStrategy.java @ 39492
History | View | Annotate | Download (19.2 KB)
1 |
package org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Font; |
5 |
import java.awt.Graphics2D; |
6 |
import java.awt.image.BufferedImage; |
7 |
import java.util.ArrayList; |
8 |
import java.util.List; |
9 |
|
10 |
import org.cresques.cts.ICoordTrans; |
11 |
import org.cresques.cts.IProjection; |
12 |
import org.slf4j.LoggerFactory; |
13 |
|
14 |
import org.gvsig.compat.print.PrintAttributes; |
15 |
import org.gvsig.fmap.dal.exception.DataException; |
16 |
import org.gvsig.fmap.dal.exception.ReadException; |
17 |
import org.gvsig.fmap.dal.feature.Feature; |
18 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
19 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
20 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
21 |
import org.gvsig.fmap.dal.feature.FeatureType; |
22 |
import org.gvsig.fmap.geom.Geometry; |
23 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
24 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
25 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
26 |
import org.gvsig.fmap.geom.primitive.Envelope; |
27 |
import org.gvsig.fmap.geom.primitive.Point; |
28 |
import org.gvsig.fmap.mapcontext.MapContext; |
29 |
import org.gvsig.fmap.mapcontext.ViewPort; |
30 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
31 |
import org.gvsig.fmap.mapcontext.layers.vectorial.ContainsEnvelopeEvaluator; |
32 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
33 |
import org.gvsig.fmap.mapcontext.layers.vectorial.IntersectsEnvelopeEvaluator; |
34 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingMethod; |
35 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.IPlacementConstraints; |
36 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.IZoomConstraints; |
37 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.CartographicSupportToolkit; |
38 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.text.impl.SimpleTextSymbol; |
39 |
import org.gvsig.tools.ToolsLocator; |
40 |
import org.gvsig.tools.dispose.DisposableIterator; |
41 |
import org.gvsig.tools.dynobject.DynStruct; |
42 |
import org.gvsig.tools.exception.BaseException; |
43 |
import org.gvsig.tools.persistence.PersistenceManager; |
44 |
import org.gvsig.tools.persistence.PersistentState; |
45 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
46 |
import org.gvsig.tools.task.Cancellable; |
47 |
import org.gvsig.tools.util.Callable; |
48 |
|
49 |
|
50 |
|
51 |
/**
|
52 |
* LabelingStrategy used when the user wants to use label sizes, rotations, etc. from
|
53 |
* the values included in fields of the datasource's table
|
54 |
*
|
55 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
56 |
*
|
57 |
*/
|
58 |
public class AttrInTableLabelingStrategy implements IAttrInTableLabelingStrategy { |
59 |
private static final String FIELD_LABELING_METHOD = "labelingMethod"; |
60 |
private static final String FIELD_ZOOM_CONSTRAINTS = "zoomConstraints"; |
61 |
private static final String FIELD_COLOR_FONT = "colorFont"; |
62 |
private static final String FIELD_REFERENCE_SYSTEM = "referenceSystem"; |
63 |
private static final String FIELD_FIXED_COLOR = "fixedColor"; |
64 |
private static final String FIELD_USE_FIXED_COLOR = "useFixedColor"; |
65 |
private static final String FIELD_FIXED_SIZE = "fixedSize"; |
66 |
private static final String FIELD_USE_FIXED_SIZE = "useFixedSize"; |
67 |
private static final String FIELD_FONT = "font"; |
68 |
private static final String FIELD_UNIT = "Unit"; |
69 |
private static final String FIELD_ROTATION = "RotationField"; |
70 |
private static final String FIELD_COLOR = "ColorField"; |
71 |
private static final String FIELD_HEIGHT = "HeightField"; |
72 |
private static final String FIELD_TEXT = "TextField"; |
73 |
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(AttrInTableLabelingStrategy.class); |
74 |
public static final double MIN_TEXT_SIZE = 3; |
75 |
private static final String ATTR_IN_TABLE_LABELING_STRATEGY_PERSISTENCE_DEFINITION_NAME = |
76 |
"AttrInTableLabelingStrategy";
|
77 |
private ILabelingMethod method = new DefaultLabelingMethod(); |
78 |
private IZoomConstraints zoom;
|
79 |
private FLyrVect layer;
|
80 |
// private double unitFactor = 1D;
|
81 |
private double fixedSize=10; |
82 |
private Color fixedColor; |
83 |
private int unit = -1; //(pixel) |
84 |
private boolean useFixedSize; |
85 |
private boolean useFixedColor; |
86 |
private int referenceSystem; |
87 |
// private boolean isPrinting;
|
88 |
private String[] usedFields = null; |
89 |
private Font font; |
90 |
private Color colorFont; |
91 |
private String textFieldName; |
92 |
private String rotationFieldName; |
93 |
private String heightFieldName; |
94 |
private String colorFieldName; |
95 |
|
96 |
public ILabelingMethod getLabelingMethod() {
|
97 |
return this.method; |
98 |
} |
99 |
|
100 |
public void setLabelingMethod(ILabelingMethod method) { |
101 |
this.method = method;
|
102 |
} |
103 |
|
104 |
public IPlacementConstraints getPlacementConstraints() {
|
105 |
return null; // (automatically handled by the driver) |
106 |
} |
107 |
|
108 |
public void setPlacementConstraints(IPlacementConstraints constraints) { |
109 |
// nothing
|
110 |
} |
111 |
|
112 |
public IZoomConstraints getZoomConstraints() {
|
113 |
return zoom;
|
114 |
} |
115 |
|
116 |
public void setZoomConstraints(IZoomConstraints constraints) { |
117 |
this.zoom = constraints;
|
118 |
} |
119 |
|
120 |
private void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
121 |
Cancellable cancel, PrintAttributes props) throws ReadException {
|
122 |
|
123 |
double scale = viewPort.getScale();
|
124 |
|
125 |
SimpleTextSymbol sym = new SimpleTextSymbol();
|
126 |
|
127 |
sym.setFont(getFont()); |
128 |
|
129 |
sym.setUnit(unit); |
130 |
sym.setReferenceSystem(referenceSystem); |
131 |
if (zoom==null || |
132 |
( zoom.isUserDefined() && (scale >= zoom.getMaxScale()) |
133 |
&& (scale <= zoom.getMinScale()) ) ) { |
134 |
FeatureSet set = null;
|
135 |
DisposableIterator iterator = null;
|
136 |
try {
|
137 |
// limit the labeling to the visible extent
|
138 |
List<String> fields = new ArrayList<String>(); |
139 |
int heightPos =-1; |
140 |
int rotationPos =-1; |
141 |
int textPos = -1; |
142 |
int colorPos = -1; |
143 |
|
144 |
if (!this.usesFixedSize()) { |
145 |
if (getHeightField() != null) { |
146 |
heightPos = fields.size(); |
147 |
fields.add(getHeightField()); |
148 |
} |
149 |
} |
150 |
if (getRotationField() != null) { |
151 |
rotationPos = fields.size(); |
152 |
fields.add(getRotationField()); |
153 |
} |
154 |
if (getTextField() != null) { |
155 |
textPos = fields.size(); |
156 |
fields.add(getTextField()); |
157 |
} |
158 |
|
159 |
if (!this.usesFixedColor() && getColorField() != null) { |
160 |
colorPos = fields.size(); |
161 |
fields.add(getColorField()); |
162 |
} |
163 |
|
164 |
FeatureStore featureStore = layer.getFeatureStore(); |
165 |
ICoordTrans ct = layer.getCoordTrans(); |
166 |
|
167 |
String geomName = featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName();
|
168 |
fields.add(geomName); |
169 |
|
170 |
if (viewPort.getAdjustedEnvelope().contains(
|
171 |
layer.getFullEnvelope())) { |
172 |
/*
|
173 |
* viewport contains layer completely
|
174 |
*/
|
175 |
set = featureStore.getFeatureSet(); |
176 |
} else {
|
177 |
/*
|
178 |
* view port does not contain layer completely
|
179 |
*/
|
180 |
IntersectsEnvelopeEvaluator iee = null;
|
181 |
|
182 |
IProjection data_proj = null;
|
183 |
Envelope env_in_store_crs = null;
|
184 |
|
185 |
if (ct == null) { |
186 |
env_in_store_crs = viewPort.getAdjustedEnvelope(); |
187 |
data_proj = viewPort.getProjection(); |
188 |
} else {
|
189 |
env_in_store_crs = viewPort.getAdjustedEnvelope().convert( |
190 |
ct.getInverted()); |
191 |
data_proj = ct.getPOrig(); |
192 |
} |
193 |
|
194 |
iee = new IntersectsEnvelopeEvaluator(
|
195 |
env_in_store_crs, |
196 |
data_proj, |
197 |
featureStore.getDefaultFeatureType(), |
198 |
geomName); |
199 |
FeatureQuery featureQuery = featureStore.createFeatureQuery(); |
200 |
featureQuery.setAttributeNames((String[]) fields.toArray(new String[fields.size()])); |
201 |
featureQuery.setFilter(iee); |
202 |
set = featureStore.getFeatureSet(featureQuery); |
203 |
} |
204 |
|
205 |
/*
|
206 |
* 'set' now has the features that have to be labeled
|
207 |
*/
|
208 |
iterator = set.fastIterator(); |
209 |
while(iterator.hasNext()){
|
210 |
if (cancel.isCanceled()){
|
211 |
return;
|
212 |
} |
213 |
Feature feature=(Feature)iterator.next(); |
214 |
double size = 0; |
215 |
Color color = null; |
216 |
if (useFixedSize){
|
217 |
// uses fixed size
|
218 |
size = fixedSize;// * fontScaleFactor;
|
219 |
} else if (heightFieldName != null) { |
220 |
// text size is defined in the table
|
221 |
try {
|
222 |
size = feature.getDouble(fields.get(heightPos)); |
223 |
} catch (Exception e) { |
224 |
logger. |
225 |
warn("Null text height value for text '{}'", feature.getString(fields.get(textPos)));
|
226 |
|
227 |
continue;
|
228 |
} |
229 |
} else {
|
230 |
// otherwise will use the size in the symbol
|
231 |
size = sym.getFont().getSize(); |
232 |
} |
233 |
|
234 |
double the_dpi = MapContext.getScreenDPI();
|
235 |
if (props != null) { |
236 |
int len = PrintAttributes.PRINT_QUALITY_DPI.length;
|
237 |
int priq = props.getPrintQuality();
|
238 |
if (priq < 0 || priq >= len) { |
239 |
throw new ReadException(featureStore.getName(), |
240 |
new Exception("Bad print quality value: " |
241 |
+ priq)); |
242 |
} else {
|
243 |
the_dpi = PrintAttributes.PRINT_QUALITY_DPI[priq]; |
244 |
} |
245 |
} |
246 |
|
247 |
size = CartographicSupportToolkit. |
248 |
getCartographicLength(this,
|
249 |
size, |
250 |
viewPort, |
251 |
the_dpi); |
252 |
if (size <= MIN_TEXT_SIZE) {
|
253 |
// label is too small to be readable, will be skipped
|
254 |
// this speeds up the rendering in wider zooms
|
255 |
continue;
|
256 |
} |
257 |
|
258 |
|
259 |
/*
|
260 |
* ym.setFontSize(int) assumes dpi = 72
|
261 |
*/
|
262 |
sym.setFontSize(size*72/the_dpi);
|
263 |
|
264 |
|
265 |
if (useFixedColor){
|
266 |
color = fixedColor; |
267 |
} else if (colorFieldName != null) { |
268 |
// text size is defined in the table
|
269 |
try {
|
270 |
color = new Color(feature.getInt(fields.get(colorPos))); |
271 |
} catch (ClassCastException ccEx) { |
272 |
if (feature.get(fields.get(colorPos)) != null) { |
273 |
throw new ReadException("Unknown", ccEx); |
274 |
} |
275 |
logger.warn( |
276 |
"Null color value for text '{}'",
|
277 |
feature.getString(textFieldName)); |
278 |
|
279 |
continue;
|
280 |
} |
281 |
} else {
|
282 |
color = sym.getTextColor(); |
283 |
} |
284 |
|
285 |
sym.setTextColor(color); |
286 |
|
287 |
double rotation = 0D; |
288 |
if (rotationFieldName != null) { |
289 |
// text rotation is defined in the table
|
290 |
rotation = -Math.toRadians(((Number) feature.get(fields.get(rotationPos))).doubleValue()); |
291 |
} |
292 |
|
293 |
Geometry geom = feature.getDefaultGeometry(); |
294 |
sym.setText(feature.getString(fields.get(textPos))); |
295 |
sym.setRotation(rotation); |
296 |
|
297 |
if (ct != null) { |
298 |
/*
|
299 |
* Reproject from store CRS to view CRS
|
300 |
*/
|
301 |
geom = geom.cloneGeometry(); |
302 |
geom.reProject(ct); |
303 |
} |
304 |
|
305 |
Point p = createLabelPoint(geom);
|
306 |
if( p != null ) { |
307 |
if (props == null) { |
308 |
sym.draw(g, viewPort.getAffineTransform(), p, feature, cancel); |
309 |
} else {
|
310 |
sym.print(g, viewPort.getAffineTransform(), p, props); |
311 |
} |
312 |
} |
313 |
} |
314 |
|
315 |
} catch (BaseException e) {
|
316 |
throw new ReadException( |
317 |
"Could not draw annotation in the layer.", e);
|
318 |
} finally {
|
319 |
if (iterator != null) { |
320 |
iterator.dispose(); |
321 |
} |
322 |
if (set != null) { |
323 |
set.dispose(); |
324 |
} |
325 |
|
326 |
} |
327 |
|
328 |
} |
329 |
} |
330 |
|
331 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
332 |
Cancellable cancel, double dpi) throws ReadException { |
333 |
draw(image, g, viewPort, cancel, null);
|
334 |
} |
335 |
|
336 |
private org.gvsig.fmap.geom.primitive.Point createLabelPoint(org.gvsig.fmap.geom.Geometry geom)
|
337 |
throws CreateGeometryException {
|
338 |
|
339 |
try {
|
340 |
return geom.centroid();
|
341 |
} catch (GeometryOperationNotSupportedException e) {
|
342 |
return null; |
343 |
} catch (GeometryOperationException e) {
|
344 |
return null; |
345 |
} |
346 |
} |
347 |
|
348 |
// public String getClassName() {
|
349 |
// return getClass().getName();
|
350 |
// }
|
351 |
|
352 |
public String getRotationField() { |
353 |
return this.rotationFieldName; |
354 |
} |
355 |
|
356 |
public String getTextField() { |
357 |
return this.textFieldName; |
358 |
} |
359 |
|
360 |
public String getHeightField() { |
361 |
return this.heightFieldName; |
362 |
} |
363 |
|
364 |
public String getColorField() { |
365 |
return this.colorFieldName; |
366 |
} |
367 |
|
368 |
public void setTextField(String textFieldName) { |
369 |
this.textFieldName=textFieldName;
|
370 |
this.usedFields = null; |
371 |
} |
372 |
|
373 |
public void setRotationField(String rotationFieldName) { |
374 |
this.rotationFieldName = rotationFieldName;
|
375 |
this.usedFields = null; |
376 |
} |
377 |
|
378 |
/**
|
379 |
* Sets the field that contains the size of the text. The size is computed
|
380 |
* in meters. To use any other unit, call setUnit(int) with the scale factor from meters
|
381 |
* (for centimeters, call <b>setUnitFactor(0.01))</b>.
|
382 |
* @param heightFieldName
|
383 |
*/
|
384 |
public void setHeightField(String heightFieldName) { |
385 |
this.heightFieldName = heightFieldName;
|
386 |
this.usedFields = null; |
387 |
} |
388 |
|
389 |
|
390 |
public void setColorField(String colorFieldName) { |
391 |
this.colorFieldName = colorFieldName;
|
392 |
} |
393 |
|
394 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
395 |
PrintAttributes props) throws ReadException {
|
396 |
draw(null, g, viewPort, cancel, props);
|
397 |
} |
398 |
|
399 |
public void setUsesFixedSize(boolean b) { |
400 |
useFixedSize = b; |
401 |
this.usedFields = null; |
402 |
} |
403 |
|
404 |
public boolean usesFixedSize() { |
405 |
return useFixedSize;
|
406 |
} |
407 |
|
408 |
public double getFixedSize() { |
409 |
return fixedSize;
|
410 |
} |
411 |
|
412 |
public void setFixedSize(double fixedSize) { |
413 |
this.fixedSize = fixedSize;
|
414 |
this.usedFields = null; |
415 |
} |
416 |
|
417 |
public void setUsesFixedColor(boolean b) { |
418 |
useFixedColor = b; |
419 |
this.usedFields = null; |
420 |
} |
421 |
|
422 |
public boolean usesFixedColor() { |
423 |
return useFixedColor;
|
424 |
} |
425 |
|
426 |
public Color getFixedColor() { |
427 |
return fixedColor;
|
428 |
} |
429 |
|
430 |
public void setFixedColor(Color fixedColor) { |
431 |
this.fixedColor = fixedColor;
|
432 |
} |
433 |
|
434 |
|
435 |
public void setUnit(int unitIndex) { |
436 |
unit = unitIndex; |
437 |
|
438 |
} |
439 |
|
440 |
public int getUnit() { |
441 |
return unit;
|
442 |
} |
443 |
|
444 |
public String[] getUsedFields() { |
445 |
if (this.usedFields == null) { |
446 |
List<String> v = new ArrayList<String>(4); |
447 |
if (!this.usesFixedSize()) { |
448 |
if (getHeightField() != null) { |
449 |
v.add(getHeightField()); |
450 |
} |
451 |
} |
452 |
if (getRotationField() != null) { |
453 |
v.add(getRotationField()); |
454 |
} |
455 |
if (getTextField() != null) { |
456 |
v.add(getTextField()); |
457 |
} |
458 |
|
459 |
if (!this.usesFixedColor() && getColorField() != null) { |
460 |
v.add(getColorField()); |
461 |
} |
462 |
this.usedFields = (String[]) v.toArray(new String[v.size()]); |
463 |
} |
464 |
return this.usedFields; |
465 |
} |
466 |
|
467 |
public int getReferenceSystem() { |
468 |
return referenceSystem;
|
469 |
} |
470 |
|
471 |
public void setReferenceSystem(int referenceSystem) { |
472 |
this.referenceSystem = referenceSystem;
|
473 |
} |
474 |
|
475 |
public double toCartographicSize(ViewPort viewPort, double dpi, Geometry geom) { |
476 |
// not required here
|
477 |
throw new Error("Undefined in this context"); |
478 |
} |
479 |
|
480 |
public void setCartographicSize(double cartographicSize, Geometry geom) { |
481 |
// not required here
|
482 |
throw new Error("Undefined in this context"); |
483 |
} |
484 |
|
485 |
public double getCartographicSize(ViewPort viewPort, double dpi, Geometry geom) { |
486 |
// not required here
|
487 |
throw new Error("Undefined in this context"); |
488 |
|
489 |
} |
490 |
|
491 |
public void setLayer(FLayer layer) { |
492 |
this.layer = (FLyrVect) layer;
|
493 |
if (layer == null) { |
494 |
return;
|
495 |
} |
496 |
FeatureType type; |
497 |
try {
|
498 |
type = this.layer.getFeatureStore().getDefaultFeatureType();
|
499 |
} catch (DataException e) {
|
500 |
throw new RuntimeException(this.getClass().getName(), e); |
501 |
} |
502 |
|
503 |
if (textFieldName != null) { |
504 |
if (type.getIndex(textFieldName) < 0) { |
505 |
// FIXME exception ??
|
506 |
} |
507 |
} |
508 |
if (rotationFieldName != null) { |
509 |
if (type.getIndex(rotationFieldName) < 0) { |
510 |
// FIXME exception ??
|
511 |
} |
512 |
} |
513 |
if (heightFieldName != null) { |
514 |
if (type.getIndex(heightFieldName) < 0) { |
515 |
// FIXME exception ??
|
516 |
} |
517 |
} |
518 |
if (colorFieldName != null) { |
519 |
if (type.getIndex(colorFieldName) < 0) { |
520 |
// FIXME exception ??
|
521 |
} |
522 |
} |
523 |
} |
524 |
|
525 |
public boolean shouldDrawLabels(double scale) { |
526 |
return layer.isWithinScale(scale);
|
527 |
} |
528 |
public Color getColorFont() { |
529 |
return colorFont;
|
530 |
} |
531 |
|
532 |
public void setColorFont(Color colorFont) { |
533 |
this.colorFont = colorFont;
|
534 |
} |
535 |
|
536 |
public Font getFont() { |
537 |
return font;
|
538 |
} |
539 |
|
540 |
public void setFont(Font selFont) { |
541 |
this.font = selFont;
|
542 |
} |
543 |
|
544 |
/* (non-Javadoc)
|
545 |
* @see org.gvsig.tools.persistence.Persistent#loadFromState(org.gvsig.tools.persistence.PersistentState)
|
546 |
*/
|
547 |
public void loadFromState(PersistentState state) |
548 |
throws PersistenceException {
|
549 |
|
550 |
setTextField(state.getString(FIELD_TEXT)); |
551 |
setHeightField(state.getString(FIELD_HEIGHT)); |
552 |
setColorField(state.getString(FIELD_COLOR)); |
553 |
setRotationField(state.getString(FIELD_ROTATION)); |
554 |
setUnit(state.getInt(FIELD_UNIT)); |
555 |
setFont((Font) state.get(FIELD_FONT));
|
556 |
useFixedSize = state.getBoolean(FIELD_USE_FIXED_SIZE); |
557 |
setFixedSize(state.getDouble(FIELD_FIXED_SIZE)); |
558 |
useFixedColor = state.getBoolean(FIELD_USE_FIXED_COLOR); |
559 |
setFixedColor((Color) state.get(FIELD_FIXED_COLOR));
|
560 |
setReferenceSystem(state.getInt(FIELD_REFERENCE_SYSTEM)); |
561 |
setColorFont((Color) state.get(FIELD_COLOR_FONT));
|
562 |
setZoomConstraints((IZoomConstraints) state.get(FIELD_ZOOM_CONSTRAINTS)); |
563 |
setLabelingMethod((ILabelingMethod) state.get(FIELD_LABELING_METHOD)); |
564 |
} |
565 |
|
566 |
/* (non-Javadoc)
|
567 |
* @see org.gvsig.tools.persistence.Persistent#saveToState(org.gvsig.tools.persistence.PersistentState)
|
568 |
*/
|
569 |
public void saveToState(final PersistentState state) throws PersistenceException { |
570 |
state.set(FIELD_TEXT, getTextField()); |
571 |
state.set(FIELD_HEIGHT, getHeightField()); |
572 |
state.set(FIELD_COLOR, getColorField()); |
573 |
state.set(FIELD_ROTATION, getRotationField()); |
574 |
state.set(FIELD_UNIT, getUnit()); |
575 |
state.set(FIELD_FONT, getFont()); |
576 |
state.set(FIELD_USE_FIXED_SIZE, useFixedSize); |
577 |
state.set(FIELD_FIXED_SIZE, getFixedSize()); |
578 |
state.set(FIELD_USE_FIXED_COLOR, useFixedColor); |
579 |
state.set(FIELD_FIXED_COLOR, getFixedColor()); |
580 |
state.set(FIELD_REFERENCE_SYSTEM, getReferenceSystem()); |
581 |
state.set(FIELD_COLOR_FONT, getColorFont()); |
582 |
state.set(FIELD_ZOOM_CONSTRAINTS, getZoomConstraints()); |
583 |
state.set(FIELD_LABELING_METHOD, getLabelingMethod()); |
584 |
} |
585 |
|
586 |
public static class RegisterPersistence implements Callable { |
587 |
|
588 |
public Object call() throws Exception { |
589 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
590 |
if( manager.getDefinition(ATTR_IN_TABLE_LABELING_STRATEGY_PERSISTENCE_DEFINITION_NAME)==null ) { |
591 |
DynStruct definition = manager.addDefinition( |
592 |
AttrInTableLabelingStrategy.class, |
593 |
ATTR_IN_TABLE_LABELING_STRATEGY_PERSISTENCE_DEFINITION_NAME, |
594 |
ATTR_IN_TABLE_LABELING_STRATEGY_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
|
595 |
null,
|
596 |
null
|
597 |
); |
598 |
definition.addDynFieldString(FIELD_TEXT).setMandatory(true);
|
599 |
definition.addDynFieldString(FIELD_HEIGHT).setMandatory(false);
|
600 |
definition.addDynFieldString(FIELD_COLOR).setMandatory(false);
|
601 |
definition.addDynFieldString(FIELD_ROTATION).setMandatory(false);
|
602 |
definition.addDynFieldInt(FIELD_UNIT).setMandatory(true);
|
603 |
definition.addDynFieldObject(FIELD_FONT).setMandatory(false).setClassOfValue(Font.class); |
604 |
definition.addDynFieldBoolean(FIELD_USE_FIXED_SIZE).setMandatory(true);
|
605 |
definition.addDynFieldDouble(FIELD_FIXED_SIZE).setMandatory(false);
|
606 |
definition.addDynFieldBoolean(FIELD_USE_FIXED_COLOR).setMandatory(true);
|
607 |
definition.addDynFieldObject(FIELD_FIXED_COLOR).setMandatory(false).setClassOfValue(Color.class); |
608 |
definition.addDynFieldInt(FIELD_REFERENCE_SYSTEM).setMandatory(true);
|
609 |
definition.addDynFieldObject(FIELD_COLOR_FONT).setMandatory(false).setClassOfValue(Color.class); |
610 |
definition.addDynFieldObject(FIELD_ZOOM_CONSTRAINTS).setMandatory(false).setClassOfValue(IZoomConstraints.class);
|
611 |
definition.addDynFieldObject(FIELD_LABELING_METHOD).setMandatory(true).setClassOfValue(ILabelingMethod.class);
|
612 |
} |
613 |
return Boolean.TRUE; |
614 |
} |
615 |
|
616 |
} |
617 |
} |