Revision 567
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.main/src/main/java/org/gvsig/view3d/main/PaletteActions.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright ? 2007-2015 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 |
|
|
25 |
package org.gvsig.view3d.main; |
|
26 |
|
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.io.File; |
|
29 |
import java.util.HashMap; |
|
30 |
import java.util.Map; |
|
31 |
|
|
32 |
import javax.swing.AbstractAction; |
|
33 |
import javax.swing.Action; |
|
34 |
import javax.swing.JFileChooser; |
|
35 |
import javax.swing.SwingUtilities; |
|
36 |
import javax.swing.tree.DefaultMutableTreeNode; |
|
37 |
import javax.swing.tree.TreePath; |
|
38 |
|
|
39 |
import org.gvsig.fmap.dal.DALLocator; |
|
40 |
import org.gvsig.fmap.dal.DataManager; |
|
41 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
42 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
43 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
44 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
45 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
46 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
47 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
48 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
49 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
50 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
51 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
|
52 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
53 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
54 |
import org.gvsig.utils.GenericFileFilter; |
|
55 |
import org.gvsig.view3d.swing.api.View3DSwingLocator; |
|
56 |
import org.gvsig.view3d.swing.api.View3DSwingManager; |
|
57 |
import org.gvsig.view3d.swing.api.View3DSwingManager.TYPE; |
|
58 |
import org.gvsig.view3d.swing.api.View3DPanel; |
|
59 |
|
|
60 |
/** |
|
61 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
62 |
* |
|
63 |
*/ |
|
64 |
public class PaletteActions { |
|
65 |
|
|
66 |
Map<String, Action> actions; |
|
67 |
Main main; |
|
68 |
|
|
69 |
public PaletteActions(Main main) { |
|
70 |
|
|
71 |
this.main = main; |
|
72 |
|
|
73 |
actions = new HashMap<String, Action>(); |
|
74 |
|
|
75 |
actions.put("exit", getExitAction()); |
|
76 |
actions.put("add-vectorial-layer", getAddVectorialLayerAction()); |
|
77 |
actions.put("add-raster-layer", getAddRasterLayerAction()); |
|
78 |
actions.put("remove-layer", getRemoveLayerAction()); |
|
79 |
actions.put("create-sphere-view-3d", getCreateSphereViewAction()); |
|
80 |
actions.put("create-flat-view-3d", getCreateFlatViewAction()); |
|
81 |
actions.put("create-reload-view-3d", getCreateReloadLayersAction()); |
|
82 |
actions.put("create-synchronize-view-3d", getCreateSynchronizeAction()); |
|
83 |
|
|
84 |
} |
|
85 |
|
|
86 |
public Action getAction(String actionCommand) { |
|
87 |
return actions.get(actionCommand); |
|
88 |
} |
|
89 |
|
|
90 |
private AbstractAction getAddVectorialLayerAction() { |
|
91 |
return new AbstractAction("Add Vectorial layer") { |
|
92 |
|
|
93 |
/** |
|
94 |
* |
|
95 |
*/ |
|
96 |
private static final long serialVersionUID = 7506436995278783992L; |
|
97 |
|
|
98 |
public void actionPerformed(ActionEvent e) { |
|
99 |
ThreadSafeDialogsManager dlgManager = |
|
100 |
ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
101 |
|
|
102 |
File[] file = |
|
103 |
dlgManager.showChooserDialog( |
|
104 |
"Seleccione una capa vectorial", |
|
105 |
JFileChooser.OPEN_DIALOG, JFileChooser.FILES_ONLY, |
|
106 |
false, new File(System.getProperty("user.home")), |
|
107 |
new GenericFileFilter(new String[] { ".shp", ".kml", |
|
108 |
".kmz" }, "(*.shp),(*.kml),(*.kmz)"), true); |
|
109 |
|
|
110 |
if (file != null) { |
|
111 |
try { |
|
112 |
for (int i = 0; i < file.length; i++) { |
|
113 |
addVectorialLayer(file[i].getAbsolutePath()); |
|
114 |
} |
|
115 |
} catch (Exception ex) { |
|
116 |
ex.printStackTrace(); |
|
117 |
} |
|
118 |
} |
|
119 |
} |
|
120 |
}; |
|
121 |
} |
|
122 |
|
|
123 |
public void addRasterLayer(String layerPath) throws InitializeException, |
|
124 |
ProviderNotRegisteredException, ValidateDataParametersException, |
|
125 |
LoadLayerException { |
|
126 |
|
|
127 |
DataStoreParameters params; |
|
128 |
DataManager dataManager = DALLocator.getDataManager(); |
|
129 |
MapContextManager mapContextManager = |
|
130 |
MapContextLocator.getMapContextManager(); |
|
131 |
|
|
132 |
params = dataManager.createStoreParameters("Gdal Store"); |
|
133 |
params.setDynValue("uri", layerPath); |
|
134 |
params.validate(); |
|
135 |
|
|
136 |
DefaultRasterStore store = |
|
137 |
(DefaultRasterStore) dataManager.openStore( |
|
138 |
params.getDataStoreName(), params); |
|
139 |
|
|
140 |
FLyrRaster layer = |
|
141 |
(FLyrRaster) mapContextManager.createLayer(store.getName(), store); |
|
142 |
|
|
143 |
this.main.getMapContext().beginAtomicEvent(); |
|
144 |
this.main.getMapContext().getLayers().addLayer(layer); |
|
145 |
this.main.getMapContext().invalidate(); |
|
146 |
this.main.getMapContext().endAtomicEvent(); |
|
147 |
|
|
148 |
// XXX Forces component repaint. |
|
149 |
SwingUtilities.updateComponentTreeUI(this.main.mainFrame); |
|
150 |
} |
|
151 |
|
|
152 |
private AbstractAction getAddRasterLayerAction() { |
|
153 |
return new AbstractAction("Add Raster layer") { |
|
154 |
|
|
155 |
/** |
|
156 |
* |
|
157 |
*/ |
|
158 |
private static final long serialVersionUID = 7506436995278783992L; |
|
159 |
|
|
160 |
public void actionPerformed(ActionEvent e) { |
|
161 |
ThreadSafeDialogsManager dlgManager = |
|
162 |
ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
163 |
|
|
164 |
File[] file = |
|
165 |
dlgManager.showChooserDialog("Seleccione una capa raster", |
|
166 |
JFileChooser.OPEN_DIALOG, JFileChooser.FILES_ONLY, |
|
167 |
false, new File(System.getProperty("user.home")), |
|
168 |
new GenericFileFilter(new String[] { "bmp", "gif", |
|
169 |
"tif", "tiff", "jpg", "jpeg", "png", "vrt", "dat", |
|
170 |
"lan", "gis", "img", "pix", "aux", "adf", "mpr", |
|
171 |
"mpl", "map", "asc", "pgm", "ppm", "rst", "rmf", |
|
172 |
"nos", "kap", "hdr", "raw", "ers", "xml", "grd", |
|
173 |
"txt" }, "Gdal format"), true); |
|
174 |
|
|
175 |
if (file != null) { |
|
176 |
try { |
|
177 |
for (int i = 0; i < file.length; i++) { |
|
178 |
addRasterLayer(file[i].getAbsolutePath()); |
|
179 |
} |
|
180 |
} catch (Exception ex) { |
|
181 |
ex.printStackTrace(); |
|
182 |
} |
|
183 |
} |
|
184 |
} |
|
185 |
}; |
|
186 |
} |
|
187 |
|
|
188 |
public void addVectorialLayer(String layerPath) throws InitializeException, |
|
189 |
ProviderNotRegisteredException, ValidateDataParametersException, |
|
190 |
LoadLayerException { |
|
191 |
|
|
192 |
DataStoreParameters params = null; |
|
193 |
DataManager dataManager = DALLocator.getDataManager(); |
|
194 |
MapContextManager mapContextManager = |
|
195 |
MapContextLocator.getMapContextManager(); |
|
196 |
|
|
197 |
if (layerPath.endsWith(".shp")) { |
|
198 |
params = dataManager.createStoreParameters("Shape"); |
|
199 |
params.setDynValue("shpFile", layerPath); |
|
200 |
|
|
201 |
} else if (layerPath.endsWith(".kml") || layerPath.endsWith(".kmz")) { |
|
202 |
params = dataManager.createStoreParameters("GPE"); |
|
203 |
params.setDynValue("File", layerPath); |
|
204 |
} |
|
205 |
|
|
206 |
params.setDynValue("CRS", this.main.getDefaultProjection()); |
|
207 |
params.validate(); |
|
208 |
|
|
209 |
FeatureStore store = |
|
210 |
(FeatureStore) dataManager.openStore(params.getDataStoreName(), |
|
211 |
params); |
|
212 |
|
|
213 |
FLayer layer = mapContextManager.createLayer(store.getName(), store); |
|
214 |
this.main.getMapContext().beginAtomicEvent(); |
|
215 |
this.main.getMapContext().getLayers().addLayer(layer); |
|
216 |
this.main.getMapContext().invalidate(); |
|
217 |
this.main.getMapContext().endAtomicEvent(); |
|
218 |
|
|
219 |
// XXX Forces component repaint. |
|
220 |
SwingUtilities.updateComponentTreeUI(this.main.mainFrame); |
|
221 |
} |
|
222 |
|
|
223 |
private AbstractAction getExitAction() { |
|
224 |
return new AbstractAction("Exit") { |
|
225 |
|
|
226 |
/** |
|
227 |
* |
|
228 |
*/ |
|
229 |
private static final long serialVersionUID = 7506436995278783992L; |
|
230 |
|
|
231 |
public void actionPerformed(ActionEvent e) { |
|
232 |
System.exit(0); |
|
233 |
} |
|
234 |
}; |
|
235 |
} |
|
236 |
|
|
237 |
private Action getCreateSphereViewAction() { |
|
238 |
return new AbstractAction("Create Sphere 3D visor") { |
|
239 |
|
|
240 |
/** |
|
241 |
* |
|
242 |
*/ |
|
243 |
private static final long serialVersionUID = 7506436995278783992L; |
|
244 |
|
|
245 |
public void actionPerformed(ActionEvent e) { |
|
246 |
View3DSwingManager manager = View3DSwingLocator.getManager(); |
|
247 |
View3DPanel view3dPanel = |
|
248 |
manager.createView3DPanel(main.getMapContext(), |
|
249 |
"Main",TYPE.SPHERE, new DummieExtendedPropertiesSupport()); |
|
250 |
view3dPanel.show(); |
|
251 |
} |
|
252 |
}; |
|
253 |
} |
|
254 |
|
|
255 |
private Action getCreateSynchronizeAction() { |
|
256 |
return new AbstractAction("Synchronize views") { |
|
257 |
|
|
258 |
/** |
|
259 |
* |
|
260 |
*/ |
|
261 |
private static final long serialVersionUID = 7506436995278783992L; |
|
262 |
|
|
263 |
public void actionPerformed(ActionEvent e) { |
|
264 |
// TODO |
|
265 |
} |
|
266 |
}; |
|
267 |
} |
|
268 |
|
|
269 |
private Action getCreateReloadLayersAction() { |
|
270 |
return new AbstractAction("Reload layers") { |
|
271 |
|
|
272 |
/** |
|
273 |
* |
|
274 |
*/ |
|
275 |
private static final long serialVersionUID = 7506436995278783992L; |
|
276 |
|
|
277 |
public void actionPerformed(ActionEvent e) { |
|
278 |
// TODO |
|
279 |
} |
|
280 |
}; |
|
281 |
} |
|
282 |
|
|
283 |
private Action getCreateFlatViewAction() { |
|
284 |
return new AbstractAction("Create Flat 3D visor") { |
|
285 |
|
|
286 |
/** |
|
287 |
* |
|
288 |
*/ |
|
289 |
private static final long serialVersionUID = 7506436995278783992L; |
|
290 |
|
|
291 |
public void actionPerformed(ActionEvent e) { |
|
292 |
View3DSwingManager manager = View3DSwingLocator.getManager(); |
|
293 |
View3DPanel view3dPanel = |
|
294 |
manager.createView3DPanel(main.getMapContext(),"Main", TYPE.FLAT, |
|
295 |
new DummieExtendedPropertiesSupport()); |
|
296 |
// Change value for constant key |
|
297 |
view3dPanel.show(); |
|
298 |
} |
|
299 |
}; |
|
300 |
} |
|
301 |
|
|
302 |
private Action getRemoveLayerAction() { |
|
303 |
return new AbstractAction("Remove selected layer") { |
|
304 |
|
|
305 |
/** |
|
306 |
* |
|
307 |
*/ |
|
308 |
private static final long serialVersionUID = 7506436995278783992L; |
|
309 |
|
|
310 |
public void actionPerformed(ActionEvent e) { |
|
311 |
TreePath selectionPath = main.getTree().getSelectionPath(); |
|
312 |
|
|
313 |
if (selectionPath == null) { |
|
314 |
return; |
|
315 |
} |
|
316 |
|
|
317 |
DefaultMutableTreeNode selectedNode = |
|
318 |
(DefaultMutableTreeNode) selectionPath |
|
319 |
.getLastPathComponent(); |
|
320 |
selectedNode.removeFromParent(); |
|
321 |
main.getTreeModel().reload(); |
|
322 |
|
|
323 |
main.getMapContext().beginAtomicEvent(); |
|
324 |
main.getMapContext().getLayers() |
|
325 |
.removeLayer(selectedNode.toString()); |
|
326 |
main.getMapContext().invalidate(); |
|
327 |
main.getMapContext().endAtomicEvent(); |
|
328 |
|
|
329 |
// XXX Forces component repaint. |
|
330 |
SwingUtilities.updateComponentTreeUI(main.mainFrame); |
|
331 |
} |
|
332 |
}; |
|
333 |
} |
|
334 |
} |
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.main/src/main/java/org/gvsig/view3d/main/DummieLayerOrderManager.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright ? 2007-2014 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 |
|
|
25 |
package org.gvsig.view3d.main; |
|
26 |
|
|
27 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
28 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
29 |
import org.gvsig.fmap.mapcontext.layers.order.LayerOrderManager; |
|
30 |
import org.gvsig.tools.persistence.PersistentState; |
|
31 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
32 |
|
|
33 |
public class DummieLayerOrderManager implements LayerOrderManager { |
|
34 |
|
|
35 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
36 |
} |
|
37 |
|
|
38 |
public void loadFromState(PersistentState state) |
|
39 |
throws PersistenceException { |
|
40 |
} |
|
41 |
|
|
42 |
public int getPosition(FLayers target, FLayer newLayer) { |
|
43 |
return 0; |
|
44 |
} |
|
45 |
|
|
46 |
public String getName() { |
|
47 |
return null; |
|
48 |
} |
|
49 |
|
|
50 |
public String getDescription() { |
|
51 |
return null; |
|
52 |
} |
|
53 |
|
|
54 |
public String getCode() { |
|
55 |
return null; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public Object clone() throws CloneNotSupportedException { |
|
60 |
return new DummieLayerOrderManager(); |
|
61 |
} |
|
62 |
|
|
63 |
} |
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.main/src/main/java/org/gvsig/view3d/main/Main.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright ? 2007-2015 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 |
|
|
25 |
package org.gvsig.view3d.main; |
|
26 |
|
|
27 |
import java.awt.BorderLayout; |
|
28 |
import java.awt.Color; |
|
29 |
import java.awt.Dimension; |
|
30 |
import java.awt.event.MouseEvent; |
|
31 |
import java.awt.event.MouseListener; |
|
32 |
|
|
33 |
import javax.swing.JButton; |
|
34 |
import javax.swing.JFrame; |
|
35 |
import javax.swing.JMenu; |
|
36 |
import javax.swing.JMenuBar; |
|
37 |
import javax.swing.JMenuItem; |
|
38 |
import javax.swing.JOptionPane; |
|
39 |
import javax.swing.JPanel; |
|
40 |
import javax.swing.JToolBar; |
|
41 |
import javax.swing.JTree; |
|
42 |
import javax.swing.SwingUtilities; |
|
43 |
import javax.swing.WindowConstants; |
|
44 |
import javax.swing.tree.DefaultMutableTreeNode; |
|
45 |
import javax.swing.tree.DefaultTreeModel; |
|
46 |
import javax.swing.tree.TreePath; |
|
47 |
import javax.swing.tree.TreeSelectionModel; |
|
48 |
|
|
49 |
import org.cresques.cts.IProjection; |
|
50 |
import org.slf4j.Logger; |
|
51 |
import org.slf4j.LoggerFactory; |
|
52 |
|
|
53 |
import org.gvsig.fmap.crs.CRSFactory; |
|
54 |
import org.gvsig.fmap.dal.DALLocator; |
|
55 |
import org.gvsig.fmap.dal.DataManager; |
|
56 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
57 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
58 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
59 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
60 |
import org.gvsig.fmap.mapcontext.layers.CancelationException; |
|
61 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
62 |
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent; |
|
63 |
import org.gvsig.fmap.mapcontext.layers.LayerCollectionListener; |
|
64 |
import org.gvsig.fmap.mapcontext.layers.LayerPositionEvent; |
|
65 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
66 |
import org.gvsig.fmap.mapcontrol.MapControlCreationException; |
|
67 |
import org.gvsig.fmap.mapcontrol.MapControlLocator; |
|
68 |
import org.gvsig.fmap.mapcontrol.MapControlManager; |
|
69 |
import org.gvsig.fmap.mapcontrol.tools.PanListenerImpl; |
|
70 |
import org.gvsig.fmap.mapcontrol.tools.PointSelectionListener; |
|
71 |
import org.gvsig.fmap.mapcontrol.tools.ZoomInListenerImpl; |
|
72 |
import org.gvsig.fmap.mapcontrol.tools.ZoomOutListenerImpl; |
|
73 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
|
74 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MoveBehavior; |
|
75 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
|
76 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.RectangleBehavior; |
|
77 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
78 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
79 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
80 |
import org.gvsig.view3d.swing.api.View3DSwingLocator; |
|
81 |
import org.gvsig.view3d.swing.api.View3DSwingManager; |
|
82 |
|
|
83 |
/** |
|
84 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
85 |
* |
|
86 |
*/ |
|
87 |
public class Main { |
|
88 |
|
|
89 |
private static final Logger LOG = LoggerFactory.getLogger(Main.class); |
|
90 |
|
|
91 |
final View3DSwingManager view3DManager; |
|
92 |
|
|
93 |
final MapControlManager mapControlManager; |
|
94 |
|
|
95 |
final DataManager dataManager; |
|
96 |
|
|
97 |
final MapContextManager mapContextManager; |
|
98 |
|
|
99 |
final String DEFAULT_CRS_CODE = "EPSG:4326"; |
|
100 |
|
|
101 |
final PaletteActions paletteActions; |
|
102 |
|
|
103 |
IProjection defaultProjection; |
|
104 |
|
|
105 |
MapControl mapControl; |
|
106 |
|
|
107 |
JFrame mainFrame; |
|
108 |
|
|
109 |
JTree tree; |
|
110 |
|
|
111 |
DefaultTreeModel treeModel; |
|
112 |
|
|
113 |
DefaultMutableTreeNode rootNode; |
|
114 |
|
|
115 |
MouseListener treeMouseListener; |
|
116 |
|
|
117 |
public Main() { |
|
118 |
view3DManager = View3DSwingLocator.getManager(); |
|
119 |
mapControlManager = MapControlLocator.getMapControlManager(); |
|
120 |
dataManager = DALLocator.getDataManager(); |
|
121 |
mapContextManager = MapContextLocator.getMapContextManager(); |
|
122 |
defaultProjection = CRSFactory.getCRS(DEFAULT_CRS_CODE); |
|
123 |
paletteActions = new PaletteActions(this); |
|
124 |
|
|
125 |
MapContextLocator |
|
126 |
.registerDefaultOrderManager(DummieLayerOrderManager.class); |
|
127 |
} |
|
128 |
|
|
129 |
public static void main(String[] args) { |
|
130 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
131 |
Main main = new Main(); |
|
132 |
main.doMain(); |
|
133 |
} |
|
134 |
|
|
135 |
private void doMain() { |
|
136 |
|
|
137 |
try { |
|
138 |
MapContext mapContext = |
|
139 |
new MapContext(new ViewPort(defaultProjection)); |
|
140 |
mapControl = mapControlManager.createJMapControlPanel(mapContext); |
|
141 |
|
|
142 |
addCollecionListener(); |
|
143 |
|
|
144 |
mapControl.addBehavior("zoom", new Behavior[] { |
|
145 |
new RectangleBehavior(new ZoomInListenerImpl(mapControl)), |
|
146 |
new PointBehavior(new ZoomOutListenerImpl(mapControl), |
|
147 |
Behavior.BUTTON_RIGHT) }); |
|
148 |
mapControl.addBehavior("pan", new MoveBehavior(new PanListenerImpl( |
|
149 |
mapControl))); |
|
150 |
|
|
151 |
mapControl.addBehavior("pointSelection", |
|
152 |
new Behavior[] { new PointBehavior(new PointSelectionListener( |
|
153 |
mapControl)) }); |
|
154 |
|
|
155 |
IProjection defaultProjection = CRSFactory.getCRS(DEFAULT_CRS_CODE); |
|
156 |
mapControl.getViewPort().setProjection(defaultProjection); |
|
157 |
|
|
158 |
mapControl.setTool("pan"); |
|
159 |
|
|
160 |
} catch (MapControlCreationException e) { |
|
161 |
LOG.error("Can't create mapControl", e); |
|
162 |
} |
|
163 |
|
|
164 |
// Create JFrame to show data |
|
165 |
mainFrame = new JFrame("View 3D test app"); |
|
166 |
mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
|
167 |
mainFrame.setPreferredSize(new Dimension(1055, 680)); |
|
168 |
mainFrame.add(mapControl, BorderLayout.CENTER); |
|
169 |
|
|
170 |
// Create menu bar |
|
171 |
createMenu(); |
|
172 |
|
|
173 |
// Create tools bar |
|
174 |
createToolBar(); |
|
175 |
|
|
176 |
// Create simple TOC |
|
177 |
createTOC(); |
|
178 |
|
|
179 |
// Display the window. |
|
180 |
mainFrame.pack(); |
|
181 |
mainFrame.setLocation(100, 0); |
|
182 |
mainFrame.setVisible(true); |
|
183 |
|
|
184 |
} |
|
185 |
|
|
186 |
private void addCollecionListener() { |
|
187 |
mapControl.getMapContext().getLayers() |
|
188 |
.addLayerCollectionListener(new LayerCollectionListener() { |
|
189 |
|
|
190 |
public void visibilityChanged(LayerCollectionEvent e) |
|
191 |
throws CancelationException { |
|
192 |
} |
|
193 |
|
|
194 |
public void layerRemoving(LayerCollectionEvent e) |
|
195 |
throws CancelationException { |
|
196 |
} |
|
197 |
|
|
198 |
public void layerRemoved(LayerCollectionEvent e) { |
|
199 |
} |
|
200 |
|
|
201 |
public void layerMoving(LayerPositionEvent e) |
|
202 |
throws CancelationException { |
|
203 |
} |
|
204 |
|
|
205 |
public void layerMoved(LayerPositionEvent e) { |
|
206 |
} |
|
207 |
|
|
208 |
public void layerAdding(LayerCollectionEvent e) |
|
209 |
throws CancelationException { |
|
210 |
} |
|
211 |
|
|
212 |
public void layerAdded(LayerCollectionEvent e) { |
|
213 |
FLayer layer = e.getAffectedLayer(); |
|
214 |
DefaultMutableTreeNode layerNode = |
|
215 |
new DefaultMutableTreeNode(layer.getName()); |
|
216 |
getRootNode().add(layerNode); |
|
217 |
getTreeModel().reload(getRootNode()); |
|
218 |
|
|
219 |
// Expand nodes |
|
220 |
getTree().expandRow(0); |
|
221 |
} |
|
222 |
}); |
|
223 |
} |
|
224 |
|
|
225 |
private void createMenu() { |
|
226 |
// Create the menu bar. |
|
227 |
JMenuBar menuBar = new JMenuBar(); |
|
228 |
|
|
229 |
// Build the menu. |
|
230 |
JMenu menuFile = new JMenu("File"); |
|
231 |
menuFile.add(new JMenuItem(paletteActions.getAction("exit"))); |
|
232 |
|
|
233 |
JMenu menuLayer = new JMenu("Layer"); |
|
234 |
menuLayer.add(new JMenuItem(paletteActions |
|
235 |
.getAction("add-vectorial-layer"))); |
|
236 |
menuLayer.add(new JMenuItem(paletteActions |
|
237 |
.getAction("add-raster-layer"))); |
|
238 |
menuLayer.add(new JMenuItem(paletteActions.getAction("remove-layer"))); |
|
239 |
|
|
240 |
JMenu menu3D = new JMenu("3D"); |
|
241 |
menu3D.add(new JMenuItem(paletteActions |
|
242 |
.getAction("create-sphere-view-3d"))); |
|
243 |
menu3D.add(new JMenuItem(paletteActions |
|
244 |
.getAction("create-flat-view-3d"))); |
|
245 |
menu3D.add(new JMenuItem(paletteActions |
|
246 |
.getAction("create-reload-view-3d"))); |
|
247 |
menu3D.add(new JMenuItem(paletteActions |
|
248 |
.getAction("create-synchronize-view-3d"))); |
|
249 |
|
|
250 |
menuBar.add(menuFile); |
|
251 |
menuBar.add(menuLayer); |
|
252 |
menuBar.add(menu3D); |
|
253 |
|
|
254 |
mainFrame.setJMenuBar(menuBar); |
|
255 |
} |
|
256 |
|
|
257 |
private void createToolBar() { |
|
258 |
JToolBar toolBar = new JToolBar(); |
|
259 |
|
|
260 |
toolBar |
|
261 |
.add(new JButton(paletteActions.getAction("add-vectorial-layer"))); |
|
262 |
toolBar.add(new JButton(paletteActions.getAction("add-raster-layer"))); |
|
263 |
toolBar.add(new JButton(paletteActions.getAction("remove-layer"))); |
|
264 |
toolBar.add(new JButton(paletteActions |
|
265 |
.getAction("create-sphere-view-3d"))); |
|
266 |
toolBar |
|
267 |
.add(new JButton(paletteActions.getAction("create-flat-view-3d"))); |
|
268 |
toolBar.add(new JButton(paletteActions |
|
269 |
.getAction("create-reload-view-3d"))); |
|
270 |
toolBar.add(new JButton(paletteActions |
|
271 |
.getAction("create-synchronize-view-3d"))); |
|
272 |
|
|
273 |
mainFrame.add(toolBar, BorderLayout.PAGE_START); |
|
274 |
|
|
275 |
} |
|
276 |
|
|
277 |
private void createTOC() { |
|
278 |
|
|
279 |
JPanel toc = new JPanel(); |
|
280 |
toc.setBackground(Color.WHITE); |
|
281 |
|
|
282 |
rootNode = getRootNode(); |
|
283 |
treeModel = getTreeModel(); |
|
284 |
tree = getTree(); |
|
285 |
|
|
286 |
toc.add(tree); |
|
287 |
mainFrame.add(toc, BorderLayout.WEST); |
|
288 |
} |
|
289 |
|
|
290 |
private DefaultMutableTreeNode getRootNode() { |
|
291 |
if (rootNode == null) { |
|
292 |
rootNode = new DefaultMutableTreeNode("Layers"); |
|
293 |
} |
|
294 |
return rootNode; |
|
295 |
} |
|
296 |
|
|
297 |
protected DefaultTreeModel getTreeModel() { |
|
298 |
if (treeModel == null) { |
|
299 |
treeModel = new DefaultTreeModel(getRootNode()); |
|
300 |
} |
|
301 |
return treeModel; |
|
302 |
} |
|
303 |
|
|
304 |
protected JTree getTree() { |
|
305 |
if (tree == null) { |
|
306 |
tree = new JTree(getTreeModel()); |
|
307 |
tree.getSelectionModel().setSelectionMode( |
|
308 |
TreeSelectionModel.SINGLE_TREE_SELECTION); |
|
309 |
tree.addMouseListener(getTreeMouseListener()); |
|
310 |
} |
|
311 |
return tree; |
|
312 |
} |
|
313 |
|
|
314 |
private MouseListener getTreeMouseListener() { |
|
315 |
if (treeMouseListener == null) { |
|
316 |
treeMouseListener = new MouseListener() { |
|
317 |
|
|
318 |
public void mouseReleased(MouseEvent e) { |
|
319 |
} |
|
320 |
|
|
321 |
public void mousePressed(MouseEvent e) { |
|
322 |
int selRow = tree.getRowForLocation(e.getX(), e.getY()); |
|
323 |
TreePath selPath = |
|
324 |
tree.getPathForLocation(e.getX(), e.getY()); |
|
325 |
if (selRow != -1) { |
|
326 |
if (e.getClickCount() == 2 |
|
327 |
&& SwingUtilities.isLeftMouseButton(e)) { |
|
328 |
|
|
329 |
DefaultMutableTreeNode selectedNode = |
|
330 |
(DefaultMutableTreeNode) selPath |
|
331 |
.getLastPathComponent(); |
|
332 |
|
|
333 |
if(selectedNode == getRootNode()){ |
|
334 |
return; |
|
335 |
} |
|
336 |
|
|
337 |
// TODO Open 3D properties dialog to set layer load |
|
338 |
// mode. |
|
339 |
ThreadSafeDialogsManager tsdm = |
|
340 |
ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
341 |
tsdm.messageDialog( |
|
342 |
"Open " + selectedNode.toString() |
|
343 |
+ " 3D properties" |
|
344 |
+ " dialog to set layer load mode", |
|
345 |
"3D properties", |
|
346 |
JOptionPane.INFORMATION_MESSAGE); |
|
347 |
} |
|
348 |
} |
|
349 |
} |
|
350 |
|
|
351 |
public void mouseExited(MouseEvent e) { |
|
352 |
} |
|
353 |
|
|
354 |
public void mouseEntered(MouseEvent e) { |
|
355 |
} |
|
356 |
|
|
357 |
public void mouseClicked(MouseEvent e) { |
|
358 |
} |
|
359 |
}; |
|
360 |
} |
|
361 |
return treeMouseListener; |
|
362 |
} |
|
363 |
|
|
364 |
public MapControl getMapControl() { |
|
365 |
return this.mapControl; |
|
366 |
} |
|
367 |
|
|
368 |
public MapContext getMapContext() { |
|
369 |
return this.mapControl.getMapContext(); |
|
370 |
} |
|
371 |
|
|
372 |
public IProjection getDefaultProjection() { |
|
373 |
return defaultProjection; |
|
374 |
} |
|
375 |
} |
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.main/src/main/java/org/gvsig/view3d/main/DummieExtendedPropertiesSupport.java | ||
---|---|---|
1 |
package org.gvsig.view3d.main; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.gvsig.fmap.mapcontext.layers.ExtendedPropertiesSupport; |
|
7 |
|
|
8 |
|
|
9 |
public class DummieExtendedPropertiesSupport implements |
|
10 |
ExtendedPropertiesSupport { |
|
11 |
|
|
12 |
private Map<Object, Object> properties; |
|
13 |
|
|
14 |
public DummieExtendedPropertiesSupport() { |
|
15 |
properties = new HashMap<Object, Object>(); |
|
16 |
} |
|
17 |
|
|
18 |
public Object getProperty(Object key) { |
|
19 |
return properties.get(key); |
|
20 |
} |
|
21 |
|
|
22 |
public void setProperty(Object key, Object obj) { |
|
23 |
properties.put(key, obj); |
|
24 |
} |
|
25 |
|
|
26 |
public Map getExtendedProperties() { |
|
27 |
return properties; |
|
28 |
} |
|
29 |
|
|
30 |
} |
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.main/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.view3d</artifactId> |
|
6 |
<version>1.0.2</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.view3d.main</artifactId> |
|
9 |
<name>org.gvsig.view3d.main</name> |
|
10 |
<dependencies> |
|
11 |
<!-- Compile dependencies --> |
|
12 |
<dependency> |
|
13 |
<groupId>org.gvsig</groupId> |
|
14 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
15 |
<scope>compile</scope> |
|
16 |
</dependency> |
|
17 |
<dependency> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>org.gvsig.timesupport.lib.api</artifactId> |
|
20 |
<scope>compile</scope> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
25 |
<type>jar</type> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
36 |
<scope>compile</scope> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
41 |
<scope>compile</scope> |
|
42 |
</dependency> |
|
43 |
<dependency> |
|
44 |
<groupId>org.gvsig</groupId> |
|
45 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
46 |
<scope>compile</scope> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>org.gvsig</groupId> |
|
50 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
51 |
</dependency> |
|
52 |
<dependency> |
|
53 |
<groupId>org.gvsig</groupId> |
|
54 |
<artifactId>org.gvsig.raster.swing.api</artifactId> |
|
55 |
</dependency> |
|
56 |
<dependency> |
|
57 |
<groupId>org.gvsig</groupId> |
|
58 |
<artifactId>org.gvsig.raster.lib.impl</artifactId> |
|
59 |
</dependency> |
|
60 |
<dependency> |
|
61 |
<groupId>org.gvsig</groupId> |
|
62 |
<artifactId>org.gvsig.gpe.lib.api</artifactId> |
|
63 |
<version>2.1.5</version> |
|
64 |
</dependency> |
|
65 |
|
|
66 |
<!-- runtime dependencies --> |
|
67 |
<dependency> |
|
68 |
<groupId>org.gvsig</groupId> |
|
69 |
<artifactId>org.gvsig.metadata.lib.basic.impl</artifactId> |
|
70 |
<scope>runtime</scope> |
|
71 |
</dependency> |
|
72 |
<dependency> |
|
73 |
<groupId>org.gvsig</groupId> |
|
74 |
<artifactId>${org.gvsig.fmap.geometry.impl}</artifactId> |
|
75 |
<scope>runtime</scope> |
|
76 |
</dependency> |
|
77 |
<dependency> |
|
78 |
<groupId>org.gvsig</groupId> |
|
79 |
<artifactId>${org.gvsig.fmap.geometry.operation.impl}</artifactId> |
|
80 |
<scope>runtime</scope> |
|
81 |
</dependency> |
|
82 |
<dependency> |
|
83 |
<groupId>org.gvsig</groupId> |
|
84 |
<artifactId>org.gvsig.fmap.mapcontext.impl</artifactId> |
|
85 |
<scope>runtime</scope> |
|
86 |
</dependency> |
|
87 |
<dependency> |
|
88 |
<groupId>org.gvsig</groupId> |
|
89 |
<artifactId>org.gvsig.symbology.lib.impl</artifactId> |
|
90 |
<scope>runtime</scope> |
|
91 |
</dependency> |
|
92 |
<dependency> |
|
93 |
<groupId>org.gvsig</groupId> |
|
94 |
<artifactId>org.gvsig.fmap.dal.impl</artifactId> |
|
95 |
<scope>runtime</scope> |
|
96 |
</dependency> |
|
97 |
<dependency> |
|
98 |
<groupId>org.gvsig</groupId> |
|
99 |
<artifactId>org.gvsig.raster.gdal.io</artifactId> |
|
100 |
<scope>runtime</scope> |
|
101 |
</dependency> |
|
102 |
<dependency> |
|
103 |
<groupId>org.gvsig</groupId> |
|
104 |
<artifactId>org.gvsig.fmap.dal.file.shp</artifactId> |
|
105 |
<scope>runtime</scope> |
|
106 |
</dependency> |
|
107 |
<dependency> |
|
108 |
<groupId>org.gvsig</groupId> |
|
109 |
<artifactId>org.gvsig.fmap.dal.file.dbf</artifactId> |
|
110 |
<scope>runtime</scope> |
|
111 |
</dependency> |
|
112 |
<dependency> |
|
113 |
<groupId>org.gvsig</groupId> |
|
114 |
<artifactId>org.gvsig.timesupport.lib.impl</artifactId> |
|
115 |
<scope>runtime</scope> |
|
116 |
</dependency> |
|
117 |
<dependency> |
|
118 |
<groupId>org.gvsig</groupId> |
|
119 |
<artifactId>org.gvsig.tools.evaluator.sqljep</artifactId> |
|
120 |
<scope>runtime</scope> |
|
121 |
</dependency> |
|
122 |
<dependency> |
|
123 |
<groupId>org.gvsig</groupId> |
|
124 |
<artifactId>org.gvsig.raster.swing.impl</artifactId> |
|
125 |
<scope>runtime</scope> |
|
126 |
</dependency> |
|
127 |
<dependency> |
|
128 |
<groupId>org.gvsig</groupId> |
|
129 |
<artifactId>org.gvsig.proj.lib.proj4j</artifactId> |
|
130 |
<scope>runtime</scope> |
|
131 |
</dependency> |
|
132 |
<dependency> |
|
133 |
<groupId>org.gvsig</groupId> |
|
134 |
<artifactId>org.gvsig.raster.fmap</artifactId> |
|
135 |
</dependency> |
|
136 |
<dependency> |
|
137 |
<groupId>org.gvsig</groupId> |
|
138 |
<artifactId>org.gvsig.gpe.lib.impl</artifactId> |
|
139 |
<scope>runtime</scope> |
|
140 |
</dependency> |
|
141 |
<dependency> |
|
142 |
<groupId>org.gvsig</groupId> |
|
143 |
<artifactId>org.gvsig.gpe.prov.gml</artifactId> |
|
144 |
<scope>runtime</scope> |
|
145 |
</dependency> |
|
146 |
<dependency> |
|
147 |
<groupId>org.gvsig</groupId> |
|
148 |
<artifactId>org.gvsig.gpe.prov.kml</artifactId> |
|
149 |
<scope>runtime</scope> |
|
150 |
</dependency> |
|
151 |
<dependency> |
|
152 |
<groupId>org.gvsig</groupId> |
|
153 |
<artifactId>org.gvsig.gpe.prov.xml</artifactId> |
|
154 |
<scope>runtime</scope> |
|
155 |
</dependency> |
|
156 |
<dependency> |
|
157 |
<groupId>org.gvsig</groupId> |
|
158 |
<artifactId>org.gvsig.gpe.exportto.generic</artifactId> |
|
159 |
<scope>runtime</scope> |
|
160 |
</dependency> |
|
161 |
<dependency> |
|
162 |
<groupId>org.gvsig</groupId> |
|
163 |
<artifactId>org.gvsig.gpe.exportto.kml</artifactId> |
|
164 |
<scope>runtime</scope> |
|
165 |
</dependency> |
|
166 |
<dependency> |
|
167 |
<groupId>org.gvsig</groupId> |
|
168 |
<artifactId>org.gvsig.gpe.app.mainplugin</artifactId> |
|
169 |
<scope>runtime</scope> |
|
170 |
</dependency> |
|
171 |
<dependency> |
|
172 |
<groupId>xerces</groupId> |
|
173 |
<artifactId>xercesImpl</artifactId> |
|
174 |
<version>2.11.0</version> |
|
175 |
</dependency> |
|
176 |
<dependency> |
|
177 |
<groupId>xml-apis</groupId> |
|
178 |
<artifactId>xml-apis</artifactId> |
|
179 |
<version>2.0.2</version> |
|
180 |
</dependency> |
|
181 |
|
|
182 |
<!-- Native dependencies. To test with other arch --> |
|
183 |
<!-- change classifier of dependency --> |
|
184 |
|
|
185 |
<dependency> |
|
186 |
<groupId>org.jogamp.gluegen</groupId> |
|
187 |
<artifactId>gluegen-rt</artifactId> |
|
188 |
<classifier>natives-linux-amd64</classifier> |
|
189 |
<scope>runtime</scope> |
|
190 |
<version>2.2.1</version> |
|
191 |
</dependency> |
|
192 |
<dependency> |
|
193 |
<groupId>org.jogamp.jogl</groupId> |
|
194 |
<artifactId>jogl-all</artifactId> |
|
195 |
<classifier>natives-linux-amd64</classifier> |
|
196 |
<scope>runtime</scope> |
|
197 |
<version>2.2.1</version> |
|
198 |
</dependency> |
|
199 |
|
|
200 |
|
|
201 |
<!-- View3D dependencies --> |
|
202 |
<dependency> |
|
203 |
<groupId>org.gvsig</groupId> |
|
204 |
<artifactId>org.gvsig.view3d.lib.api</artifactId> |
|
205 |
</dependency> |
|
206 |
<dependency> |
|
207 |
<groupId>org.gvsig</groupId> |
|
208 |
<artifactId>org.gvsig.view3d.lib.impl</artifactId> |
|
209 |
<scope>runtime</scope> |
|
210 |
</dependency> |
|
211 |
<dependency> |
|
212 |
<groupId>org.gvsig</groupId> |
|
213 |
<artifactId>org.gvsig.view3d.swing.api</artifactId> |
|
214 |
</dependency> |
|
215 |
<dependency> |
|
216 |
<groupId>org.gvsig</groupId> |
|
217 |
<artifactId>org.gvsig.view3d.swing.impl</artifactId> |
|
218 |
<scope>runtime</scope> |
|
219 |
</dependency> |
|
220 |
</dependencies> |
|
221 |
|
|
222 |
<build> |
|
223 |
<plugins> |
|
224 |
<plugin> |
|
225 |
<artifactId>maven-dependency-plugin</artifactId> |
|
226 |
<executions> |
|
227 |
<execution> |
|
228 |
<phase>package</phase> |
|
229 |
<goals> |
|
230 |
<goal>copy-dependencies</goal> |
|
231 |
</goals> |
|
232 |
<configuration> |
|
233 |
<includeTypes>jar</includeTypes> |
|
234 |
<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact> |
|
235 |
<outputDirectory>${project.build.directory}/lib</outputDirectory> |
|
236 |
<overWriteReleases>true</overWriteReleases> |
|
237 |
<overWriteSnapshots>true</overWriteSnapshots> |
|
238 |
<overWriteIfNewer>true</overWriteIfNewer> |
|
239 |
</configuration> |
|
240 |
</execution> |
|
241 |
</executions> |
|
242 |
</plugin> |
|
243 |
</plugins> |
|
244 |
</build> |
|
245 |
</project> |
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.main/main.sh | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
set -x |
|
3 |
JAR_FILE=`ls -1 target/org.gvsig.view3d.main* | grep -v ".*-sources.jar" | grep -v ".*-javadoc.jar" ` |
|
4 |
CLASSPATH=$JAR_FILE |
|
5 |
set +x |
|
6 |
for afile in target/lib/* |
|
7 |
do |
|
8 |
CLASSPATH="$CLASSPATH:$afile" |
|
9 |
done |
|
10 |
export GDAL_PLUGIN_FOLDER=$1 |
|
11 |
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GDAL_PLUGIN_FOLDER/jgdal/lib:$GDAL_PLUGIN_FOLDER/gdal/lib64:" |
|
12 |
echo 'Classpath:' |
|
13 |
echo $CLASSPATH |
|
14 |
echo 'Plugin folder:' |
|
15 |
echo $GDAL_PLUGIN_FOLDER |
|
16 |
echo 'Library path:' |
|
17 |
echo $LD_LIBRARY_PATH |
|
18 |
echo |
|
19 |
echo 'Command exec:' |
|
20 |
echo java -cp $CLASSPATH org.gvsig.view3d.main.Main -Djava.library.path=${LD_LIBRARY_PATH} |
|
21 |
java -cp $CLASSPATH org.gvsig.view3d.main.Main -Djava.library.path=${LD_LIBRARY_PATH} |
|
0 | 22 |
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.main/main-debug.sh | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
set -x |
|
3 |
JAR_FILE=`ls -1 target/org.gvsig.view3d.main* | grep -v ".*-sources.jar" | grep -v ".*-javadoc.jar" ` |
|
4 |
CLASSPATH=$JAR_FILE |
|
5 |
set +x |
|
6 |
for afile in target/lib/* |
|
7 |
do |
|
8 |
CLASSPATH="$CLASSPATH:$afile" |
|
9 |
done |
|
10 |
export GDAL_PLUGIN_FOLDER=$1 |
|
11 |
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GDAL_PLUGIN_FOLDER/jgdal/lib:$GDAL_PLUGIN_FOLDER/gdal/lib64:" |
|
12 |
echo 'Classpath:' |
|
13 |
echo $CLASSPATH |
|
14 |
echo 'Plugin folder:' |
|
15 |
echo $GDAL_PLUGIN_FOLDER |
|
16 |
echo 'Library path:' |
|
17 |
echo $LD_LIBRARY_PATH |
|
18 |
echo |
|
19 |
echo 'Command exec:' |
|
20 |
echo java -agentlib:jdwp=transport=dt_socket,address=8765,server=y,suspend=y -cp $CLASSPATH org.gvsig.view3d.main.Main -Djava.library.path=${LD_LIBRARY_PATH} |
|
21 |
java -agentlib:jdwp=transport=dt_socket,address=8765,server=y,suspend=y -cp $CLASSPATH org.gvsig.view3d.main.Main -Djava.library.path=${LD_LIBRARY_PATH} |
|
0 | 22 |
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.lib/org.gvsig.view3d.lib.impl/src/main/java/org/gvsig/view3d/lib/impl/DefaultView3DLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright ? 2007-2015 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 |
|
|
25 |
package org.gvsig.view3d.lib.impl; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DALLibrary; |
|
28 |
import org.gvsig.tools.ToolsLocator; |
|
29 |
import org.gvsig.tools.library.AbstractLibrary; |
|
30 |
import org.gvsig.tools.library.LibraryException; |
|
31 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
32 |
import org.gvsig.view3d.lib.api.View3DLibrary; |
|
33 |
import org.gvsig.view3d.lib.api.View3DLocator; |
|
34 |
import org.gvsig.view3d.lib.impl.properties.LayerProperties3DPersistenceFactory; |
|
35 |
import org.gvsig.view3d.lib.impl.properties.RasterLayerProperties3DPersistenceFactory; |
|
36 |
import org.gvsig.view3d.lib.impl.properties.VectorialLayerProperties3DPersistenceFactory; |
|
37 |
|
|
38 |
/** |
|
39 |
* @author <a href="mailto:lmarques@disid.com">Lluis Marques</a> |
|
40 |
* |
|
41 |
*/ |
|
42 |
public class DefaultView3DLibrary extends AbstractLibrary { |
|
43 |
|
|
44 |
@Override |
|
45 |
public void doRegistration() { |
|
46 |
registerAsImplementationOf(View3DLibrary.class); |
|
47 |
require(DALLibrary.class); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
protected void doInitialize() throws LibraryException { |
|
52 |
View3DLocator.registerManager(DefaultView3DManger.class); |
|
53 |
|
|
54 |
// Register persitence |
|
55 |
registerPersistence(); |
|
56 |
} |
|
57 |
|
|
58 |
private void registerPersistence() { |
|
59 |
PersistenceManager persistenceManager = |
|
60 |
ToolsLocator.getPersistenceManager(); |
|
61 |
persistenceManager |
|
62 |
.registerFactory(new LayerProperties3DPersistenceFactory()); |
|
63 |
persistenceManager |
|
64 |
.registerFactory(new VectorialLayerProperties3DPersistenceFactory()); |
|
65 |
persistenceManager |
|
66 |
.registerFactory(new RasterLayerProperties3DPersistenceFactory()); |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
protected void doPostInitialize() throws LibraryException { |
|
71 |
} |
|
72 |
|
|
73 |
} |
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.lib/org.gvsig.view3d.lib.impl/src/main/java/org/gvsig/view3d/lib/impl/properties/BasicLayerProperties3D.java | ||
---|---|---|
1 |
package org.gvsig.view3d.lib.impl.properties; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
4 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
|
5 |
import org.gvsig.fmap.mapcontext.layers.LayerEvent; |
|
6 |
import org.gvsig.fmap.mapcontext.layers.LayerListener; |
|
7 |
import org.gvsig.view3d.lib.api.properties.LayerProperties3D; |
|
8 |
|
|
9 |
|
|
10 |
public class BasicLayerProperties3D implements LayerProperties3D { |
|
11 |
|
|
12 |
private boolean elevation = false; |
|
13 |
private String elevationUnits; |
|
14 |
private double levelZeroResolutionMultiplier = 1; |
|
15 |
private int maxLevel = 0; |
|
16 |
private int minLevel = 0; |
|
17 |
private double noDataValue = -99999; |
|
18 |
private int tileWidth = 512; |
|
19 |
private int tileHeight = 512; |
|
20 |
private FLayer layer; |
|
21 |
|
|
22 |
public BasicLayerProperties3D(FLayer layer) { |
|
23 |
this.layer = layer; |
|
24 |
} |
|
25 |
|
|
26 |
public boolean getElevation() { |
|
27 |
return elevation; |
|
28 |
} |
|
29 |
|
|
30 |
public String getElevationUnits() { |
|
31 |
return elevationUnits; |
|
32 |
} |
|
33 |
|
|
34 |
public double getLevelZeroResolutionMultiplier() { |
|
35 |
return levelZeroResolutionMultiplier; |
|
36 |
} |
|
37 |
|
|
38 |
public int getMaxLevel() { |
|
39 |
return maxLevel; |
|
40 |
} |
|
41 |
|
|
42 |
public int getMinLevel() { |
|
43 |
return minLevel; |
|
44 |
} |
|
45 |
|
|
46 |
public double getNoDataValue() { |
|
47 |
return noDataValue; |
|
48 |
} |
|
49 |
|
|
50 |
public int getTileHeight() { |
|
51 |
return tileHeight; |
|
52 |
} |
|
53 |
|
|
54 |
public int getTileWidth() { |
|
55 |
return tileWidth; |
|
56 |
} |
|
57 |
|
|
58 |
public void setElevation(boolean elevation) { |
|
59 |
this.elevation = elevation; |
|
60 |
fireDrawValueChangedEvent("elevation"); |
|
61 |
} |
|
62 |
|
|
63 |
public void setElevationUnits(String elevation) { |
|
64 |
this.elevationUnits = elevation; |
|
65 |
fireDrawValueChangedEvent("elevationUnits"); |
|
66 |
} |
|
67 |
|
|
68 |
public void setLevelZeroResolutionMultiplier(double multiplier) { |
|
69 |
this.levelZeroResolutionMultiplier = multiplier; |
|
70 |
fireDrawValueChangedEvent("lezelZeroResolutionMultiPlier"); |
|
71 |
} |
|
72 |
|
|
73 |
public void setMaxLevel(int maxLevel) { |
|
74 |
this.maxLevel = maxLevel; |
|
75 |
fireDrawValueChangedEvent("maxLevel"); |
|
76 |
} |
|
77 |
|
|
78 |
public void setMinLevel(int minLevel) { |
|
79 |
this.minLevel = minLevel; |
|
80 |
fireDrawValueChangedEvent("minLevel"); |
|
81 |
} |
|
82 |
|
|
83 |
public void setNoDataValue(double noDataValue) { |
|
84 |
this.noDataValue = noDataValue; |
|
85 |
fireDrawValueChangedEvent("noDataValue"); |
|
86 |
|
|
87 |
} |
|
88 |
|
|
89 |
public void setTileHeight(int height) { |
|
90 |
this.tileHeight = height; |
|
91 |
fireDrawValueChangedEvent("tileHeight"); |
|
92 |
|
|
93 |
} |
|
94 |
|
|
95 |
public void setTileWidth(int width) { |
|
96 |
this.tileWidth = width; |
|
97 |
fireDrawValueChangedEvent("tileWidth"); |
|
98 |
} |
|
99 |
|
|
100 |
protected void fireDrawValueChangedEvent(String property) { |
|
101 |
LayerListener[] layerListeners = this.layer.getLayerListeners(); |
|
102 |
for (int i = 0; i < layerListeners.length; i++) { |
|
103 |
layerListeners[i].drawValueChanged(LayerEvent |
|
104 |
.createDrawValuesChangedEvent((FLyrDefault) this.layer, |
|
105 |
property)); |
|
106 |
} |
|
107 |
} |
|
108 |
|
|
109 |
public FLayer getLayer() { |
|
110 |
return this.layer; |
|
111 |
} |
|
112 |
|
|
113 |
public void setLayer(FLayer theLayer) { |
|
114 |
this.layer = theLayer; |
|
115 |
} |
|
116 |
} |
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.lib/org.gvsig.view3d.lib.impl/src/main/java/org/gvsig/view3d/lib/impl/properties/DefaultRasterLayerProperties3D.java | ||
---|---|---|
1 |
package org.gvsig.view3d.lib.impl.properties; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
4 |
import org.gvsig.view3d.lib.api.properties.RasterLayerProperties3D; |
|
5 |
|
|
6 |
public class DefaultRasterLayerProperties3D extends BasicLayerProperties3D |
|
7 |
implements RasterLayerProperties3D { |
|
8 |
|
|
9 |
public DefaultRasterLayerProperties3D(FLayer theLayer) { |
|
10 |
super(theLayer); |
|
11 |
} |
|
12 |
} |
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.lib/org.gvsig.view3d.lib.impl/src/main/java/org/gvsig/view3d/lib/impl/properties/VectorialLayerProperties3DPersistenceFactory.java | ||
---|---|---|
1 |
package org.gvsig.view3d.lib.impl.properties; |
|
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.AbstractSinglePersistenceFactory; |
|
7 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
8 |
import org.gvsig.tools.persistence.PersistentState; |
|
9 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
10 |
import org.gvsig.view3d.lib.api.properties.LayerProperties3D; |
|
11 |
import org.gvsig.view3d.lib.api.properties.VectorialLayerProperties3D; |
|
12 |
|
|
13 |
public class VectorialLayerProperties3DPersistenceFactory extends |
|
14 |
AbstractSinglePersistenceFactory { |
|
15 |
|
|
16 |
private static final String DYNCLASS_NAME = "Vectorial3DProperties"; |
|
17 |
private static final String DYNCLASS_DESCRIPTION = |
|
18 |
"Vectorial layer 3D properties persistence definition"; |
|
19 |
|
|
20 |
protected static final String FIELD_ELEVATION_FIELD = "elevationField"; |
|
21 |
protected static final String FIELD_RASTERIZED = "rasterized"; |
|
22 |
|
|
23 |
public VectorialLayerProperties3DPersistenceFactory() { |
|
24 |
super(VectorialLayerProperties3D.class, DYNCLASS_NAME, |
|
25 |
DYNCLASS_DESCRIPTION, null, null); |
|
26 |
|
|
27 |
DynStruct definition = this.getDefinition(); |
|
28 |
|
|
29 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
30 |
definition.extend(manager.getDefinition(LayerProperties3D.class)); |
|
31 |
|
|
32 |
definition.addDynFieldString(FIELD_ELEVATION_FIELD); |
|
33 |
definition.addDynFieldBoolean(FIELD_RASTERIZED); |
|
34 |
} |
|
35 |
|
|
36 |
public Object createFromState(PersistentState state) |
|
37 |
throws PersistenceException { |
|
38 |
|
|
39 |
FLayer layer = |
|
40 |
(FLayer) state.get(LayerProperties3DPersistenceFactory.FIELD_LAYER); |
|
41 |
VectorialLayerProperties3D properties = |
|
42 |
new DefaultVectorialLayerProperties3D(layer); |
|
43 |
|
|
44 |
properties.setElevation(state |
|
45 |
.getBoolean(LayerProperties3DPersistenceFactory.FIELD_ELEVATION)); |
|
46 |
properties |
|
47 |
.setElevationUnits(state |
|
48 |
.getString(LayerProperties3DPersistenceFactory.FIELD_ELEVATION_UNITS)); |
|
49 |
properties |
|
50 |
.setLevelZeroResolutionMultiplier(state |
|
51 |
.getDouble(LayerProperties3DPersistenceFactory.FIELD_LEVEL_ZERO_RESOLUTION_MULTIPLIER)); |
|
52 |
properties.setMaxLevel(state |
|
53 |
.getInt(LayerProperties3DPersistenceFactory.FIELD_MAXLEVEL)); |
|
54 |
properties.setMinLevel(state |
|
55 |
.getInt(LayerProperties3DPersistenceFactory.FIELD_MINLEVEL)); |
|
56 |
properties.setNoDataValue(state |
|
57 |
.getDouble(LayerProperties3DPersistenceFactory.FIELD_NODATA_VALUE)); |
|
58 |
properties.setTileHeight(state |
|
59 |
.getInt(LayerProperties3DPersistenceFactory.FIELD_TILE_HEIGHT)); |
|
60 |
properties.setTileWidth(state |
|
61 |
.getInt(LayerProperties3DPersistenceFactory.FIELD_TILE_WIDTH)); |
|
62 |
properties.setElevationField(state.getString(FIELD_ELEVATION_FIELD)); |
|
63 |
properties.setRasterized(state.getBoolean(FIELD_RASTERIZED)); |
|
64 |
|
|
65 |
return properties; |
|
66 |
} |
|
67 |
|
|
68 |
public void saveToState(PersistentState state, Object obj) |
|
69 |
throws PersistenceException { |
|
70 |
|
|
71 |
VectorialLayerProperties3D properties = |
|
72 |
(VectorialLayerProperties3D) obj; |
|
73 |
|
|
74 |
state.set(LayerProperties3DPersistenceFactory.FIELD_ELEVATION, |
|
75 |
properties.getElevation()); |
|
76 |
state.set(LayerProperties3DPersistenceFactory.FIELD_ELEVATION_UNITS, |
|
77 |
properties.getElevationUnits()); |
|
78 |
state |
|
79 |
.set( |
|
80 |
LayerProperties3DPersistenceFactory.FIELD_LEVEL_ZERO_RESOLUTION_MULTIPLIER, |
|
81 |
properties.getLevelZeroResolutionMultiplier()); |
|
82 |
state.set(LayerProperties3DPersistenceFactory.FIELD_MAXLEVEL, |
|
83 |
properties.getMaxLevel()); |
|
84 |
state.set(LayerProperties3DPersistenceFactory.FIELD_MINLEVEL, |
|
85 |
properties.getMinLevel()); |
|
86 |
state.set(LayerProperties3DPersistenceFactory.FIELD_NODATA_VALUE, |
|
87 |
properties.getNoDataValue()); |
|
88 |
state.set(LayerProperties3DPersistenceFactory.FIELD_TILE_HEIGHT, |
|
89 |
properties.getTileHeight()); |
|
90 |
state.set(LayerProperties3DPersistenceFactory.FIELD_TILE_WIDTH, |
|
91 |
properties.getTileWidth()); |
|
92 |
state.set(LayerProperties3DPersistenceFactory.FIELD_LAYER, |
|
93 |
properties.getLayer()); |
|
94 |
state.set(FIELD_ELEVATION_FIELD, properties.getElevationField()); |
|
95 |
state.set(FIELD_RASTERIZED, properties.getRasterized()); |
|
96 |
} |
|
97 |
|
|
98 |
} |
2.1/tags/org.gvsig.view3d-1.0.2/org.gvsig.view3d.lib/org.gvsig.view3d.lib.impl/src/main/java/org/gvsig/view3d/lib/impl/properties/LayerProperties3DPersistenceFactory.java | ||
---|---|---|
1 |
package org.gvsig.view3d.lib.impl.properties; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
4 |
import org.gvsig.tools.dynobject.DynStruct; |
|
5 |
import org.gvsig.tools.persistence.AbstractSinglePersistenceFactory; |
|
6 |
import org.gvsig.tools.persistence.PersistentState; |
|
7 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
8 |
import org.gvsig.view3d.lib.api.properties.LayerProperties3D; |
|
9 |
|
|
10 |
|
|
11 |
public class LayerProperties3DPersistenceFactory extends |
|
12 |
AbstractSinglePersistenceFactory { |
|
13 |
|
|
14 |
private static final String DYNCLASS_NAME = "Layer3DProperties"; |
|
15 |
private static final String DYNCLASS_DESCRIPTION = |
|
16 |
"Basic layer 3D properties persistence definition"; |
|
17 |
|
|
18 |
protected static final String FIELD_ELEVATION = "elevation"; |
|
19 |
protected static final String FIELD_ELEVATION_UNITS = "elevationUnits"; |
|
20 |
protected static final String FIELD_LEVEL_ZERO_RESOLUTION_MULTIPLIER = "lezelZeroResolutionMultiPlier"; |
|
21 |
protected static final String FIELD_MAXLEVEL = "maxLevel"; |
|
22 |
protected static final String FIELD_MINLEVEL = "minLevel"; |
|
23 |
protected static final String FIELD_NODATA_VALUE= "noDataValue"; |
|
24 |
protected static final String FIELD_TILE_HEIGHT = "tileHeight"; |
|
25 |
protected static final String FIELD_TILE_WIDTH = "tileWidth"; |
|
26 |
protected static final String FIELD_LAYER = "layer"; |
|
27 |
|
|
28 |
public LayerProperties3DPersistenceFactory() { |
|
29 |
super(LayerProperties3D.class, DYNCLASS_NAME, DYNCLASS_DESCRIPTION, |
|
30 |
null, null); |
|
31 |
|
|
32 |
DynStruct definition = this.getDefinition(); |
|
33 |
definition.addDynFieldBoolean(FIELD_ELEVATION); |
|
34 |
definition.addDynFieldString(FIELD_ELEVATION_UNITS); |
|
35 |
definition.addDynFieldDouble(FIELD_LEVEL_ZERO_RESOLUTION_MULTIPLIER); |
|
36 |
definition.addDynFieldInt(FIELD_MAXLEVEL); |
|
37 |
definition.addDynFieldInt(FIELD_MINLEVEL); |
|
38 |
definition.addDynFieldDouble(FIELD_NODATA_VALUE); |
|
39 |
definition.addDynFieldInt(FIELD_TILE_HEIGHT); |
Also available in: Unified diff