gvsig-3d / 2.1 / trunk / org.gvsig.view3d / org.gvsig.view3d.vector / org.gvsig.view3d.vector.lib / org.gvsig.view3d.vector.lib.impl / src / main / java / org / gvsig / view3d / vector / lib / impl / vector / DefaultVectorLoaderParameters.java @ 761
History | View | Annotate | Download (3.96 KB)
1 |
package org.gvsig.view3d.vector.lib.impl.vector; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
|
5 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
6 |
import org.gvsig.tools.ToolsLocator; |
7 |
import org.gvsig.tools.dynobject.DynStruct; |
8 |
import org.gvsig.tools.persistence.PersistenceManager; |
9 |
import org.gvsig.tools.persistence.PersistentState; |
10 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
11 |
import org.gvsig.view3d.lib.api.loader.AbstractLoaderParameters; |
12 |
import org.gvsig.view3d.vector.lib.api.VectorElevationMode; |
13 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
14 |
|
15 |
/**
|
16 |
*
|
17 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
|
18 |
*
|
19 |
*/
|
20 |
public class DefaultVectorLoaderParameters extends AbstractLoaderParameters implements VectorLoaderParameters { |
21 |
|
22 |
public static final String PARAMETERS_DEFINITION_NAME = "VectorLoaderParameters"; |
23 |
public static final String PARAMETERS_DEFINITION_DESCRIPTION = "Parameters that defines vector load mode"; |
24 |
|
25 |
public static final String VECTOR_ELEVATION_MODEL_FIELD_NAME = "vectorElevationModel"; |
26 |
public static final String DEFAULT_COLOR_FIELD_NAME = "defaultColor"; |
27 |
public static final String CONSTANT_HEIGHT_FIELD_NAME = "constantHeight"; |
28 |
|
29 |
protected VectorElevationMode vectorElevationMode;
|
30 |
protected Color defaultColor; |
31 |
protected double constantHeight; |
32 |
|
33 |
public DefaultVectorLoaderParameters(FLayer layer) {
|
34 |
super(layer);
|
35 |
} |
36 |
|
37 |
protected DefaultVectorLoaderParameters() {
|
38 |
// Do nothing
|
39 |
} |
40 |
|
41 |
@Override
|
42 |
public String getName() { |
43 |
return VectorLoaderParameters.NAME;
|
44 |
} |
45 |
|
46 |
@Override
|
47 |
public VectorElevationMode getVectorElevationMode() {
|
48 |
return this.vectorElevationMode; |
49 |
} |
50 |
|
51 |
@Override
|
52 |
public void setVectorElevationMode(VectorElevationMode vectorElevationMode) { |
53 |
this.vectorElevationMode = vectorElevationMode;
|
54 |
} |
55 |
|
56 |
@Override
|
57 |
public Color getDefaultColor() { |
58 |
return this.defaultColor; |
59 |
} |
60 |
|
61 |
@Override
|
62 |
public void setDefaultColor(Color color) { |
63 |
this.defaultColor = color;
|
64 |
} |
65 |
|
66 |
@Override
|
67 |
public Double getConstantHeight() { |
68 |
return this.constantHeight; |
69 |
} |
70 |
|
71 |
@Override
|
72 |
public void setConstantHeight(Double height) { |
73 |
this.constantHeight = height;
|
74 |
} |
75 |
|
76 |
public static void registerPersistenceDefinition() { |
77 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
78 |
DynStruct definition = manager.getDefinition(PARAMETERS_DEFINITION_NAME); |
79 |
if (definition == null) { |
80 |
definition = manager.addDefinition(DefaultVectorLoaderParameters.class, PARAMETERS_DEFINITION_NAME, |
81 |
PARAMETERS_DEFINITION_DESCRIPTION, null, null); |
82 |
|
83 |
definition.addDynFieldObject(VECTOR_ELEVATION_MODEL_FIELD_NAME); |
84 |
definition.addDynFieldObject(DEFAULT_COLOR_FIELD_NAME); |
85 |
definition.addDynFieldDouble(CONSTANT_HEIGHT_FIELD_NAME); |
86 |
} |
87 |
} |
88 |
|
89 |
@Override
|
90 |
public Object clone() throws CloneNotSupportedException { |
91 |
|
92 |
VectorLoaderParameters newParameters = new DefaultVectorLoaderParameters();
|
93 |
newParameters.setVectorElevationMode(this.getVectorElevationMode());
|
94 |
newParameters.setDefaultColor(this.getDefaultColor());
|
95 |
newParameters.setConstantHeight(this.getConstantHeight());
|
96 |
newParameters.setLayer(this.getLayer());
|
97 |
return newParameters;
|
98 |
} |
99 |
|
100 |
@Override
|
101 |
protected void doSaveToState(PersistentState state) throws PersistenceException { |
102 |
state.set(VECTOR_ELEVATION_MODEL_FIELD_NAME, this.vectorElevationMode);
|
103 |
state.set(DEFAULT_COLOR_FIELD_NAME, this.defaultColor);
|
104 |
state.set(CONSTANT_HEIGHT_FIELD_NAME, this.constantHeight);
|
105 |
} |
106 |
|
107 |
@Override
|
108 |
protected void doLoadFromState(PersistentState state) throws PersistenceException { |
109 |
this.vectorElevationMode = (VectorElevationMode) state.get(VECTOR_ELEVATION_MODEL_FIELD_NAME);
|
110 |
this.defaultColor = (Color) state.get(DEFAULT_COLOR_FIELD_NAME); |
111 |
this.constantHeight = state.getDouble(CONSTANT_HEIGHT_FIELD_NAME);
|
112 |
} |
113 |
} |