gvsig-3d / 2.1 / trunk / org.gvsig.view3d / org.gvsig.view3d.swing / org.gvsig.view3d.swing.impl / src / main / java / org / gvsig / view3d / swing / impl / properties / DefaultMapControlProperties3D.java @ 773
History | View | Annotate | Download (9.15 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.swing.impl.properties; |
25 |
|
26 |
import java.beans.PropertyChangeListener; |
27 |
import java.beans.PropertyChangeSupport; |
28 |
|
29 |
import org.gvsig.tools.ToolsLocator; |
30 |
import org.gvsig.tools.dynobject.DynStruct; |
31 |
import org.gvsig.tools.persistence.PersistenceManager; |
32 |
import org.gvsig.tools.persistence.PersistentState; |
33 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
34 |
import org.gvsig.view3d.swing.api.properties.MapControlProperties3D; |
35 |
|
36 |
/**
|
37 |
*
|
38 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
|
39 |
*
|
40 |
*/
|
41 |
public class DefaultMapControlProperties3D implements MapControlProperties3D { |
42 |
|
43 |
private PropertyChangeSupport propertyChangeSupport; |
44 |
|
45 |
private double sphereVerticalExaggeration = 1; |
46 |
private double flatVerticalExaggeration = 1; |
47 |
private boolean autoLayerShynchornize = true; |
48 |
private boolean autoViewPortSynchronize = false; |
49 |
private boolean showBlueMarbleLayer = true; |
50 |
private boolean showNasaLandsatLayer = true; |
51 |
private boolean showDefaultElevation = true; |
52 |
private boolean anaglyphMode = false; |
53 |
|
54 |
public DefaultMapControlProperties3D() {
|
55 |
propertyChangeSupport = new PropertyChangeSupport(this); |
56 |
} |
57 |
|
58 |
public boolean getAnaglyphMode(){ |
59 |
return anaglyphMode;
|
60 |
} |
61 |
|
62 |
public boolean getAutoLayerSynchronize() { |
63 |
return autoLayerShynchornize;
|
64 |
} |
65 |
|
66 |
public boolean getAutoViewPortSynchronize() { |
67 |
return autoViewPortSynchronize;
|
68 |
} |
69 |
|
70 |
public boolean getBlueMarbleLayerVisibility() { |
71 |
return showBlueMarbleLayer;
|
72 |
} |
73 |
|
74 |
public boolean getDefaultElevationVisibility() { |
75 |
return showDefaultElevation;
|
76 |
} |
77 |
|
78 |
public double getFlatVerticalExaggeration() { |
79 |
return flatVerticalExaggeration;
|
80 |
} |
81 |
|
82 |
public boolean getNasaLandsatLayerVisibility() { |
83 |
return showNasaLandsatLayer;
|
84 |
} |
85 |
|
86 |
public double getSphereVerticalExaggeration() { |
87 |
return sphereVerticalExaggeration;
|
88 |
} |
89 |
|
90 |
public void setAnaglyphMode(boolean flag){ |
91 |
this.propertyChangeSupport.firePropertyChange(ANAGLYPH_MODE_PROPERTY_NAME,
|
92 |
this.anaglyphMode, flag);
|
93 |
this.anaglyphMode = flag;
|
94 |
} |
95 |
|
96 |
public void setAutoLayerSynchronize(boolean flag) { |
97 |
this.propertyChangeSupport.firePropertyChange(
|
98 |
AUTO_LAYER_SYNCHRONIZE_PROPERTY_NAME, autoLayerShynchornize, flag); |
99 |
this.autoLayerShynchornize = flag;
|
100 |
} |
101 |
|
102 |
public void setAutoViewPortSynchronize(boolean flag) { |
103 |
this.propertyChangeSupport.firePropertyChange(
|
104 |
AUTO_VIEWPORT_SYNCHRONIZE_PROPERTY_NAME, autoViewPortSynchronize, |
105 |
flag); |
106 |
this.autoViewPortSynchronize = flag;
|
107 |
} |
108 |
|
109 |
public void setBlueMarbleLayerVisibility(boolean visibility) { |
110 |
this.propertyChangeSupport.firePropertyChange(
|
111 |
BLUE_MARBEL_VISIBILITY_PROPERTY_NAME, showBlueMarbleLayer, |
112 |
visibility); |
113 |
this.showBlueMarbleLayer = visibility;
|
114 |
} |
115 |
|
116 |
public void setDefaultElevationVisibility(boolean visibility) { |
117 |
this.propertyChangeSupport.firePropertyChange(
|
118 |
DEFAULT_ELEVATION_VISIBILITY_PROPERTY_NAME, showDefaultElevation, |
119 |
visibility); |
120 |
this.showDefaultElevation = visibility;
|
121 |
} |
122 |
|
123 |
public void setFlatVerticalExaggeration(double value) { |
124 |
value = formatValue(value); |
125 |
this.propertyChangeSupport.firePropertyChange(
|
126 |
FLAT_VERTICAL_EXAGGERATION_PROPERTY_NAME, flatVerticalExaggeration, |
127 |
value); |
128 |
this.flatVerticalExaggeration = value;
|
129 |
} |
130 |
|
131 |
public void setNasaLandsatVisibility(boolean visibility) { |
132 |
this.propertyChangeSupport.firePropertyChange(
|
133 |
NASA_LANDSAT_VISIBILITY_PROPERTY_NAME, showNasaLandsatLayer, |
134 |
visibility); |
135 |
this.showNasaLandsatLayer = visibility;
|
136 |
} |
137 |
|
138 |
public void setSphereVerticalExaggeration(double value) { |
139 |
value = formatValue(value); |
140 |
this.propertyChangeSupport.firePropertyChange(
|
141 |
SPHERE_VERTICAL_EXAGGERATION_PROPERTY_NAME, sphereVerticalExaggeration, |
142 |
value); |
143 |
this.sphereVerticalExaggeration = value;
|
144 |
} |
145 |
|
146 |
private double formatValue(double value) { |
147 |
return (double)Math.round(value * 100d) / 100d; |
148 |
} |
149 |
|
150 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
151 |
this.propertyChangeSupport.addPropertyChangeListener(listener);
|
152 |
} |
153 |
|
154 |
public void removePropertyChangeListener(PropertyChangeListener listener) { |
155 |
this.propertyChangeSupport.removePropertyChangeListener(listener);
|
156 |
} |
157 |
|
158 |
public static void registerPersistence(){ |
159 |
// MapControl 3D properties register
|
160 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
161 |
|
162 |
DynStruct definition = |
163 |
manager |
164 |
.addDefinition(DefaultMapControlProperties3D.class, |
165 |
MapControlProperties3D.PERSISTENCE_NAME, |
166 |
"MapControl 3D properties persistence definition", null, |
167 |
null);
|
168 |
|
169 |
definition |
170 |
.addDynFieldBoolean(MapControlProperties3D.AUTO_LAYER_SYNCHRONIZE_PROPERTY_NAME); |
171 |
definition |
172 |
.addDynFieldBoolean(MapControlProperties3D.AUTO_VIEWPORT_SYNCHRONIZE_PROPERTY_NAME); |
173 |
definition |
174 |
.addDynFieldDouble(MapControlProperties3D.SPHERE_VERTICAL_EXAGGERATION_PROPERTY_NAME); |
175 |
definition |
176 |
.addDynFieldDouble(MapControlProperties3D.FLAT_VERTICAL_EXAGGERATION_PROPERTY_NAME); |
177 |
definition |
178 |
.addDynFieldBoolean(MapControlProperties3D.BLUE_MARBEL_VISIBILITY_PROPERTY_NAME); |
179 |
definition |
180 |
.addDynFieldBoolean(MapControlProperties3D.NASA_LANDSAT_VISIBILITY_PROPERTY_NAME); |
181 |
definition |
182 |
.addDynFieldBoolean(MapControlProperties3D.DEFAULT_ELEVATION_VISIBILITY_PROPERTY_NAME); |
183 |
definition |
184 |
.addDynFieldBoolean(MapControlProperties3D.ANAGLYPH_MODE_PROPERTY_NAME); |
185 |
} |
186 |
|
187 |
public void saveToState(PersistentState state) throws PersistenceException { |
188 |
|
189 |
state.set(AUTO_LAYER_SYNCHRONIZE_PROPERTY_NAME, |
190 |
getAutoLayerSynchronize()); |
191 |
state.set(AUTO_VIEWPORT_SYNCHRONIZE_PROPERTY_NAME, |
192 |
getAutoViewPortSynchronize()); |
193 |
state.set(FLAT_VERTICAL_EXAGGERATION_PROPERTY_NAME, |
194 |
getFlatVerticalExaggeration()); |
195 |
state.set(SPHERE_VERTICAL_EXAGGERATION_PROPERTY_NAME, |
196 |
getSphereVerticalExaggeration()); |
197 |
state.set(BLUE_MARBEL_VISIBILITY_PROPERTY_NAME, |
198 |
getBlueMarbleLayerVisibility()); |
199 |
state.set(NASA_LANDSAT_VISIBILITY_PROPERTY_NAME, |
200 |
getNasaLandsatLayerVisibility()); |
201 |
state.set(DEFAULT_ELEVATION_VISIBILITY_PROPERTY_NAME, |
202 |
getDefaultElevationVisibility()); |
203 |
state.set(ANAGLYPH_MODE_PROPERTY_NAME, getAnaglyphMode()); |
204 |
} |
205 |
|
206 |
public void loadFromState(PersistentState state) |
207 |
throws PersistenceException {
|
208 |
|
209 |
if(state.hasValue(AUTO_LAYER_SYNCHRONIZE_PROPERTY_NAME)){
|
210 |
setAutoLayerSynchronize(state |
211 |
.getBoolean(AUTO_LAYER_SYNCHRONIZE_PROPERTY_NAME)); |
212 |
} |
213 |
if(state.hasValue(AUTO_VIEWPORT_SYNCHRONIZE_PROPERTY_NAME)){
|
214 |
setAutoViewPortSynchronize(state |
215 |
.getBoolean(AUTO_VIEWPORT_SYNCHRONIZE_PROPERTY_NAME)); |
216 |
} |
217 |
if(state.hasValue(SPHERE_VERTICAL_EXAGGERATION_PROPERTY_NAME)){
|
218 |
setSphereVerticalExaggeration(state |
219 |
.getDouble(SPHERE_VERTICAL_EXAGGERATION_PROPERTY_NAME)); |
220 |
} |
221 |
if(state.hasValue(FLAT_VERTICAL_EXAGGERATION_PROPERTY_NAME)){
|
222 |
setFlatVerticalExaggeration(state |
223 |
.getDouble(FLAT_VERTICAL_EXAGGERATION_PROPERTY_NAME)); |
224 |
} |
225 |
if(state.hasValue(BLUE_MARBEL_VISIBILITY_PROPERTY_NAME)){
|
226 |
setBlueMarbleLayerVisibility(state |
227 |
.getBoolean(BLUE_MARBEL_VISIBILITY_PROPERTY_NAME)); |
228 |
} |
229 |
if(state.hasValue(NASA_LANDSAT_VISIBILITY_PROPERTY_NAME)){
|
230 |
setNasaLandsatVisibility(state |
231 |
.getBoolean(NASA_LANDSAT_VISIBILITY_PROPERTY_NAME)); |
232 |
} |
233 |
if(state.hasValue(DEFAULT_ELEVATION_VISIBILITY_PROPERTY_NAME)){
|
234 |
setDefaultElevationVisibility(state |
235 |
.getBoolean(DEFAULT_ELEVATION_VISIBILITY_PROPERTY_NAME)); |
236 |
} |
237 |
if(state.hasValue(ANAGLYPH_MODE_PROPERTY_NAME)){
|
238 |
setAnaglyphMode(state.getBoolean(ANAGLYPH_MODE_PROPERTY_NAME)); |
239 |
} |
240 |
} |
241 |
} |