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 / symbol / style / AbstractStyle.java @ 34294
History | View | Annotate | Download (2.98 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style; |
23 |
|
24 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.IStyle; |
25 |
import org.gvsig.tools.ToolsLocator; |
26 |
import org.gvsig.tools.dynobject.DynStruct; |
27 |
import org.gvsig.tools.persistence.PersistenceManager; |
28 |
import org.gvsig.tools.persistence.PersistentState; |
29 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
30 |
import org.gvsig.tools.util.Callable; |
31 |
|
32 |
/**
|
33 |
* Implements the IStyle interface in order to complete the methods ot the
|
34 |
* IStyle interface that allow the users to add the description of an object or
|
35 |
* obtain it.
|
36 |
*
|
37 |
* @author 2005-2008 jaume dominguez faus - jaume.dominguez@iver.es
|
38 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
|
39 |
*/
|
40 |
|
41 |
public abstract class AbstractStyle implements IStyle { |
42 |
|
43 |
public static final String STYLE_PERSISTENCE_DEFINITION_NAME = "Style"; |
44 |
|
45 |
private static final String FIELD_DESCRIPTION = "description"; |
46 |
|
47 |
private String desc; |
48 |
|
49 |
public final void setDescription(String desc) { |
50 |
this.desc = desc;
|
51 |
} |
52 |
|
53 |
public final String getDescription() { |
54 |
return desc;
|
55 |
} |
56 |
|
57 |
public Object clone() throws CloneNotSupportedException { |
58 |
return super.clone(); |
59 |
} |
60 |
|
61 |
public void loadFromState(PersistentState state) |
62 |
throws PersistenceException {
|
63 |
setDescription(state.getString(FIELD_DESCRIPTION)); |
64 |
} |
65 |
|
66 |
public void saveToState(PersistentState state) throws PersistenceException { |
67 |
state.set(FIELD_DESCRIPTION, getDescription()); |
68 |
} |
69 |
|
70 |
public static class RegisterPersistence implements Callable { |
71 |
|
72 |
public Object call() throws Exception { |
73 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
74 |
if( manager.getDefinition(STYLE_PERSISTENCE_DEFINITION_NAME)==null ) { |
75 |
DynStruct definition = manager.addDefinition( |
76 |
AbstractStyle.class, |
77 |
STYLE_PERSISTENCE_DEFINITION_NAME, |
78 |
STYLE_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
|
79 |
null,
|
80 |
null
|
81 |
); |
82 |
|
83 |
// Description
|
84 |
definition.addDynFieldString(FIELD_DESCRIPTION); |
85 |
} |
86 |
return Boolean.TRUE; |
87 |
} |
88 |
|
89 |
} |
90 |
} |