Revision 443
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.app/org.gvsig.view3d.app.common/src/main/java/org/gvsig/view3d/app/mainplugin/View3DExtension.java | ||
---|---|---|
25 | 25 |
package org.gvsig.view3d.app.mainplugin; |
26 | 26 |
|
27 | 27 |
import org.gvsig.andami.plugins.Extension; |
28 |
import org.gvsig.view3d.swing.api.View3DLocator; |
|
29 |
import org.gvsig.view3d.swing.api.View3DManager; |
|
28 |
import org.gvsig.view3d.swing.api.View3DSwingLocator; |
|
29 |
import org.gvsig.view3d.swing.api.View3DSwingManager; |
|
30 |
import org.gvsig.view3d.swing.api.View3DSwingManager.TYPE; |
|
30 | 31 |
import org.gvsig.view3d.swing.api.View3DPanel; |
31 |
import org.gvsig.view3d.swing.api.View3DPanel.TYPE; |
|
32 | 32 |
|
33 | 33 |
|
34 | 34 |
/** |
... | ... | |
41 | 41 |
} |
42 | 42 |
|
43 | 43 |
public void execute(String actionCommand) { |
44 |
View3DManager manager = View3DLocator.getManager();
|
|
44 |
View3DSwingManager manager = View3DSwingLocator.getManager();
|
|
45 | 45 |
View3DPanel createView3DPanel = manager.createView3DPanel(null, TYPE.SPHERE); |
46 | 46 |
createView3DPanel.show(); |
47 | 47 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.main/src/main/java/org/gvsig/view3d/main/PaletteActions.java | ||
---|---|---|
52 | 52 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
53 | 53 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
54 | 54 |
import org.gvsig.utils.GenericFileFilter; |
55 |
import org.gvsig.view3d.swing.api.View3DLocator; |
|
56 |
import org.gvsig.view3d.swing.api.View3DManager; |
|
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; |
|
57 | 58 |
import org.gvsig.view3d.swing.api.View3DPanel; |
58 |
import org.gvsig.view3d.swing.api.View3DPanel.TYPE; |
|
59 | 59 |
|
60 | 60 |
/** |
61 | 61 |
* @author llmarques |
... | ... | |
243 | 243 |
private static final long serialVersionUID = 7506436995278783992L; |
244 | 244 |
|
245 | 245 |
public void actionPerformed(ActionEvent e) { |
246 |
View3DManager manager = View3DLocator.getManager();
|
|
246 |
View3DSwingManager manager = View3DSwingLocator.getManager();
|
|
247 | 247 |
View3DPanel view3dPanel = |
248 | 248 |
manager.createView3DPanel(main.getMapContext(), TYPE.SPHERE); |
249 |
// Change value for constant key |
|
250 | 249 |
view3dPanel.show(); |
251 | 250 |
} |
252 | 251 |
}; |
... | ... | |
289 | 288 |
private static final long serialVersionUID = 7506436995278783992L; |
290 | 289 |
|
291 | 290 |
public void actionPerformed(ActionEvent e) { |
292 |
View3DManager manager = View3DLocator.getManager();
|
|
291 |
View3DSwingManager manager = View3DSwingLocator.getManager();
|
|
293 | 292 |
View3DPanel view3dPanel = |
294 | 293 |
manager.createView3DPanel(main.getMapContext(), TYPE.FLAT); |
295 | 294 |
// Change value for constant key |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.main/src/main/java/org/gvsig/view3d/main/Main.java | ||
---|---|---|
77 | 77 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
78 | 78 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
79 | 79 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
80 |
import org.gvsig.view3d.swing.api.View3DLocator; |
|
81 |
import org.gvsig.view3d.swing.api.View3DManager; |
|
80 |
import org.gvsig.view3d.swing.api.View3DSwingLocator;
|
|
81 |
import org.gvsig.view3d.swing.api.View3DSwingManager;
|
|
82 | 82 |
|
83 | 83 |
/** |
84 | 84 |
* @author llmarques |
... | ... | |
88 | 88 |
|
89 | 89 |
private static final Logger logger = LoggerFactory.getLogger(Main.class); |
90 | 90 |
|
91 |
final View3DManager view3DManager; |
|
91 |
final View3DSwingManager view3DManager;
|
|
92 | 92 |
|
93 | 93 |
final MapControlManager mapControlManager; |
94 | 94 |
|
... | ... | |
115 | 115 |
MouseListener treeMouseListener; |
116 | 116 |
|
117 | 117 |
public Main() { |
118 |
view3DManager = View3DLocator.getManager(); |
|
118 |
view3DManager = View3DSwingLocator.getManager();
|
|
119 | 119 |
mapControlManager = MapControlLocator.getMapControlManager(); |
120 | 120 |
dataManager = DALLocator.getDataManager(); |
121 | 121 |
mapContextManager = MapContextLocator.getMapContextManager(); |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.api/src/main/java/org/gvsig/view3d/swing/api/AbstractView3DPanel.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.swing.api; |
|
26 |
|
|
27 |
import gov.nasa.worldwind.Configuration; |
|
28 |
import gov.nasa.worldwind.Model; |
|
29 |
import gov.nasa.worldwind.WorldWind; |
|
30 |
import gov.nasa.worldwind.avlist.AVKey; |
|
31 |
import gov.nasa.worldwind.awt.WorldWindowGLJPanel; |
|
32 |
import gov.nasa.worldwind.globes.Earth; |
|
33 |
import gov.nasa.worldwind.globes.EarthFlat; |
|
34 |
import gov.nasa.worldwind.layers.ViewControlsLayer; |
|
35 |
import gov.nasa.worldwind.layers.ViewControlsSelectListener; |
|
36 |
import gov.nasa.worldwind.terrain.ZeroElevationModel; |
|
37 |
import gov.nasa.worldwind.util.StatusBar; |
|
38 |
import gov.nasa.worldwind.view.orbit.BasicOrbitView; |
|
39 |
import gov.nasa.worldwind.view.orbit.FlatOrbitView; |
|
40 |
|
|
41 |
import java.awt.BorderLayout; |
|
42 |
import java.awt.Dimension; |
|
43 |
import java.io.File; |
|
44 |
import java.net.URL; |
|
45 |
|
|
46 |
import javax.swing.JPanel; |
|
47 |
|
|
48 |
/** |
|
49 |
* @author llmarques |
|
50 |
* |
|
51 |
*/ |
|
52 |
public abstract class AbstractView3DPanel extends JPanel implements View3DPanel { |
|
53 |
|
|
54 |
private static final long serialVersionUID = -5520926159828176663L; |
|
55 |
|
|
56 |
private WorldWindowGLJPanel wwd; |
|
57 |
|
|
58 |
/** |
|
59 |
* @param borderLayout |
|
60 |
*/ |
|
61 |
public AbstractView3DPanel(BorderLayout borderLayout, TYPE type) { |
|
62 |
super(borderLayout); |
|
63 |
|
|
64 |
// Load configuration file |
|
65 |
URL configURL = this.getClass().getResource("/config/worldwind.xml"); |
|
66 |
|
|
67 |
if (configURL != null) { |
|
68 |
File configFile = new File(configURL.getPath()); |
|
69 |
Configuration.insertConfigurationDocument(configFile.getAbsolutePath()); |
|
70 |
} |
|
71 |
|
|
72 |
// Set mode before instantiation |
|
73 |
if (type == TYPE.SPHERE) { |
|
74 |
setSpherePanelConfiguration(); |
|
75 |
} else if (type == TYPE.SPHERE) { |
|
76 |
setFlatPanelConfiguration(); |
|
77 |
} |
|
78 |
|
|
79 |
this.add(getWwd(), BorderLayout.CENTER); |
|
80 |
|
|
81 |
this.add(getStatusBar(), BorderLayout.SOUTH); |
|
82 |
} |
|
83 |
|
|
84 |
private void intializeWWPanel() { |
|
85 |
wwd = new WorldWindowGLJPanel(); |
|
86 |
wwd.setPreferredSize(new Dimension(800, 600)); |
|
87 |
|
|
88 |
// Create the default model as described in the current worldwind |
|
89 |
// properties. |
|
90 |
Model m = |
|
91 |
(Model) WorldWind |
|
92 |
.createConfigurationComponent(AVKey.MODEL_CLASS_NAME); |
|
93 |
this.wwd.setModel(m); |
|
94 |
|
|
95 |
// Add view control layer |
|
96 |
addNavigation(); |
|
97 |
} |
|
98 |
|
|
99 |
private void addNavigation() { |
|
100 |
|
|
101 |
ViewControlsLayer controlsLayer = new ViewControlsLayer(); |
|
102 |
|
|
103 |
Model model = this.wwd.getModel(); |
|
104 |
model.getLayers().add(controlsLayer); |
|
105 |
|
|
106 |
this.wwd.addSelectListener(new ViewControlsSelectListener(wwd, |
|
107 |
controlsLayer)); |
|
108 |
} |
|
109 |
|
|
110 |
private StatusBar getStatusBar() { |
|
111 |
StatusBar statusBar = new StatusBar(); |
|
112 |
this.add(statusBar, BorderLayout.PAGE_END); |
|
113 |
statusBar.setEventSource(wwd); |
|
114 |
return statusBar; |
|
115 |
} |
|
116 |
|
|
117 |
protected WorldWindowGLJPanel getWwd() { |
|
118 |
if (this.wwd == null) { |
|
119 |
intializeWWPanel(); |
|
120 |
} |
|
121 |
return this.wwd; |
|
122 |
} |
|
123 |
|
|
124 |
private void setSpherePanelConfiguration() { |
|
125 |
Configuration.setValue(AVKey.GLOBE_CLASS_NAME, Earth.class.getName()); |
|
126 |
Configuration.setValue(AVKey.VIEW_CLASS_NAME, |
|
127 |
BasicOrbitView.class.getName()); |
|
128 |
} |
|
129 |
|
|
130 |
private void setFlatPanelConfiguration() { |
|
131 |
Configuration.setValue(AVKey.GLOBE_CLASS_NAME, |
|
132 |
EarthFlat.class.getName()); |
|
133 |
Configuration.setValue(AVKey.VIEW_CLASS_NAME, |
|
134 |
FlatOrbitView.class.getName()); |
|
135 |
} |
|
136 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.api/src/main/java/org/gvsig/view3d/swing/api/View3DLocator.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.swing.api; |
|
26 |
|
|
27 |
import org.gvsig.tools.locator.BaseLocator; |
|
28 |
import org.gvsig.tools.locator.LocatorException; |
|
29 |
|
|
30 |
/** |
|
31 |
* This locator is the entry point for the View 3D library, providing |
|
32 |
* access to View3D services through the {@link View3DManager} . |
|
33 |
* |
|
34 |
* @author lmarques |
|
35 |
* @version $Id$ |
|
36 |
*/ |
|
37 |
public class View3DLocator extends BaseLocator { |
|
38 |
|
|
39 |
private static final String LOCATOR_NAME = "View3DLocator"; |
|
40 |
|
|
41 |
public static final String MANAGER_NAME = "View3D.manager"; |
|
42 |
|
|
43 |
private static final String MANAGER_DESCRIPTION = "View 3D Swing Manager"; |
|
44 |
|
|
45 |
private static final View3DLocator instance = new View3DLocator(); |
|
46 |
|
|
47 |
/** |
|
48 |
* Return the singleton instance. |
|
49 |
* |
|
50 |
* @return the singleton instance |
|
51 |
*/ |
|
52 |
public static View3DLocator getInstance() { |
|
53 |
return instance; |
|
54 |
} |
|
55 |
|
|
56 |
public String getLocatorName() { |
|
57 |
return LOCATOR_NAME; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Return a reference to View3DManager. |
|
62 |
* |
|
63 |
* @return a reference to View3DManager |
|
64 |
* @throws LocatorException |
|
65 |
* if there is no access to the class or the class |
|
66 |
* cannot be instantiated |
|
67 |
* @see Locator#get(String)View3DManager |
|
68 |
*/ |
|
69 |
public static View3DManager getManager() throws LocatorException { |
|
70 |
return (View3DManager) getInstance().get(MANAGER_NAME); |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Registers the Class implementing the View3DLocator interface. |
|
75 |
* |
|
76 |
* @param clazz |
|
77 |
* implementing the View3DManager interface |
|
78 |
*/ |
|
79 |
public static void registerManager(Class clazz) { |
|
80 |
getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
|
81 |
} |
|
82 |
|
|
83 |
public static void registerDefaultManager(Class clazz) { |
|
84 |
getInstance().registerDefault(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
|
85 |
} |
|
86 |
|
|
87 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.api/src/main/java/org/gvsig/view3d/swing/api/View3DLibrary.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.swing.api; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DALLibrary; |
|
28 |
import org.gvsig.tools.library.AbstractLibrary; |
|
29 |
import org.gvsig.tools.library.LibraryException; |
|
30 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author llmarques |
|
34 |
* |
|
35 |
*/ |
|
36 |
public class View3DLibrary extends AbstractLibrary { |
|
37 |
|
|
38 |
@Override |
|
39 |
public void doRegistration() { |
|
40 |
registerAsAPI(View3DLibrary.class); |
|
41 |
require(DALLibrary.class); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
protected void doInitialize() throws LibraryException { |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
protected void doPostInitialize() throws LibraryException { |
|
50 |
View3DManager manager = View3DLocator.getManager(); |
|
51 |
if (manager == null) { |
|
52 |
throw new ReferenceNotRegisteredException( |
|
53 |
View3DLocator.MANAGER_NAME, View3DLocator.getInstance()); |
|
54 |
} |
|
55 |
} |
|
56 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.api/src/main/java/org/gvsig/view3d/swing/api/View3DManager.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.swing.api; |
|
26 |
|
|
27 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
28 |
import org.gvsig.view3d.swing.api.View3DPanel.TYPE; |
|
29 |
|
|
30 |
/** |
|
31 |
* @author llmarques |
|
32 |
* |
|
33 |
*/ |
|
34 |
public interface View3DManager { |
|
35 |
|
|
36 |
/** |
|
37 |
* |
|
38 |
* @param theMapContext |
|
39 |
* @param mode |
|
40 |
* @return |
|
41 |
*/ |
|
42 |
public View3DPanel createView3DPanel(MapContext theMapContext, TYPE mode); |
|
43 |
|
|
44 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.api/src/main/java/org/gvsig/view3d/swing/api/View3DSwingManager.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.swing.api; |
|
26 |
|
|
27 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
28 |
|
|
29 |
/** |
|
30 |
* @author llmarques |
|
31 |
* |
|
32 |
*/ |
|
33 |
public interface View3DSwingManager { |
|
34 |
|
|
35 |
public enum TYPE{ SPHERE,FLAT } |
|
36 |
|
|
37 |
/** |
|
38 |
* |
|
39 |
* @param theMapContext |
|
40 |
* @param type |
|
41 |
* @return |
|
42 |
*/ |
|
43 |
public View3DPanel createView3DPanel(MapContext theMapContext, TYPE type); |
|
44 |
|
|
45 |
/** |
|
46 |
* |
|
47 |
* @param theMapContext |
|
48 |
* @param type |
|
49 |
* @return |
|
50 |
*/ |
|
51 |
public MapControl3D createMapControl3D(MapContext theMapContext, TYPE type); |
|
52 |
|
|
53 |
|
|
54 |
//TODO: Add methods to get properties panels. |
|
55 |
|
|
56 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.api/src/main/java/org/gvsig/view3d/swing/api/MapControl3D.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.swing.api; |
|
26 |
|
|
27 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
28 |
import org.gvsig.tools.swing.api.Component; |
|
29 |
import org.gvsig.view3d.swing.api.View3DSwingManager.TYPE; |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* @author llmarques |
|
34 |
* |
|
35 |
*/ |
|
36 |
public interface MapControl3D extends Component{ |
|
37 |
|
|
38 |
/** |
|
39 |
* |
|
40 |
* @return |
|
41 |
*/ |
|
42 |
public MapContext getMapContext(); |
|
43 |
|
|
44 |
/** |
|
45 |
* |
|
46 |
* @return |
|
47 |
*/ |
|
48 |
public TYPE getType(); |
|
49 |
|
|
50 |
/** |
|
51 |
* |
|
52 |
* @return |
|
53 |
*/ |
|
54 |
public double getVerticalExaggeration(); |
|
55 |
|
|
56 |
/** |
|
57 |
* |
|
58 |
*/ |
|
59 |
public void hideAtmosphere(); |
|
60 |
|
|
61 |
/** |
|
62 |
* |
|
63 |
*/ |
|
64 |
public void hideMiniMap(); |
|
65 |
|
|
66 |
/** |
|
67 |
* |
|
68 |
*/ |
|
69 |
public void hideNorthIndicator(); |
|
70 |
|
|
71 |
/** |
|
72 |
* |
|
73 |
*/ |
|
74 |
public void hideScale(); |
|
75 |
|
|
76 |
/** |
|
77 |
* |
|
78 |
*/ |
|
79 |
public void hideStarBackground(); |
|
80 |
|
|
81 |
/** |
|
82 |
* |
|
83 |
*/ |
|
84 |
public void reloadLayers(); |
|
85 |
|
|
86 |
/** |
|
87 |
* |
|
88 |
*/ |
|
89 |
public void setMapContext(MapContext theMapContext); |
|
90 |
|
|
91 |
/** |
|
92 |
* |
|
93 |
*/ |
|
94 |
public void setVerticalExaggeration(double verticalExaggeration); |
|
95 |
|
|
96 |
/** |
|
97 |
* |
|
98 |
*/ |
|
99 |
public void showAtmosphere(); |
|
100 |
|
|
101 |
/** |
|
102 |
* |
|
103 |
*/ |
|
104 |
public void showMiniMap(); |
|
105 |
|
|
106 |
/** |
|
107 |
* |
|
108 |
*/ |
|
109 |
public void showNortIndicator(); |
|
110 |
|
|
111 |
/** |
|
112 |
* |
|
113 |
*/ |
|
114 |
public void showScale(); |
|
115 |
|
|
116 |
/** |
|
117 |
* |
|
118 |
*/ |
|
119 |
public void showStarBackgroundLayer(); |
|
120 |
|
|
121 |
/** |
|
122 |
* |
|
123 |
*/ |
|
124 |
public void synchronizeViewPorts(); |
|
125 |
|
|
126 |
/** |
|
127 |
* |
|
128 |
*/ |
|
129 |
public void synchronizeLayers(); |
|
130 |
|
|
131 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.api/src/main/java/org/gvsig/view3d/swing/api/View3DSwingLocator.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.swing.api; |
|
26 |
|
|
27 |
import org.gvsig.tools.locator.BaseLocator; |
|
28 |
import org.gvsig.tools.locator.LocatorException; |
|
29 |
|
|
30 |
/** |
|
31 |
* This locator is the entry point for the View 3D swing library, providing |
|
32 |
* access to View3D swing services through the {@link View3DSwingManager} . |
|
33 |
* |
|
34 |
* @author lmarques |
|
35 |
* @version $Id$ |
|
36 |
*/ |
|
37 |
public class View3DSwingLocator extends BaseLocator { |
|
38 |
|
|
39 |
private static final String LOCATOR_NAME = "View3DSwingLocator"; |
|
40 |
|
|
41 |
public static final String MANAGER_NAME = "View3D.SwingManager"; |
|
42 |
|
|
43 |
private static final String MANAGER_DESCRIPTION = "View 3D Swing Manager"; |
|
44 |
|
|
45 |
private static final View3DSwingLocator instance = new View3DSwingLocator(); |
|
46 |
|
|
47 |
/** |
|
48 |
* Return the singleton instance. |
|
49 |
* |
|
50 |
* @return the singleton instance |
|
51 |
*/ |
|
52 |
public static View3DSwingLocator getInstance() { |
|
53 |
return instance; |
|
54 |
} |
|
55 |
|
|
56 |
public String getLocatorName() { |
|
57 |
return LOCATOR_NAME; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Return a reference to View3DSwingManager. |
|
62 |
* |
|
63 |
* @return a reference to View3DSwingManager |
|
64 |
* @throws LocatorException |
|
65 |
* if there is no access to the class or the class |
|
66 |
* cannot be instantiated |
|
67 |
* @see Locator#get(String)View3DSwingManager |
|
68 |
*/ |
|
69 |
public static View3DSwingManager getManager() throws LocatorException { |
|
70 |
return (View3DSwingManager) getInstance().get(MANAGER_NAME); |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Registers the Class implementing the View3DSwingLocator interface. |
|
75 |
* |
|
76 |
* @param clazz |
|
77 |
* implementing the View3DSwingManager interface |
|
78 |
*/ |
|
79 |
public static void registerManager(Class clazz) { |
|
80 |
getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
|
81 |
} |
|
82 |
|
|
83 |
public static void registerDefaultManager(Class clazz) { |
|
84 |
getInstance().registerDefault(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
|
85 |
} |
|
86 |
|
|
87 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.api/src/main/java/org/gvsig/view3d/swing/api/View3DSwingLibrary.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.swing.api; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DALLibrary; |
|
28 |
import org.gvsig.tools.library.AbstractLibrary; |
|
29 |
import org.gvsig.tools.library.LibraryException; |
|
30 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author llmarques |
|
34 |
* |
|
35 |
*/ |
|
36 |
public class View3DSwingLibrary extends AbstractLibrary { |
|
37 |
|
|
38 |
@Override |
|
39 |
public void doRegistration() { |
|
40 |
registerAsAPI(View3DSwingLibrary.class); |
|
41 |
require(DALLibrary.class); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
protected void doInitialize() throws LibraryException { |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
protected void doPostInitialize() throws LibraryException { |
|
50 |
View3DSwingManager manager = View3DSwingLocator.getManager(); |
|
51 |
if (manager == null) { |
|
52 |
throw new ReferenceNotRegisteredException( |
|
53 |
View3DSwingLocator.MANAGER_NAME, View3DSwingLocator.getInstance()); |
|
54 |
} |
|
55 |
} |
|
56 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.api/src/main/java/org/gvsig/view3d/swing/api/View3DPanel.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
package org.gvsig.view3d.swing.api; |
26 | 26 |
|
27 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
28 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
29 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
30 | 27 |
import org.gvsig.tools.swing.api.Component; |
31 | 28 |
|
32 | 29 |
/** |
... | ... | |
35 | 32 |
*/ |
36 | 33 |
public interface View3DPanel extends Component { |
37 | 34 |
|
38 |
public enum TYPE{ SPHERE,FLAT } |
|
39 |
|
|
40 | 35 |
/** |
41 | 36 |
* |
42 |
* @param layer |
|
43 |
*/ |
|
44 |
public void add(FLayer layer); |
|
45 |
|
|
46 |
/** |
|
47 |
* |
|
48 |
* @param layer |
|
49 |
*/ |
|
50 |
public void add(FLayers layer); |
|
51 |
|
|
52 |
/** |
|
53 |
* |
|
54 | 37 |
* @return |
55 | 38 |
*/ |
56 |
public MapContext getMapContext();
|
|
39 |
public MapControl3D getMapControl3D();
|
|
57 | 40 |
|
58 | 41 |
/** |
59 | 42 |
* |
60 |
* @return |
|
61 | 43 |
*/ |
62 |
public TYPE getType(); |
|
63 |
|
|
64 |
/** |
|
65 |
* |
|
66 |
* @return |
|
67 |
*/ |
|
68 |
public double getVerticalExaggeration(); |
|
69 |
|
|
70 |
/** |
|
71 |
* |
|
72 |
*/ |
|
73 |
public void hideAtmosphere(); |
|
74 |
|
|
75 |
/** |
|
76 |
* |
|
77 |
*/ |
|
78 |
public void hideMiniMap(); |
|
79 |
|
|
80 |
/** |
|
81 |
* |
|
82 |
*/ |
|
83 |
public void hideStarBackground(); |
|
84 |
|
|
85 |
/** |
|
86 |
* |
|
87 |
*/ |
|
88 |
public void hideNorthIndicator(); |
|
89 |
|
|
90 |
/** |
|
91 |
* |
|
92 |
*/ |
|
93 |
public void hideScale(); |
|
94 |
|
|
95 |
/** |
|
96 |
* |
|
97 |
*/ |
|
98 |
public void reloadLayers(); |
|
99 |
|
|
100 |
/** |
|
101 |
* |
|
102 |
*/ |
|
103 |
public void remove(FLayer layer); |
|
104 |
|
|
105 |
/** |
|
106 |
* |
|
107 |
*/ |
|
108 |
public void removeAllLayers(); |
|
109 |
|
|
110 |
/** |
|
111 |
* |
|
112 |
*/ |
|
113 |
public void setMapContext(MapContext theMapContext); |
|
114 |
|
|
115 |
/** |
|
116 |
* |
|
117 |
*/ |
|
118 |
public void setVerticalExaggeration(double verticalExaggeration); |
|
119 |
|
|
120 |
/** |
|
121 |
* |
|
122 |
*/ |
|
123 | 44 |
public void show(); |
124 | 45 |
|
125 |
/** |
|
126 |
* |
|
127 |
*/ |
|
128 |
public void showAtmosphere(); |
|
129 |
|
|
130 |
/** |
|
131 |
* |
|
132 |
*/ |
|
133 |
public void showNortIndicator(); |
|
134 |
|
|
135 |
/** |
|
136 |
* |
|
137 |
*/ |
|
138 |
public void showMiniMap(); |
|
139 |
|
|
140 |
/** |
|
141 |
* |
|
142 |
*/ |
|
143 |
public void showScale(); |
|
144 |
|
|
145 |
/** |
|
146 |
* |
|
147 |
*/ |
|
148 |
public void showStarBackgroundLayer(); |
|
149 |
|
|
150 |
/** |
|
151 |
* |
|
152 |
*/ |
|
153 |
public void synchronizeViewPorts(); |
|
154 |
|
|
155 | 46 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.view3d.swing.api.View3DLibrary |
|
1 |
org.gvsig.view3d.swing.api.View3DSwingLibrary |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/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.swing.impl; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DALLibrary; |
|
28 |
import org.gvsig.tools.library.AbstractLibrary; |
|
29 |
import org.gvsig.tools.library.LibraryException; |
|
30 |
import org.gvsig.view3d.swing.api.View3DLibrary; |
|
31 |
import org.gvsig.view3d.swing.api.View3DLocator; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author llmarques |
|
35 |
* |
|
36 |
*/ |
|
37 |
public class DefaultView3DLibrary extends AbstractLibrary { |
|
38 |
|
|
39 |
@Override |
|
40 |
public void doRegistration() { |
|
41 |
registerAsImplementationOf(View3DLibrary.class); |
|
42 |
require(DALLibrary.class); |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
protected void doInitialize() throws LibraryException { |
|
47 |
View3DLocator.registerManager(DefaultView3DManager.class); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
protected void doPostInitialize() throws LibraryException { |
|
52 |
} |
|
53 |
|
|
54 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/impl/DefaultView3DManager.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.swing.impl; |
|
26 |
|
|
27 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
28 |
import org.gvsig.view3d.swing.api.View3DManager; |
|
29 |
import org.gvsig.view3d.swing.api.View3DPanel; |
|
30 |
import org.gvsig.view3d.swing.api.View3DPanel.TYPE; |
|
31 |
|
|
32 |
|
|
33 |
/** |
|
34 |
* @author llmarques |
|
35 |
* |
|
36 |
*/ |
|
37 |
public class DefaultView3DManager implements View3DManager { |
|
38 |
|
|
39 |
public View3DPanel createView3DPanel(MapContext theMapContext, TYPE type) { |
|
40 |
return new DefaultView3DPanel(theMapContext, type); |
|
41 |
} |
|
42 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/impl/DefaultView3DSwingManager.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.swing.impl; |
|
26 |
|
|
27 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
28 |
import org.gvsig.view3d.swing.api.MapControl3D; |
|
29 |
import org.gvsig.view3d.swing.api.View3DSwingManager; |
|
30 |
import org.gvsig.view3d.swing.api.View3DPanel; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author llmarques |
|
34 |
* |
|
35 |
*/ |
|
36 |
public class DefaultView3DSwingManager implements View3DSwingManager { |
|
37 |
|
|
38 |
public MapControl3D createMapControl3D(MapContext theMapContext, TYPE type) { |
|
39 |
return new DefaultMapControl3D(theMapContext, type); |
|
40 |
} |
|
41 |
|
|
42 |
public View3DPanel createView3DPanel(MapContext theMapContext, TYPE type) { |
|
43 |
return new DefaultView3DPanel(theMapContext, type); |
|
44 |
} |
|
45 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/impl/DefaultMapControl3D.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.swing.impl; |
|
26 |
|
|
27 |
import gov.nasa.worldwind.Configuration; |
|
28 |
import gov.nasa.worldwind.Model; |
|
29 |
import gov.nasa.worldwind.WorldWind; |
|
30 |
import gov.nasa.worldwind.avlist.AVKey; |
|
31 |
import gov.nasa.worldwind.awt.WorldWindowGLJPanel; |
|
32 |
import gov.nasa.worldwind.globes.Earth; |
|
33 |
import gov.nasa.worldwind.globes.EarthFlat; |
|
34 |
import gov.nasa.worldwind.globes.Globe; |
|
35 |
import gov.nasa.worldwind.layers.CompassLayer; |
|
36 |
import gov.nasa.worldwind.layers.Layer; |
|
37 |
import gov.nasa.worldwind.layers.LayerList; |
|
38 |
import gov.nasa.worldwind.layers.ScalebarLayer; |
|
39 |
import gov.nasa.worldwind.layers.SkyColorLayer; |
|
40 |
import gov.nasa.worldwind.layers.SkyGradientLayer; |
|
41 |
import gov.nasa.worldwind.layers.StarsLayer; |
|
42 |
import gov.nasa.worldwind.layers.ViewControlsLayer; |
|
43 |
import gov.nasa.worldwind.layers.ViewControlsSelectListener; |
|
44 |
import gov.nasa.worldwind.layers.WorldMapLayer; |
|
45 |
import gov.nasa.worldwind.util.StatusBar; |
|
46 |
import gov.nasa.worldwind.view.orbit.BasicOrbitView; |
|
47 |
import gov.nasa.worldwind.view.orbit.FlatOrbitView; |
|
48 |
|
|
49 |
import java.awt.BorderLayout; |
|
50 |
import java.awt.Dimension; |
|
51 |
import java.io.File; |
|
52 |
import java.lang.reflect.Constructor; |
|
53 |
import java.lang.reflect.InvocationTargetException; |
|
54 |
import java.net.URL; |
|
55 |
import java.util.List; |
|
56 |
|
|
57 |
import javax.swing.JComponent; |
|
58 |
import javax.swing.JPanel; |
|
59 |
|
|
60 |
import org.slf4j.Logger; |
|
61 |
import org.slf4j.LoggerFactory; |
|
62 |
|
|
63 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
64 |
import org.gvsig.view3d.swing.api.MapControl3D; |
|
65 |
import org.gvsig.view3d.swing.api.View3DSwingManager.TYPE; |
|
66 |
|
|
67 |
/** |
|
68 |
* @author llmarques |
|
69 |
* |
|
70 |
*/ |
|
71 |
public class DefaultMapControl3D extends JPanel implements MapControl3D { |
|
72 |
|
|
73 |
private static final long serialVersionUID = 2024899922367896097L; |
|
74 |
|
|
75 |
private static final Logger logger = LoggerFactory |
|
76 |
.getLogger(DefaultMapControl3D.class); |
|
77 |
|
|
78 |
private MapContext mapContext; |
|
79 |
|
|
80 |
private WorldWindowGLJPanel wwd; |
|
81 |
|
|
82 |
private TYPE type; |
|
83 |
|
|
84 |
public DefaultMapControl3D(MapContext theMapContext, TYPE type) { |
|
85 |
|
|
86 |
super(new BorderLayout()); |
|
87 |
|
|
88 |
this.mapContext = theMapContext; |
|
89 |
this.type = type; |
|
90 |
|
|
91 |
// Load configuration file |
|
92 |
URL configURL = this.getClass().getResource("/config/worldwind.xml"); |
|
93 |
|
|
94 |
if (configURL != null) { |
|
95 |
File configFile = new File(configURL.getPath()); |
|
96 |
Configuration.insertConfigurationDocument(configFile |
|
97 |
.getAbsolutePath()); |
|
98 |
} |
|
99 |
|
|
100 |
// Set mode before instantiation |
|
101 |
if (type == TYPE.SPHERE) { |
|
102 |
setSpherePanelConfiguration(); |
|
103 |
} else if (type == TYPE.SPHERE) { |
|
104 |
setFlatPanelConfiguration(); |
|
105 |
} |
|
106 |
|
|
107 |
this.add(getWwd(), BorderLayout.CENTER); |
|
108 |
|
|
109 |
this.add(getStatusBar(), BorderLayout.SOUTH); |
|
110 |
|
|
111 |
// add(this.mapContext.getLayers()); |
|
112 |
|
|
113 |
} |
|
114 |
|
|
115 |
@SuppressWarnings("rawtypes") |
|
116 |
private void addLayer(Class layerClazz) throws InstantiationException, |
|
117 |
IllegalAccessException, IllegalArgumentException, |
|
118 |
InvocationTargetException { |
|
119 |
LayerList layerList = getWwd().getModel().getLayers(); |
|
120 |
|
|
121 |
if (isAlreadyAdded(layerList, layerClazz)) { |
|
122 |
return; |
|
123 |
} |
|
124 |
|
|
125 |
Constructor[] constructors = layerClazz.getConstructors(); |
|
126 |
for (int i = 0; i < constructors.length; i++) { |
|
127 |
if (constructors[i].getParameterTypes().length == 0) { |
|
128 |
layerList.add((Layer) constructors[i].newInstance()); |
|
129 |
} |
|
130 |
} |
|
131 |
} |
|
132 |
|
|
133 |
private void addNavigation() { |
|
134 |
|
|
135 |
ViewControlsLayer controlsLayer = new ViewControlsLayer(); |
|
136 |
|
|
137 |
Model model = getWwd().getModel(); |
|
138 |
model.getLayers().add(controlsLayer); |
|
139 |
|
|
140 |
getWwd().addSelectListener( |
|
141 |
new ViewControlsSelectListener(wwd, controlsLayer)); |
|
142 |
} |
|
143 |
|
|
144 |
public JComponent asJComponent() { |
|
145 |
return this; |
|
146 |
} |
|
147 |
|
|
148 |
public MapContext getMapContext() { |
|
149 |
return this.mapContext; |
|
150 |
} |
|
151 |
|
|
152 |
private StatusBar getStatusBar() { |
|
153 |
StatusBar statusBar = new StatusBar(); |
|
154 |
this.add(statusBar, BorderLayout.PAGE_END); |
|
155 |
statusBar.setEventSource(wwd); |
|
156 |
return statusBar; |
|
157 |
} |
|
158 |
|
|
159 |
public TYPE getType() { |
|
160 |
return this.type; |
|
161 |
} |
|
162 |
|
|
163 |
public double getVerticalExaggeration() { |
|
164 |
return getWwd().getSceneController().getVerticalExaggeration(); |
|
165 |
} |
|
166 |
|
|
167 |
protected WorldWindowGLJPanel getWwd() { |
|
168 |
if (this.wwd == null) { |
|
169 |
intializeWWPanel(); |
|
170 |
} |
|
171 |
return this.wwd; |
|
172 |
} |
|
173 |
|
|
174 |
public void hideAtmosphere() { |
|
175 |
hideLayer(SkyGradientLayer.class); |
|
176 |
} |
|
177 |
|
|
178 |
@SuppressWarnings("rawtypes") |
|
179 |
private void hideLayer(Class layerClazz) { |
|
180 |
LayerList layers = getWwd().getModel().getLayers(); |
|
181 |
List<Layer> layersByClass = layers.getLayersByClass(layerClazz); |
|
182 |
layers.removeAll(layersByClass); |
|
183 |
} |
|
184 |
|
|
185 |
public void hideMiniMap() { |
|
186 |
hideLayer(WorldMapLayer.class); |
|
187 |
} |
|
188 |
|
|
189 |
public void hideNorthIndicator() { |
|
190 |
hideLayer(CompassLayer.class); |
|
191 |
} |
|
192 |
|
|
193 |
public void hideScale() { |
|
194 |
hideLayer(ScalebarLayer.class); |
|
195 |
} |
|
196 |
|
|
197 |
public void hideStarBackground() { |
|
198 |
hideLayer(StarsLayer.class); |
|
199 |
} |
|
200 |
|
|
201 |
private void intializeWWPanel() { |
|
202 |
wwd = new WorldWindowGLJPanel(); |
|
203 |
wwd.setPreferredSize(new Dimension(800, 600)); |
|
204 |
|
|
205 |
// Create the default model as described in the current worldwind |
|
206 |
// properties. |
|
207 |
Model m = |
|
208 |
(Model) WorldWind |
|
209 |
.createConfigurationComponent(AVKey.MODEL_CLASS_NAME); |
|
210 |
getWwd().setModel(m); |
|
211 |
|
|
212 |
// Add view control layer |
|
213 |
addNavigation(); |
|
214 |
} |
|
215 |
|
|
216 |
private boolean isAlreadyAdded(LayerList layerList, |
|
217 |
@SuppressWarnings("rawtypes") Class clazz) { |
|
218 |
|
|
219 |
List<Layer> layersByClass = layerList.getLayersByClass(clazz); |
|
220 |
|
|
221 |
return layersByClass.size() > 0; |
|
222 |
} |
|
223 |
|
|
224 |
public void reloadLayers() { |
|
225 |
// TODO |
|
226 |
throw new UnsupportedOperationException(); |
|
227 |
} |
|
228 |
|
|
229 |
private void removeAllLayers() { |
|
230 |
getWwd().getModel().getLayers().removeAll(); |
|
231 |
} |
|
232 |
|
|
233 |
private void setFlatPanelConfiguration() { |
|
234 |
Configuration.setValue(AVKey.GLOBE_CLASS_NAME, |
|
235 |
EarthFlat.class.getName()); |
|
236 |
Configuration.setValue(AVKey.VIEW_CLASS_NAME, |
|
237 |
FlatOrbitView.class.getName()); |
|
238 |
} |
|
239 |
|
|
240 |
public void setMapContext(MapContext theMapContext) { |
|
241 |
this.mapContext = theMapContext; |
|
242 |
} |
|
243 |
|
|
244 |
private void setSpherePanelConfiguration() { |
|
245 |
Configuration.setValue(AVKey.GLOBE_CLASS_NAME, Earth.class.getName()); |
|
246 |
Configuration.setValue(AVKey.VIEW_CLASS_NAME, |
|
247 |
BasicOrbitView.class.getName()); |
|
248 |
} |
|
249 |
|
|
250 |
public void setVerticalExaggeration(double verticalExaggeration) { |
|
251 |
getWwd().getSceneController().setVerticalExaggeration( |
|
252 |
verticalExaggeration); |
|
253 |
} |
|
254 |
|
|
255 |
public void showAtmosphere() { |
|
256 |
try { |
|
257 |
Globe globe = getWwd().getModel().getGlobe(); |
|
258 |
if (globe instanceof Earth) { |
|
259 |
getWwd().getModel().getLayers().add(new SkyGradientLayer()); |
|
260 |
addLayer(SkyGradientLayer.class); |
|
261 |
} else if (globe instanceof EarthFlat) { |
|
262 |
getWwd().getModel().getLayers().add(new SkyColorLayer()); |
|
263 |
addLayer(SkyColorLayer.class); |
|
264 |
} |
|
265 |
} catch (Exception e) { |
|
266 |
logger.warn( |
|
267 |
"Can't add " + SkyGradientLayer.class.getCanonicalName() |
|
268 |
+ " or " + SkyColorLayer.class.getCanonicalName() + " to " |
|
269 |
+ getWwd().getModel().toString(), e); |
|
270 |
} |
|
271 |
} |
|
272 |
|
|
273 |
public void showMiniMap() { |
|
274 |
try { |
|
275 |
addLayer(WorldMapLayer.class); |
|
276 |
} catch (Exception e) { |
|
277 |
logger.warn("Can't add " + WorldMapLayer.class.getCanonicalName() |
|
278 |
+ "to " + getWwd().getModel().toString(), e); |
|
279 |
} |
|
280 |
} |
|
281 |
|
|
282 |
public void showNortIndicator() { |
|
283 |
try { |
|
284 |
addLayer(CompassLayer.class); |
|
285 |
} catch (Exception e) { |
|
286 |
logger.warn("Can't add " + CompassLayer.class.getCanonicalName() |
|
287 |
+ " to " + getWwd().getModel().toString(), e); |
|
288 |
} |
|
289 |
} |
|
290 |
|
|
291 |
public void showScale() { |
|
292 |
try { |
|
293 |
addLayer(ScalebarLayer.class); |
|
294 |
} catch (Exception e) { |
|
295 |
logger.warn("Can't add " + ScalebarLayer.class.getCanonicalName() |
|
296 |
+ " to " + getWwd().getModel().toString(), e); |
|
297 |
} |
|
298 |
} |
|
299 |
|
|
300 |
public void showStarBackgroundLayer() { |
|
301 |
try { |
|
302 |
addLayer(StarsLayer.class); |
|
303 |
} catch (Exception e) { |
|
304 |
logger.warn("Can't add " + StarsLayer.class.getCanonicalName() |
|
305 |
+ " to " + getWwd().getModel().toString(), e); |
|
306 |
} |
|
307 |
} |
|
308 |
|
|
309 |
public void synchronizeLayers() { |
|
310 |
// TODO |
|
311 |
throw new UnsupportedOperationException(); |
|
312 |
} |
|
313 |
|
|
314 |
public void synchronizeViewPorts() { |
|
315 |
// TODO |
|
316 |
throw new UnsupportedOperationException(); |
|
317 |
} |
|
318 |
|
|
319 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/impl/DefaultView3DSwingLibrary.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.swing.impl; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.DALLibrary; |
|
28 |
import org.gvsig.tools.library.AbstractLibrary; |
|
29 |
import org.gvsig.tools.library.LibraryException; |
|
30 |
import org.gvsig.view3d.swing.api.View3DSwingLibrary; |
|
31 |
import org.gvsig.view3d.swing.api.View3DSwingLocator; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author llmarques |
|
35 |
* |
|
36 |
*/ |
|
37 |
public class DefaultView3DSwingLibrary extends AbstractLibrary { |
|
38 |
|
|
39 |
@Override |
|
40 |
public void doRegistration() { |
|
41 |
registerAsImplementationOf(View3DSwingLibrary.class); |
|
42 |
require(DALLibrary.class); |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
protected void doInitialize() throws LibraryException { |
|
47 |
View3DSwingLocator.registerManager(DefaultView3DSwingManager.class); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
protected void doPostInitialize() throws LibraryException { |
|
52 |
} |
|
53 |
|
|
54 |
} |
2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/impl/DefaultView3DPanel.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
package org.gvsig.view3d.swing.impl; |
26 | 26 |
|
27 |
import gov.nasa.worldwind.globes.Earth; |
|
28 |
import gov.nasa.worldwind.globes.EarthFlat; |
|
29 |
import gov.nasa.worldwind.globes.Globe; |
|
30 |
import gov.nasa.worldwind.layers.CompassLayer; |
|
31 |
import gov.nasa.worldwind.layers.Layer; |
|
32 |
import gov.nasa.worldwind.layers.LayerList; |
|
33 |
import gov.nasa.worldwind.layers.ScalebarLayer; |
|
34 |
import gov.nasa.worldwind.layers.SkyColorLayer; |
|
35 |
import gov.nasa.worldwind.layers.SkyGradientLayer; |
|
36 |
import gov.nasa.worldwind.layers.StarsLayer; |
|
37 |
import gov.nasa.worldwind.layers.WorldMapLayer; |
|
38 |
|
|
39 | 27 |
import java.awt.BorderLayout; |
40 |
import java.lang.reflect.Constructor; |
|
41 |
import java.lang.reflect.InvocationTargetException; |
|
42 |
import java.util.List; |
Also available in: Unified diff