先来看下本篇博客索要达到的效果:
找到源代码下的gov.nasa.worldwind.util下的StatusBar.java文件,能够看到状态栏显示的信息主要包含视点高度以及相应空间点三维坐标以及是否使用网络等信息。在兴许的开发中採用离线模式,因此不须要联网,也不显示网络状态信息。代码依次如以下几幅图所看到的:
改动完源码后,将源码文件导出为jar包,在我们的project下引用就可以。后面假设须要改动源码,都按这样的方式操作。详细操作过程例如以下:
须要说明的是导出的时候能够仅仅勾选src文件夹也能够默认。导出后将worldWind2.0.jar文件复制到我们的project文件夹下。加入应用就可以。以下是全部源代码:
package cn.whu.vge; import gov.nasa.worldwind.Model; import gov.nasa.worldwind.WorldWind; import gov.nasa.worldwind.WorldWindow; import gov.nasa.worldwind.avlist.AVKey; import gov.nasa.worldwind.awt.WorldWindowGLCanvas; import gov.nasa.worldwind.util.StatusBar; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Toolkit; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JPanel; import javax.swing.JToolBar; /** * @author Administrator * */ public class GFScope { private JFrame GFScopeMainFrame; // 主窗口 private WorldWindowGLCanvas worldWindowGLCanvas; // 声明WWJ画布 private JPanel WorldWindPanel; //三维视图面板 private JPanel Layerpanel; //图层管理面板 private JPanel StatusBarpanel; //状态栏面板 private StatusBar statusBar; //状态栏 // private WorldWindow wwd; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { GFScope window = new GFScope(); window.GFScopeMainFrame.setVisible(true); window.GFScopeMainFrame.setTitle("XXXXX子系统"); WorldWind.setOfflineMode(true); // 设置离线执行模式 } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public GFScope() { initialize(); InitializeEarth(WorldWindPanel,StatusBarpanel); } /** * Initialize the contents of the frame. */ /** * */ private void initialize() { // 主窗口 GFScopeMainFrame = new JFrame(); GFScopeMainFrame.setIconImage(Toolkit.getDefaultToolkit().getImage( GFScope.class.getResource("/images/32x32-icon-earth.png"))); GFScopeMainFrame.setBounds(100, 100, 1000, 800); GFScopeMainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GFScopeMainFrame.getContentPane().setLayout(null); /** * 菜单项 */ JMenuBar menuBar = new JMenuBar(); menuBar.setBounds(0, 0, 984, 30); GFScopeMainFrame.getContentPane().add(menuBar); JMenu mnf = new JMenu("u6587u4EF6(F)"); menuBar.add(mnf); JMenu mnv = new JMenu("u89C6u56FE(V)"); menuBar.add(mnv); JMenu mnNewMenu = new JMenu("u5DE5u5177(T)"); menuBar.add(mnNewMenu); JMenu mnNewMenu_1 = new JMenu("u5206u6790(A)"); menuBar.add(mnNewMenu_1); JMenu mnh = new JMenu("u5E2Eu52A9(H)"); menuBar.add(mnh); /** * 工具条 */ JToolBar toolBar = new JToolBar(); toolBar.setBounds(0, 28, 984, 30); GFScopeMainFrame.getContentPane().add(toolBar); JButton btnNewButton = new JButton(""); btnNewButton.setIcon(new ImageIcon(GFScope.class .getResource("/newt/data/cross-grey-alpha-16x16.png"))); toolBar.add(btnNewButton); /** * 面板(图层面板、三维视图面板) * * @author */ Layerpanel = new JPanel(); Layerpanel.setBounds(0, 60, 194, 702); GFScopeMainFrame.getContentPane().add(Layerpanel); WorldWindPanel = new JPanel(); WorldWindPanel.setBounds(194, 60, 790, 673); GFScopeMainFrame.getContentPane().add(WorldWindPanel); StatusBarpanel = new JPanel(); StatusBarpanel.setBounds(194, 732, 790, 30); GFScopeMainFrame.getContentPane().add(StatusBarpanel); } private void InitializeEarth(JPanel panel1,JPanel panel2) { // 按指定尺寸创建画布 Dimension canvasSize = new Dimension(790, 688); this.worldWindowGLCanvas = new WorldWindowGLCanvas(); this.worldWindowGLCanvas.setPreferredSize(canvasSize); // 创建Earth模型,并与画布绑定 Model model = (Model) WorldWind .createConfigurationComponent(AVKey.MODEL_CLASS_NAME); this.worldWindowGLCanvas.setModel(model); panel1.add(worldWindowGLCanvas); /** *初始化状态栏信息 * */ this.statusBar=new StatusBar(); this.statusBar.setEventSource(worldWindowGLCanvas); panel2.add(statusBar); } }
欢迎大家留言交流!