WordWind(Java版)開發環境搭建

來源:互聯網
上載者:User

我的操作平台Windows 7 64位作業系統,如果是32位的則在拷貝有些Jar包的時候注意對應32位的。

首先在官網下載最新的WordWind源碼檔案(我下載的是2.0版本的),解壓縮,然後在Eclipse中建立Java Project。

如果想對WorldWind源碼進行研究,開發環境搭建如下:

1.將下載的檔案中的src檔案夾下的所有目錄檔案拷貝到工程中的src目錄下。

2.在Java工程中建立lib檔案夾,把gadl.jar、gluegen-rt.jar、gluegen-rt-natives-windows-amd64.jar、jogl-all.jar、jogl-all-natives-windows-amd64.jar、plugin.jar拷貝到禮拜目錄下。

3.在工程中JRE System Library上右鍵Build Path→Configure Build Path,在Libraries選項卡下點擊Add JARs,然後把lib檔案夾下的所有Jar包添加進去,如下圖。


大功告成,運行gov.nasa.worldwindx.examples包下的任意Java檔案,結果如下:


如果只想利用WorldWind進行二次開發,則開發環境只需要這樣配置:

1.在Java工程中建立lib檔案夾,把worldwin.jar、worldwindx.jar、gluegen-rt.jar、gluegen-rt-natives-windows-amd64.jar、jogl-all.jar、jogl-all-natives-windows-amd64.jar拷貝到lib目錄下。

2.在工程中JRE System Library上右鍵Build Path→Configure Build Path,在Libraries選項卡下點擊Add JARs,然後把lib檔案夾下worldwin.jar、worldwindx.jar、gluegen-rt.jar、jogl-all.jar添加進去,如下圖.


3.在src源檔案目錄中添加自己的代碼,調用WorldWind提供的API。

下面給出一個執行個體:

import java.awt.BorderLayout;import java.awt.Dimension;import java.awt.EventQueue;import java.awt.Toolkit;import javax.swing.JFrame;import gov.nasa.worldwind.BasicModel;import gov.nasa.worldwind.awt.WorldWindowGLCanvas;public class HelloWorldWind {public static class WorldWindFrame extends JFrame {private static final long serialVersionUID = -130932605398355602L;private WorldWindowGLCanvas windowCanvas;public WorldWindFrame() {windowCanvas = new WorldWindowGLCanvas();Dimension frameSize = new Dimension(600,600);windowCanvas.setPreferredSize(frameSize);this.setTitle("WorldWindDemo");this.getContentPane().add(windowCanvas,BorderLayout.CENTER);Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();this.setLocation((screenSize.width - frameSize.width ) / 2, (screenSize.height - frameSize.height) / 2);this.pack();windowCanvas.setModel(new BasicModel());}}public static void main(String[] args) {EventQueue.invokeLater(new Runnable() {@Overridepublic void run() {new WorldWindFrame().setVisible(true);}});}}

運行結果如下:




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.