zoukankan      html  css  js  c++  java
  • World Wind Java开发之三 显示状态栏信息(转)

    http://blog.csdn.net/giser_whu/article/details/40920315

    先来看下本篇博客索要达到的效果:

    找到源码下的gov.nasa.worldwind.util下的StatusBar.java文件,可以看到状态栏显示的信息主要包括视点高度以及对应空间点三维坐标以及是否使用网络等信息。在后续的开发中采用离线模式,因此不需要联网,也不显示网络状态信息。代码依次如下面几幅图所示:

    修改完源代码后,将源代码文件导出为jar包,在我们的工程下引用即可。后面如果需要修改源代码,都按这种方式操作;具体操作步骤如下:

    需要说明的是导出的时候可以只勾选src文件夹也可以默认。导出后将worldWind2.0.jar文件拷贝到我们的工程目录下,添加应用即可。下面是所有源码:

    [java] view plain copy
     
     print?在CODE上查看代码片派生到我的代码片
    1. package cn.whu.vge;  
    2.   
    3. import gov.nasa.worldwind.Model;  
    4. import gov.nasa.worldwind.WorldWind;  
    5. import gov.nasa.worldwind.WorldWindow;  
    6. import gov.nasa.worldwind.avlist.AVKey;  
    7. import gov.nasa.worldwind.awt.WorldWindowGLCanvas;  
    8. import gov.nasa.worldwind.util.StatusBar;  
    9.   
    10. import java.awt.Dimension;  
    11. import java.awt.EventQueue;  
    12. import java.awt.Toolkit;  
    13.   
    14. import javax.swing.ImageIcon;  
    15. import javax.swing.JButton;  
    16. import javax.swing.JFrame;  
    17. import javax.swing.JMenu;  
    18. import javax.swing.JMenuBar;  
    19. import javax.swing.JPanel;  
    20. import javax.swing.JToolBar;  
    21.   
    22. /** 
    23.  * @author Administrator 
    24.  * 
    25.  */  
    26.   
    27. public class GFScope  
    28. {  
    29.   
    30.     private JFrame GFScopeMainFrame; // 主窗体  
    31.     private WorldWindowGLCanvas worldWindowGLCanvas; // 声明WWJ画布  
    32.     private JPanel WorldWindPanel;  //三维视图面板  
    33.     private JPanel Layerpanel;      //图层管理面板  
    34.     private JPanel StatusBarpanel;  //状态栏面板  
    35.   
    36.     private StatusBar statusBar;    //状态栏  
    37. //  private WorldWindow wwd;  
    38.       
    39.     /** 
    40.      * Launch the application. 
    41.      */  
    42.     public static void main(String[] args)  
    43.     {  
    44.         EventQueue.invokeLater(new Runnable()  
    45.         {  
    46.             public void run()  
    47.             {  
    48.                 try  
    49.                 {  
    50.                     GFScope window = new GFScope();  
    51.                     window.GFScopeMainFrame.setVisible(true);  
    52.                     window.GFScopeMainFrame.setTitle("XXXXX子系统");  
    53.                     WorldWind.setOfflineMode(true); // 设置离线运行模式  
    54.                   
    55.                 }  
    56.                 catch (Exception e)  
    57.                 {  
    58.                     e.printStackTrace();  
    59.                 }  
    60.             }  
    61.         });  
    62.     }  
    63.   
    64.     /** 
    65.      * Create the application. 
    66.      */  
    67.     public GFScope()  
    68.     {  
    69.         initialize();  
    70.           
    71.         InitializeEarth(WorldWindPanel,StatusBarpanel);  
    72.     }  
    73.   
    74.     /** 
    75.      * Initialize the contents of the frame. 
    76.      */  
    77.     /** 
    78.      *  
    79.      */  
    80.     private void initialize()  
    81.     {  
    82.         // 主窗体  
    83.         GFScopeMainFrame = new JFrame();  
    84.         GFScopeMainFrame.setIconImage(Toolkit.getDefaultToolkit().getImage(  
    85.                 GFScope.class.getResource("/images/32x32-icon-earth.png")));  
    86.         GFScopeMainFrame.setBounds(100, 100, 1000, 800);  
    87.         GFScopeMainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
    88.         GFScopeMainFrame.getContentPane().setLayout(null);  
    89.   
    90.           
    91.         /** 
    92.          * 菜单项 
    93.          */  
    94.         JMenuBar menuBar = new JMenuBar();  
    95.         menuBar.setBounds(0, 0, 984, 30);  
    96.         GFScopeMainFrame.getContentPane().add(menuBar);  
    97.   
    98.         JMenu mnf = new JMenu("u6587u4EF6(F)");  
    99.         menuBar.add(mnf);  
    100.   
    101.         JMenu mnv = new JMenu("u89C6u56FE(V)");  
    102.         menuBar.add(mnv);  
    103.   
    104.         JMenu mnNewMenu = new JMenu("u5DE5u5177(T)");  
    105.         menuBar.add(mnNewMenu);  
    106.   
    107.         JMenu mnNewMenu_1 = new JMenu("u5206u6790(A)");  
    108.         menuBar.add(mnNewMenu_1);  
    109.   
    110.         JMenu mnh = new JMenu("u5E2Eu52A9(H)");  
    111.         menuBar.add(mnh);  
    112.   
    113.         /** 
    114.          * 工具条 
    115.          */  
    116.   
    117.         JToolBar toolBar = new JToolBar();  
    118.         toolBar.setBounds(0, 28, 984, 30);  
    119.         GFScopeMainFrame.getContentPane().add(toolBar);  
    120.   
    121.         JButton btnNewButton = new JButton("");  
    122.         btnNewButton.setIcon(new ImageIcon(GFScope.class  
    123.                 .getResource("/newt/data/cross-grey-alpha-16x16.png")));  
    124.         toolBar.add(btnNewButton);  
    125.   
    126.         /** 
    127.          * 面板(图层面板、三维视图面板) 
    128.          *  
    129.          * @author 
    130.          */  
    131.         Layerpanel = new JPanel();  
    132.         Layerpanel.setBounds(0, 60, 194, 702);  
    133.         GFScopeMainFrame.getContentPane().add(Layerpanel);  
    134.   
    135.         WorldWindPanel = new JPanel();  
    136.         WorldWindPanel.setBounds(194, 60, 790, 673);  
    137.         GFScopeMainFrame.getContentPane().add(WorldWindPanel);  
    138.           
    139.         StatusBarpanel = new JPanel();  
    140.         StatusBarpanel.setBounds(194, 732, 790, 30);  
    141.         GFScopeMainFrame.getContentPane().add(StatusBarpanel);  
    142.   
    143.           
    144.     }  
    145.   
    146.       
    147.     private void InitializeEarth(JPanel panel1,JPanel panel2)  
    148.     {  
    149.         // 按指定尺寸创建画布  
    150.         Dimension canvasSize = new Dimension(790, 688);  
    151.         this.worldWindowGLCanvas = new WorldWindowGLCanvas();  
    152.         this.worldWindowGLCanvas.setPreferredSize(canvasSize);  
    153.   
    154.         // 创建Earth模型,并与画布绑定  
    155.         Model model = (Model) WorldWind  
    156.                 .createConfigurationComponent(AVKey.MODEL_CLASS_NAME);  
    157.         this.worldWindowGLCanvas.setModel(model);  
    158.         panel1.add(worldWindowGLCanvas);  
    159.           
    160.         /** 
    161.          *初始化状态栏信息 
    162.          * */  
    163.         this.statusBar=new StatusBar();  
    164.         this.statusBar.setEventSource(worldWindowGLCanvas);  
    165.         panel2.add(statusBar);  
    166.   
    167.     }  
    168. }  


    欢迎大家留言交流!

  • 相关阅读:
    css
    css笔记
    css笔记
    echarts
    css笔记
    跨域
    JS案例
    html2canvas
    echarts
    echarts
  • 原文地址:https://www.cnblogs.com/telwanggs/p/6769732.html
Copyright © 2011-2022 走看看