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 @ 773
History | View | Annotate | Download (5.47 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright ? 2007-2017 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 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 |
* 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.view3d.vector.lib.impl.extrusion; |
25 |
|
26 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
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.view3d.vector.lib.api.VectorExtrusionLoaderParameters; |
33 |
import org.gvsig.view3d.vector.lib.api.VectorLoaderParameters; |
34 |
import org.gvsig.view3d.vector.lib.impl.vector.DefaultVectorLoaderParameters; |
35 |
|
36 |
/**
|
37 |
*
|
38 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
|
39 |
*
|
40 |
*/
|
41 |
public class DefaultVectorExtrusionLoaderParameters extends DefaultVectorLoaderParameters |
42 |
implements VectorExtrusionLoaderParameters {
|
43 |
|
44 |
public static final String PARAMETERS_DEFINITION_NAME = "VectorExtrusionLoaderParameters"; |
45 |
public static final String PARAMETERS_DEFINITION_DESCRIPTION = "Parameters that defines vector extrusion load mode"; |
46 |
|
47 |
public static final String VECTOR_ELEVATION_MODE_FIELD_NAME = "vectorElevationMode"; |
48 |
public static final String DEFAULT_COLOR_FIELD_NAME = "defaultColor"; |
49 |
public static final String HEIGHT_FIELD_FIELD_NAME = "heightField"; |
50 |
public static final String CONSTANT_HEIGHT_FIELD_NAME = "constantHeight"; |
51 |
public static final String VERTICAL_EXAGGERATION_FIELD_NAME = "verticalExaggeration"; |
52 |
|
53 |
private String heightField; |
54 |
private double verticalExaggeration = 1; |
55 |
|
56 |
public DefaultVectorExtrusionLoaderParameters(){
|
57 |
|
58 |
} |
59 |
|
60 |
public DefaultVectorExtrusionLoaderParameters(FLayer layer) {
|
61 |
super(layer);
|
62 |
} |
63 |
|
64 |
public DefaultVectorExtrusionLoaderParameters(VectorLoaderParameters vectorParams) {
|
65 |
this.layer = vectorParams.getLayer();
|
66 |
this.vectorElevationMode = vectorParams.getVectorElevationMode();
|
67 |
this.defaultColor = vectorParams.getDefaultColor();
|
68 |
this.constantHeight = vectorParams.getConstantHeight();
|
69 |
} |
70 |
|
71 |
@Override
|
72 |
public String getName() { |
73 |
return VectorExtrusionLoaderParameters.NAME;
|
74 |
} |
75 |
|
76 |
@Override
|
77 |
public String getHeightField() { |
78 |
return this.heightField; |
79 |
} |
80 |
|
81 |
@Override
|
82 |
public void setHeightField(String heightField) { |
83 |
this.heightField = heightField;
|
84 |
} |
85 |
|
86 |
@Override
|
87 |
public double getVerticalExaggeration() { |
88 |
return this.verticalExaggeration; |
89 |
} |
90 |
|
91 |
@Override
|
92 |
public void setVerticalExaggeration(double verticalExaggeration) { |
93 |
this.verticalExaggeration = verticalExaggeration;
|
94 |
} |
95 |
|
96 |
public static void registerPersistenceDefinition() { |
97 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
98 |
DynStruct definition = manager.getDefinition(PARAMETERS_DEFINITION_NAME); |
99 |
if (definition == null) { |
100 |
definition = manager.addDefinition(DefaultVectorLoaderParameters.class, PARAMETERS_DEFINITION_NAME, |
101 |
PARAMETERS_DEFINITION_DESCRIPTION, null, null); |
102 |
|
103 |
definition.extend(manager.getDefinition(DefaultVectorLoaderParameters.PARAMETERS_DEFINITION_NAME)); |
104 |
definition.addDynFieldString(HEIGHT_FIELD_FIELD_NAME); |
105 |
definition.addDynFieldDouble(VERTICAL_EXAGGERATION_FIELD_NAME); |
106 |
definition.addDynFieldObject(LAYER_FIELD_NAME).setClassOfValue(FLayer.class).setMandatory(true);
|
107 |
} |
108 |
} |
109 |
|
110 |
@Override
|
111 |
public Object clone() throws CloneNotSupportedException { |
112 |
Object object = super.clone(); |
113 |
if (object instanceof VectorLoaderParameters) { |
114 |
VectorLoaderParameters vectorParams = (VectorLoaderParameters) object; |
115 |
VectorExtrusionLoaderParameters extrusionParams = new DefaultVectorExtrusionLoaderParameters(vectorParams);
|
116 |
extrusionParams.setHeightField(this.heightField);
|
117 |
extrusionParams.setVerticalExaggeration(this.verticalExaggeration);
|
118 |
return extrusionParams;
|
119 |
} |
120 |
throw new CloneNotSupportedException("Can not clone if superclass is not an instance of VectorLoaderParameters"); |
121 |
} |
122 |
|
123 |
@Override
|
124 |
protected void doSaveToState(PersistentState state) throws PersistenceException { |
125 |
super.doSaveToState(state);
|
126 |
state.set(HEIGHT_FIELD_FIELD_NAME, this.heightField);
|
127 |
state.set(VERTICAL_EXAGGERATION_FIELD_NAME, this.verticalExaggeration);
|
128 |
} |
129 |
|
130 |
@Override
|
131 |
protected void doLoadFromState(PersistentState state) throws PersistenceException { |
132 |
super.doLoadFromState(state);
|
133 |
this.heightField = state.getString(HEIGHT_FIELD_FIELD_NAME);
|
134 |
this.verticalExaggeration = state.getDouble(VERTICAL_EXAGGERATION_FIELD_NAME);
|
135 |
} |
136 |
} |