50 |
50 |
import org.gvsig.tools.persistence.PersistenceManager;
|
51 |
51 |
import org.gvsig.tools.persistence.PersistentState;
|
52 |
52 |
import org.gvsig.tools.persistence.exception.PersistenceException;
|
|
53 |
import org.gvsig.tools.util.Callable;
|
53 |
54 |
import org.slf4j.Logger;
|
54 |
55 |
import org.slf4j.LoggerFactory;
|
55 |
56 |
|
... | ... | |
325 |
326 |
return background;
|
326 |
327 |
}
|
327 |
328 |
|
328 |
|
public void setBackgroundFileStyle(IBackgroundFileStyle background) {
|
329 |
|
this.background = background;
|
|
329 |
public void setBackgroundFileStyle(IBackgroundFileStyle bg) {
|
|
330 |
this.background = bg;
|
330 |
331 |
}
|
331 |
332 |
|
332 |
|
|
333 |
|
public static void registerPersistent() {
|
334 |
|
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager();
|
335 |
|
DynStruct definition = persistenceManager.getDefinition(
|
|
333 |
public static class RegisterPersistence implements Callable {
|
|
334 |
|
|
335 |
public Object call() throws Exception {
|
|
336 |
|
|
337 |
PersistenceManager manager = ToolsLocator.getPersistenceManager();
|
|
338 |
DynStruct definition = manager.getDefinition(
|
336 |
339 |
SIMPLE_LABEL_STYLE_PERSISTENCE_NAME);
|
337 |
340 |
|
338 |
|
if (definition == null){
|
339 |
|
definition = persistenceManager.addDefinition(
|
|
341 |
if (definition == null){
|
|
342 |
definition = manager.addDefinition(
|
340 |
343 |
SimpleLabelStyle.class,
|
341 |
344 |
SIMPLE_LABEL_STYLE_PERSISTENCE_NAME,
|
342 |
345 |
SIMPLE_LABEL_STYLE_PERSISTENCE_NAME + " Persistent definition",
|
343 |
|
null,
|
344 |
|
null
|
345 |
|
);
|
346 |
|
|
347 |
|
definition.extend(AbstractStyle.STYLE_PERSISTENCE_DEFINITION_NAME);
|
348 |
|
|
349 |
|
definition.addDynFieldObject("markerPoint").setClassOfValue(Point2D.class)
|
350 |
|
.setMandatory(true);
|
351 |
|
definition.addDynFieldList("textFieldAreas").setClassOfItems(Rectangle2D.class)
|
352 |
|
.setMandatory(true);
|
353 |
|
definition.addDynFieldObject("background").setClassOfValue(IBackgroundFileStyle.class)
|
354 |
|
.setMandatory(true);
|
355 |
|
definition.addDynFieldObject("defaultSize").setClassOfValue(Dimension.class)
|
356 |
|
.setMandatory(true);
|
357 |
|
definition.addDynFieldObject("size").setClassOfValue(Dimension.class)
|
358 |
|
.setMandatory(true);
|
359 |
|
}
|
|
346 |
null,
|
|
347 |
null);
|
|
348 |
definition.extend(manager.getDefinition(
|
|
349 |
AbstractStyle.STYLE_PERSISTENCE_DEFINITION_NAME));
|
|
350 |
definition.addDynFieldObject("markerPoint").setClassOfValue(Point2D.class)
|
|
351 |
.setMandatory(true);
|
|
352 |
definition.addDynFieldList("textFieldAreas").setClassOfItems(Rectangle2D.class)
|
|
353 |
.setMandatory(true);
|
|
354 |
definition.addDynFieldObject("background").setClassOfValue(IBackgroundFileStyle.class)
|
|
355 |
.setMandatory(false);
|
|
356 |
definition.addDynFieldObject("defaultSize").setClassOfValue(Dimension.class)
|
|
357 |
.setMandatory(true);
|
|
358 |
definition.addDynFieldObject("size").setClassOfValue(Dimension.class)
|
|
359 |
.setMandatory(true);
|
|
360 |
}
|
|
361 |
return Boolean.TRUE;
|
|
362 |
}
|
360 |
363 |
}
|
361 |
364 |
|
|
365 |
|
362 |
366 |
public void loadFromState(PersistentState state)
|
363 |
367 |
throws PersistenceException {
|
364 |
368 |
|
... | ... | |
366 |
370 |
|
367 |
371 |
this.markerPoint = (Point2D) state.get("markerPoint");
|
368 |
372 |
this.textFieldAreas = (List<Rectangle2D>) state.get("textFieldAreas");
|
369 |
|
this.background = (IBackgroundFileStyle) state.get("background");
|
|
373 |
|
|
374 |
if (state.hasValue("background")) {
|
|
375 |
this.background = (IBackgroundFileStyle) state.get("background");
|
|
376 |
}
|
|
377 |
|
370 |
378 |
this.defaultSize = (Dimension) state.get("defaultSize");
|
371 |
379 |
this.sz = (Dimension) state.get("size");
|
372 |
380 |
}
|
... | ... | |
377 |
385 |
|
378 |
386 |
state.set("markerPoint", this.markerPoint);
|
379 |
387 |
state.set("textFieldAreas", this.textFieldAreas);
|
380 |
|
state.set("background", this.background);
|
|
388 |
|
|
389 |
if (this.background != null) {
|
|
390 |
state.set("background", this.background);
|
|
391 |
}
|
|
392 |
|
381 |
393 |
state.set("defaultSize", this.defaultSize);
|
382 |
|
state.set("size", this.sz);
|
|
394 |
state.set("size", this.getSize());
|
383 |
395 |
}
|
384 |
396 |
}
|