svn-gvsig-desktop / 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 @ 45525
History | View | Annotate | Download (3.25 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2021 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style; |
25 |
|
26 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.IStyle; |
27 |
import org.gvsig.tools.ToolsLocator; |
28 |
import org.gvsig.tools.dynobject.DynStruct; |
29 |
import org.gvsig.tools.persistence.PersistenceManager; |
30 |
import org.gvsig.tools.persistence.PersistentState; |
31 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
32 |
import org.gvsig.tools.util.Callable; |
33 |
|
34 |
/**
|
35 |
* Implements the IStyle interface in order to complete the methods ot the
|
36 |
* IStyle interface that allow the users to add the description of an object or
|
37 |
* obtain it.
|
38 |
*
|
39 |
* @author gvSIG team
|
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 |
@Override
|
50 |
public final void setDescription(String desc) { |
51 |
this.desc = desc;
|
52 |
} |
53 |
|
54 |
@Override
|
55 |
public final String getDescription() { |
56 |
return desc;
|
57 |
} |
58 |
|
59 |
@Override
|
60 |
public Object clone() throws CloneNotSupportedException { |
61 |
return super.clone(); |
62 |
} |
63 |
|
64 |
@Override
|
65 |
public void loadFromState(PersistentState state) |
66 |
throws PersistenceException {
|
67 |
setDescription(state.getString(FIELD_DESCRIPTION)); |
68 |
} |
69 |
|
70 |
@Override
|
71 |
public void saveToState(PersistentState state) throws PersistenceException { |
72 |
state.set(FIELD_DESCRIPTION, getDescription()); |
73 |
} |
74 |
|
75 |
public static class RegisterPersistence implements Callable { |
76 |
|
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 |
} |