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 / extrusion / DefaultVectorExtrusionLoaderParameters.java @ 761
History | View | Annotate | Download (4.36 KB)
1 |
package org.gvsig.view3d.vector.lib.impl.extrusion; |
---|---|
2 |
|
3 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
4 |
import org.gvsig.tools.ToolsLocator; |
5 |
import org.gvsig.tools.dynobject.DynStruct; |
6 |
import org.gvsig.tools.persistence.PersistenceManager; |
7 |
import org.gvsig.tools.persistence.PersistentState; |
8 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
9 |
import org.gvsig.view3d.vector.lib.api.VectorExtrusionLoaderParameters; |
10 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
11 |
import org.gvsig.view3d.vector.lib.impl.vector.DefaultVectorLoaderParameters; |
12 |
|
13 |
/**
|
14 |
*
|
15 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
|
16 |
*
|
17 |
*/
|
18 |
public class DefaultVectorExtrusionLoaderParameters extends DefaultVectorLoaderParameters |
19 |
implements VectorExtrusionLoaderParameters {
|
20 |
|
21 |
public static final String PARAMETERS_DEFINITION_NAME = "VectorExtrusionLoaderParameters"; |
22 |
public static final String PARAMETERS_DEFINITION_DESCRIPTION = "Parameters that defines vector extrusion load mode"; |
23 |
|
24 |
public static final String VECTOR_ELEVATION_MODE_FIELD_NAME = "vectorElevationMode"; |
25 |
public static final String DEFAULT_COLOR_FIELD_NAME = "defaultColor"; |
26 |
public static final String HEIGHT_FIELD_FIELD_NAME = "heightField"; |
27 |
public static final String CONSTANT_HEIGHT_FIELD_NAME = "constantHeight"; |
28 |
public static final String VERTICAL_EXAGGERATION_FIELD_NAME = "verticalExaggeration"; |
29 |
|
30 |
private String heightField; |
31 |
private double verticalExaggeration = 1; |
32 |
|
33 |
public DefaultVectorExtrusionLoaderParameters(FLayer layer) {
|
34 |
super(layer);
|
35 |
} |
36 |
|
37 |
public DefaultVectorExtrusionLoaderParameters(VectorLoaderParameters vectorParams) {
|
38 |
this.layer = vectorParams.getLayer();
|
39 |
this.vectorElevationMode = vectorParams.getVectorElevationMode();
|
40 |
this.defaultColor = vectorParams.getDefaultColor();
|
41 |
this.constantHeight = vectorParams.getConstantHeight();
|
42 |
} |
43 |
|
44 |
@Override
|
45 |
public String getName() { |
46 |
return VectorExtrusionLoaderParameters.NAME;
|
47 |
} |
48 |
|
49 |
@Override
|
50 |
public String getHeightField() { |
51 |
return this.heightField; |
52 |
} |
53 |
|
54 |
@Override
|
55 |
public void setHeightField(String heightField) { |
56 |
this.heightField = heightField;
|
57 |
} |
58 |
|
59 |
@Override
|
60 |
public double getVerticalExaggeration() { |
61 |
return this.verticalExaggeration; |
62 |
} |
63 |
|
64 |
@Override
|
65 |
public void setVerticalExaggeration(double verticalExaggeration) { |
66 |
this.verticalExaggeration = verticalExaggeration;
|
67 |
} |
68 |
|
69 |
public static void registerPersistenceDefinition() { |
70 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
71 |
DynStruct definition = manager.getDefinition(PARAMETERS_DEFINITION_NAME); |
72 |
if (definition == null) { |
73 |
definition = manager.addDefinition(DefaultVectorLoaderParameters.class, PARAMETERS_DEFINITION_NAME, |
74 |
PARAMETERS_DEFINITION_DESCRIPTION, null, null); |
75 |
|
76 |
definition.extend(manager.getDefinition(DefaultVectorLoaderParameters.PARAMETERS_DEFINITION_NAME)); |
77 |
definition.addDynFieldString(HEIGHT_FIELD_FIELD_NAME); |
78 |
definition.addDynFieldDouble(VERTICAL_EXAGGERATION_FIELD_NAME); |
79 |
} |
80 |
} |
81 |
|
82 |
@Override
|
83 |
public Object clone() throws CloneNotSupportedException { |
84 |
Object object = super.clone(); |
85 |
if (object instanceof VectorLoaderParameters) { |
86 |
VectorLoaderParameters vectorParams = (VectorLoaderParameters) object; |
87 |
VectorExtrusionLoaderParameters extrusionParams = new DefaultVectorExtrusionLoaderParameters(vectorParams);
|
88 |
extrusionParams.setHeightField(this.heightField);
|
89 |
extrusionParams.setVerticalExaggeration(this.verticalExaggeration);
|
90 |
return extrusionParams;
|
91 |
} |
92 |
throw new CloneNotSupportedException("Can not clone if superclass is not an instance of VectorLoaderParameters"); |
93 |
} |
94 |
|
95 |
@Override
|
96 |
protected void doSaveToState(PersistentState state) throws PersistenceException { |
97 |
super.doSaveToState(state);
|
98 |
state.set(HEIGHT_FIELD_FIELD_NAME, this.heightField);
|
99 |
state.set(VERTICAL_EXAGGERATION_FIELD_NAME, this.verticalExaggeration);
|
100 |
} |
101 |
|
102 |
@Override
|
103 |
protected void doLoadFromState(PersistentState state) throws PersistenceException { |
104 |
super.doLoadFromState(state);
|
105 |
this.heightField = state.getString(HEIGHT_FIELD_FIELD_NAME);
|
106 |
this.verticalExaggeration = state.getDouble(VERTICAL_EXAGGERATION_FIELD_NAME);
|
107 |
} |
108 |
} |