gvsig-3d / 2.1 / trunk / org.gvsig.view3d / org.gvsig.view3d.app / org.gvsig.view3d.app.common / src / main / java / org / gvsig / view3d / app / properties / General3DPreferencePage.java @ 496
History | View | Annotate | Download (7.36 KB)
1 |
package org.gvsig.view3d.app.properties; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.beans.PropertyChangeEvent; |
5 |
import java.beans.PropertyChangeListener; |
6 |
|
7 |
import javax.swing.ImageIcon; |
8 |
import javax.swing.JPanel; |
9 |
|
10 |
import org.gvsig.andami.IconThemeHelper; |
11 |
import org.gvsig.andami.PluginServices; |
12 |
import org.gvsig.andami.PluginsLocator; |
13 |
import org.gvsig.andami.PluginsManager; |
14 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
15 |
import org.gvsig.andami.preferences.StoreException; |
16 |
import org.gvsig.tools.ToolsLocator; |
17 |
import org.gvsig.tools.dynobject.DynObject; |
18 |
import org.gvsig.tools.i18n.I18nManager; |
19 |
import org.gvsig.view3d.lib.api.View3DLocator; |
20 |
import org.gvsig.view3d.lib.api.View3DManager; |
21 |
import org.gvsig.view3d.lib.api.properties.GeneralProperties3D; |
22 |
import org.gvsig.view3d.swing.api.View3DSwingLocator; |
23 |
import org.gvsig.view3d.swing.api.View3DSwingManager; |
24 |
import org.gvsig.view3d.swing.api.properties.GeneralProperties3DPanel; |
25 |
|
26 |
public class General3DPreferencePage extends AbstractPreferencePage { |
27 |
|
28 |
private static final long serialVersionUID = -3384416698766077019L; |
29 |
|
30 |
public static final String ID = General3DPreferencePage.class.getName(); |
31 |
|
32 |
private GeneralProperties3DPanel propertiesPanel;
|
33 |
private DynObject pluginProperties;
|
34 |
private PluginServices plugin;
|
35 |
private boolean valueChanged = false; |
36 |
|
37 |
public General3DPreferencePage() {
|
38 |
initComponents(); |
39 |
|
40 |
addPropertyChangeListener(); |
41 |
} |
42 |
|
43 |
private void addPropertyChangeListener() { |
44 |
|
45 |
View3DManager manager = View3DLocator.getManager(); |
46 |
GeneralProperties3D general3dProperties = |
47 |
manager.getGeneral3DProperties(); |
48 |
|
49 |
general3dProperties |
50 |
.addPropertyChangeListener(new PropertyChangeListener() { |
51 |
|
52 |
public void propertyChange(PropertyChangeEvent evt) { |
53 |
valueChanged = true;
|
54 |
} |
55 |
}); |
56 |
|
57 |
} |
58 |
|
59 |
private void initComponents() { |
60 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
61 |
this.plugin = pluginManager.getPlugin(this); |
62 |
this.pluginProperties = this.plugin.getPluginProperties(); |
63 |
|
64 |
initializeValues(); |
65 |
|
66 |
View3DManager manager = View3DLocator.getManager(); |
67 |
GeneralProperties3D generalProperties3D = |
68 |
manager.getGeneral3DProperties(); |
69 |
|
70 |
View3DSwingManager swingManager = View3DSwingLocator.getManager(); |
71 |
propertiesPanel = |
72 |
swingManager.createGeneralProperties3DPanel(generalProperties3D); |
73 |
|
74 |
this.setLayout(new BorderLayout()); |
75 |
this.add(propertiesPanel.asJComponent(), BorderLayout.NORTH); |
76 |
} |
77 |
|
78 |
public String getID() { |
79 |
return ID;
|
80 |
} |
81 |
|
82 |
public String getTitle() { |
83 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
84 |
return i18nManager.getTranslation("3D"); |
85 |
} |
86 |
|
87 |
public JPanel getPanel() { |
88 |
return this; |
89 |
} |
90 |
|
91 |
public void initializeValues() { |
92 |
View3DManager manager = View3DLocator.getManager(); |
93 |
GeneralProperties3D generalProperties3D = |
94 |
manager.getGeneral3DProperties(); |
95 |
|
96 |
int width =
|
97 |
(Integer) this.pluginProperties.getDynValue("defultViewWidth"); |
98 |
int height =
|
99 |
(Integer) this.pluginProperties.getDynValue("defultViewHeight"); |
100 |
boolean atmosphereVisibility =
|
101 |
(Boolean) this.pluginProperties.getDynValue("atmosphereVisibility"); |
102 |
boolean northIndicatorVisibility =
|
103 |
(Boolean) this.pluginProperties |
104 |
.getDynValue("northIndicatorVisibility");
|
105 |
boolean minimapVisibility =
|
106 |
(Boolean) this.pluginProperties.getDynValue("minimapVisibility"); |
107 |
boolean starsBackgroundVisibility =
|
108 |
(Boolean) this.pluginProperties |
109 |
.getDynValue("starsBackgroundVisibility");
|
110 |
boolean scaleVisibility =
|
111 |
(Boolean) this.pluginProperties.getDynValue("scaleVisibility"); |
112 |
boolean viewportAnimation =
|
113 |
(Boolean) this.pluginProperties.getDynValue("viewportAnimation"); |
114 |
String cachePath =
|
115 |
(String) this.pluginProperties.getDynValue("cachePath"); |
116 |
|
117 |
generalProperties3D.setDefaultViewWidth(width); |
118 |
generalProperties3D.setDefaultViewHeight(height); |
119 |
generalProperties3D.setAtmosphereVisibility(atmosphereVisibility); |
120 |
generalProperties3D.setMinimapVisibility(minimapVisibility); |
121 |
generalProperties3D |
122 |
.setNorthIndicatorVisibility(northIndicatorVisibility); |
123 |
generalProperties3D |
124 |
.setStarsBackgroundVisibility(starsBackgroundVisibility); |
125 |
generalProperties3D.setScaleVisibility(scaleVisibility); |
126 |
generalProperties3D.setViewPortAnimation(viewportAnimation); |
127 |
generalProperties3D.setCachePath(cachePath); |
128 |
|
129 |
manager.setGeneral3DProperties(generalProperties3D); |
130 |
} |
131 |
|
132 |
public void initializeDefaults() { |
133 |
|
134 |
} |
135 |
|
136 |
@Override
|
137 |
public boolean isResizeable() { |
138 |
return true; |
139 |
} |
140 |
|
141 |
public ImageIcon getIcon() { |
142 |
return IconThemeHelper.getImageIcon("general-properties-view-3d"); |
143 |
} |
144 |
|
145 |
public boolean isValueChanged() { |
146 |
return valueChanged;
|
147 |
} |
148 |
|
149 |
@Override
|
150 |
public void storeValues() throws StoreException { |
151 |
|
152 |
this.pluginProperties.setDynValue("defultViewWidth", |
153 |
propertiesPanel.getDefaultWidth()); |
154 |
this.pluginProperties.setDynValue("defultViewHeight", |
155 |
propertiesPanel.getDefaultHeight()); |
156 |
this.pluginProperties.setDynValue("atmosphereVisibility", |
157 |
propertiesPanel.getAtmosphereVisibility()); |
158 |
this.pluginProperties.setDynValue("minimapVisibility", |
159 |
propertiesPanel.getMinimapVisibility()); |
160 |
this.pluginProperties.setDynValue("northIndicatorVisibility", |
161 |
propertiesPanel.getNorthIndicatorVisibility()); |
162 |
this.pluginProperties.setDynValue("starsBackgroundVisibility", |
163 |
propertiesPanel.getStarsBackgroundVisiblity()); |
164 |
this.pluginProperties.setDynValue("scaleVisibility", |
165 |
propertiesPanel.getScaleVisiblity()); |
166 |
this.pluginProperties.setDynValue("viewportAnimation", |
167 |
propertiesPanel.getViewPortAnimation()); |
168 |
this.pluginProperties.setDynValue("cachePath", |
169 |
propertiesPanel.getCachePath()); |
170 |
|
171 |
this.plugin.savePluginProperties();
|
172 |
} |
173 |
|
174 |
@Override
|
175 |
public void setChangesApplied() { |
176 |
|
177 |
View3DManager manager = View3DLocator.getManager(); |
178 |
GeneralProperties3D general3dProperties = |
179 |
manager.getGeneral3DProperties(); |
180 |
|
181 |
general3dProperties.setDefaultViewWidth(propertiesPanel |
182 |
.getDefaultWidth()); |
183 |
general3dProperties.setDefaultViewHeight(propertiesPanel |
184 |
.getDefaultHeight()); |
185 |
general3dProperties.setAtmosphereVisibility(propertiesPanel |
186 |
.getAtmosphereVisibility()); |
187 |
general3dProperties.setMinimapVisibility(propertiesPanel |
188 |
.getMinimapVisibility()); |
189 |
general3dProperties.setNorthIndicatorVisibility(propertiesPanel |
190 |
.getNorthIndicatorVisibility()); |
191 |
general3dProperties.setScaleVisibility(propertiesPanel |
192 |
.getScaleVisiblity()); |
193 |
general3dProperties.setStarsBackgroundVisibility(propertiesPanel |
194 |
.getStarsBackgroundVisiblity()); |
195 |
general3dProperties.setViewPortAnimation(propertiesPanel |
196 |
.getViewPortAnimation()); |
197 |
general3dProperties.setCachePath(propertiesPanel.getCachePath()); |
198 |
|
199 |
manager.setGeneral3DProperties(general3dProperties); |
200 |
|
201 |
valueChanged = false;
|
202 |
} |
203 |
|
204 |
} |