Revision 45525

View differences:

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/style/AbstractStyle.java
1 1
/**
2 2
 * gvSIG. Desktop Geographic Information System.
3 3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
4
 * Copyright (C) 2007-2021 gvSIG Association.
5 5
 *
6 6
 * This program is free software; you can redistribute it and/or
7 7
 * modify it under the terms of the GNU General Public License
......
35 35
 * Implements the IStyle interface in order to complete the methods ot the
36 36
 * IStyle interface that allow the users to add the description of an object or
37 37
 * obtain it.
38
 * 
39
 * @author 2005-2008 jaume dominguez faus - jaume.dominguez@iver.es
40
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
38
 *
39
 * @author gvSIG team
41 40
 */
42

  
43 41
public abstract class AbstractStyle implements IStyle {
44 42

  
45
	public static final String STYLE_PERSISTENCE_DEFINITION_NAME = "Style";
43
    public static final String STYLE_PERSISTENCE_DEFINITION_NAME = "Style";
46 44

  
47
	private static final String FIELD_DESCRIPTION = "description";
45
    private static final String FIELD_DESCRIPTION = "description";
48 46

  
49
	private String desc;
47
    private String desc;
50 48

  
51
	public final void setDescription(String desc) {
52
		this.desc = desc;
53
	}
49
    @Override
50
    public final void setDescription(String desc) {
51
        this.desc = desc;
52
    }
54 53

  
55
	public final String getDescription() {
56
		return desc;
57
	}
58
	
59
	public Object clone() throws CloneNotSupportedException {
60
		return super.clone();
61
	}
54
    @Override
55
    public final String getDescription() {
56
        return desc;
57
    }
62 58

  
63
	public void loadFromState(PersistentState state)
64
			throws PersistenceException {
65
		setDescription(state.getString(FIELD_DESCRIPTION));
66
	}
59
    @Override
60
    public Object clone() throws CloneNotSupportedException {
61
        return super.clone();
62
    }
67 63

  
68
	public void saveToState(PersistentState state) throws PersistenceException {
69
		state.set(FIELD_DESCRIPTION, getDescription());
70
	}
64
    @Override
65
    public void loadFromState(PersistentState state)
66
            throws PersistenceException {
67
        setDescription(state.getString(FIELD_DESCRIPTION));
68
    }
71 69

  
72
	public static class RegisterPersistence implements Callable {
70
    @Override
71
    public void saveToState(PersistentState state) throws PersistenceException {
72
        state.set(FIELD_DESCRIPTION, getDescription());
73
    }
73 74

  
74
		public Object call() throws Exception {
75
			PersistenceManager manager = ToolsLocator.getPersistenceManager();
76
			if( manager.getDefinition(STYLE_PERSISTENCE_DEFINITION_NAME)==null ) {
77
				DynStruct definition = manager.addDefinition(
78
						AbstractStyle.class,
79
						STYLE_PERSISTENCE_DEFINITION_NAME,
80
						STYLE_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
81
						null, 
82
						null
83
				);
75
    public static class RegisterPersistence implements Callable {
84 76

  
85
				// Description
86
				definition.addDynFieldString(FIELD_DESCRIPTION);
87
			}
88
			return Boolean.TRUE;
89
		}
90
		
91
	}
92
}
77
        @Override
78
        public Object call() throws Exception {
79
            PersistenceManager manager = ToolsLocator.getPersistenceManager();
80
            if (manager.getDefinition(STYLE_PERSISTENCE_DEFINITION_NAME) == null) {
81
                DynStruct definition = manager.addDefinition(
82
                        AbstractStyle.class,
83
                        STYLE_PERSISTENCE_DEFINITION_NAME,
84
                        STYLE_PERSISTENCE_DEFINITION_NAME + " Persistence definition",
85
                        null,
86
                        null
87
                );
88

  
89
                // Description
90
                definition.addDynFieldString(FIELD_DESCRIPTION);
91
            }
92
            return true;
93
        }
94

  
95
    }
96
}

Also available in: Unified diff