gvsig-3d / 2.1 / trunk / org.gvsig.view3d / org.gvsig.view3d.lib / org.gvsig.view3d.lib.impl / src / main / java / org / gvsig / view3d / lib / impl / properties / DefaultMapControlProperties3D.java @ 501
History | View | Annotate | Download (6.73 KB)
1 |
package org.gvsig.view3d.lib.impl.properties; |
---|---|
2 |
|
3 |
import java.beans.PropertyChangeListener; |
4 |
import java.beans.PropertyChangeSupport; |
5 |
|
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.properties.MapControlProperties3D; |
12 |
|
13 |
public class DefaultMapControlProperties3D implements MapControlProperties3D { |
14 |
|
15 |
private PropertyChangeSupport propertyChangeSupport; |
16 |
|
17 |
private double sphereVerticalExaggeration = 1; |
18 |
private double flatVerticalExaggeration = 1; |
19 |
private boolean autoLayerShynchornize = true; |
20 |
private boolean autoViewPortSynchronize = false; |
21 |
private boolean showBlueMarbleLayer = true; |
22 |
private boolean showNasaLandsatLayer = true; |
23 |
private boolean showDefaultElevation = true; |
24 |
|
25 |
public DefaultMapControlProperties3D() {
|
26 |
propertyChangeSupport = new PropertyChangeSupport(this); |
27 |
} |
28 |
|
29 |
public boolean getAutoLayerSynchronize() { |
30 |
return autoLayerShynchornize;
|
31 |
} |
32 |
|
33 |
public boolean getAutoViewSynchronize() { |
34 |
return autoViewPortSynchronize;
|
35 |
} |
36 |
|
37 |
public boolean getBlueMarbleLayerVisibility() { |
38 |
return showBlueMarbleLayer;
|
39 |
} |
40 |
|
41 |
public boolean getDefaultElevationVisibility() { |
42 |
return showDefaultElevation;
|
43 |
} |
44 |
|
45 |
public double getFlatVerticalExaggeration() { |
46 |
return flatVerticalExaggeration;
|
47 |
} |
48 |
|
49 |
public boolean getNasaLandsatLayerVisibility() { |
50 |
return showNasaLandsatLayer;
|
51 |
} |
52 |
|
53 |
public double getSphereVerticalExaggeration() { |
54 |
return sphereVerticalExaggeration;
|
55 |
} |
56 |
|
57 |
public void setAutoLayerSynchronize(boolean flag) { |
58 |
this.propertyChangeSupport.firePropertyChange(
|
59 |
AUTO_LAYER_SYNCHRONIZE_PROPERTY_NAME, autoLayerShynchornize, flag); |
60 |
this.autoLayerShynchornize = flag;
|
61 |
} |
62 |
|
63 |
public void setAutoViewPortSynchronize(boolean flag) { |
64 |
this.propertyChangeSupport.firePropertyChange(
|
65 |
AUTO_VIEWPORT_SYNCHRONIZE_PROPERTY_NAME, autoViewPortSynchronize, |
66 |
flag); |
67 |
this.autoViewPortSynchronize = flag;
|
68 |
} |
69 |
|
70 |
public void setBlueMarbleLayerVisibility(boolean visibility) { |
71 |
this.propertyChangeSupport.firePropertyChange(
|
72 |
BLUE_MARBEL_VISIBILITY_PROPERTY_NAME, showBlueMarbleLayer, |
73 |
visibility); |
74 |
this.showBlueMarbleLayer = visibility;
|
75 |
} |
76 |
|
77 |
public void setDefaultElevationVisibility(boolean visibility) { |
78 |
this.propertyChangeSupport.firePropertyChange(
|
79 |
DEFAULT_ELEVATION_VISIBILITY_PROPERTY_NAME, showDefaultElevation, |
80 |
visibility); |
81 |
this.showDefaultElevation = visibility;
|
82 |
} |
83 |
|
84 |
public void setFlatVerticalExaggeration(double value) { |
85 |
this.propertyChangeSupport.firePropertyChange(
|
86 |
FLAT_VERTICAL_EXAGGERATION_PROPERTY_NAME, flatVerticalExaggeration, |
87 |
value); |
88 |
this.flatVerticalExaggeration = value;
|
89 |
} |
90 |
|
91 |
public void setNasaLandsatVisibility(boolean visibility) { |
92 |
this.propertyChangeSupport.firePropertyChange(
|
93 |
NASA_LANDSAT_VISIBILITY_PROPERTY_NAME, showNasaLandsatLayer, |
94 |
visibility); |
95 |
this.showNasaLandsatLayer = visibility;
|
96 |
} |
97 |
|
98 |
public void setSphereVerticalExaggeration(double value) { |
99 |
this.propertyChangeSupport.firePropertyChange(
|
100 |
SPHERE_VERTICAL_EXAGGERATION_PROPERTY_NAME, sphereVerticalExaggeration, |
101 |
value); |
102 |
this.sphereVerticalExaggeration = value;
|
103 |
} |
104 |
|
105 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
106 |
this.propertyChangeSupport.addPropertyChangeListener(listener);
|
107 |
} |
108 |
|
109 |
public void removePropertyChangeListener(PropertyChangeListener listener) { |
110 |
this.propertyChangeSupport.removePropertyChangeListener(listener);
|
111 |
} |
112 |
|
113 |
public static void registerPersistence(){ |
114 |
// MapControl 3D properties register
|
115 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
116 |
|
117 |
DynStruct definition = |
118 |
manager |
119 |
.addDefinition(DefaultMapControlProperties3D.class, |
120 |
MapControlProperties3D.PERSISTENCE_NAME, |
121 |
"MapControl 3D properties persistence definition", null, |
122 |
null);
|
123 |
|
124 |
definition |
125 |
.addDynFieldBoolean(MapControlProperties3D.AUTO_LAYER_SYNCHRONIZE_PROPERTY_NAME); |
126 |
definition |
127 |
.addDynFieldBoolean(MapControlProperties3D.AUTO_VIEWPORT_SYNCHRONIZE_PROPERTY_NAME); |
128 |
definition |
129 |
.addDynFieldDouble(MapControlProperties3D.SPHERE_VERTICAL_EXAGGERATION_PROPERTY_NAME); |
130 |
definition |
131 |
.addDynFieldDouble(MapControlProperties3D.FLAT_VERTICAL_EXAGGERATION_PROPERTY_NAME); |
132 |
definition |
133 |
.addDynFieldBoolean(MapControlProperties3D.BLUE_MARBEL_VISIBILITY_PROPERTY_NAME); |
134 |
definition |
135 |
.addDynFieldBoolean(MapControlProperties3D.NASA_LANDSAT_VISIBILITY_PROPERTY_NAME); |
136 |
definition |
137 |
.addDynFieldBoolean(MapControlProperties3D.DEFAULT_ELEVATION_VISIBILITY_PROPERTY_NAME); |
138 |
} |
139 |
|
140 |
public void saveToState(PersistentState state) throws PersistenceException { |
141 |
|
142 |
state.set(AUTO_LAYER_SYNCHRONIZE_PROPERTY_NAME, |
143 |
getAutoLayerSynchronize()); |
144 |
state.set(AUTO_VIEWPORT_SYNCHRONIZE_PROPERTY_NAME, |
145 |
getAutoViewSynchronize()); |
146 |
state.set(FLAT_VERTICAL_EXAGGERATION_PROPERTY_NAME, |
147 |
getFlatVerticalExaggeration()); |
148 |
state.set(SPHERE_VERTICAL_EXAGGERATION_PROPERTY_NAME, |
149 |
getSphereVerticalExaggeration()); |
150 |
state.set(BLUE_MARBEL_VISIBILITY_PROPERTY_NAME, |
151 |
getBlueMarbleLayerVisibility()); |
152 |
state.set(NASA_LANDSAT_VISIBILITY_PROPERTY_NAME, |
153 |
getNasaLandsatLayerVisibility()); |
154 |
state.set(DEFAULT_ELEVATION_VISIBILITY_PROPERTY_NAME, |
155 |
getDefaultElevationVisibility()); |
156 |
} |
157 |
|
158 |
public void loadFromState(PersistentState state) |
159 |
throws PersistenceException {
|
160 |
|
161 |
setAutoLayerSynchronize(state |
162 |
.getBoolean(AUTO_LAYER_SYNCHRONIZE_PROPERTY_NAME)); |
163 |
setAutoViewPortSynchronize(state |
164 |
.getBoolean(AUTO_VIEWPORT_SYNCHRONIZE_PROPERTY_NAME)); |
165 |
setSphereVerticalExaggeration(state |
166 |
.getDouble(SPHERE_VERTICAL_EXAGGERATION_PROPERTY_NAME)); |
167 |
setFlatVerticalExaggeration(state |
168 |
.getDouble(FLAT_VERTICAL_EXAGGERATION_PROPERTY_NAME)); |
169 |
setBlueMarbleLayerVisibility(state |
170 |
.getBoolean(BLUE_MARBEL_VISIBILITY_PROPERTY_NAME)); |
171 |
setNasaLandsatVisibility(state |
172 |
.getBoolean(NASA_LANDSAT_VISIBILITY_PROPERTY_NAME)); |
173 |
setDefaultElevationVisibility(state |
174 |
.getBoolean(DEFAULT_ELEVATION_VISIBILITY_PROPERTY_NAME)); |
175 |
|
176 |
} |
177 |
|
178 |
} |