AE92 SDK for Java 窗体简例

ArcEngine开发文档中提供了另外一个开发简例HelloGlobe,它是基于JFrame窗体的一个简单应用,从窗体设计代码中我们可以看到,ArcEngine已经以JavaBean的形式封装了一些常用的窗体控件,可以直接的应用到窗体设计的开发中,并且支持跨平台,给开发者提供了另一种选择。

    引用的包:

import  java.awt.BorderLayout;
import  java.awt.event.WindowAdapter;
import  java.awt.event.WindowEvent;
import  java.io.IOException;
import  javax.swing.JFrame;

import  com.esri.arcgis.beans.TOC.TOCBean;
import  com.esri.arcgis.beans.globe.GlobeBean;
import  com.esri.arcgis.beans.toolbar.ToolbarBean;
import  com.esri.arcgis.controls.ControlsGlobeFullExtentCommand;
import  com.esri.arcgis.controls.ControlsGlobeNavigateTool;
import  com.esri.arcgis.controls.ControlsGlobeOpenDocCommand;
import  com.esri.arcgis.system.AoInitialize;
import  com.esri.arcgis.system.EngineInitializer;
import  com.esri.arcgis.system.esriLicenseExtensionCode;
import  com.esri.arcgis.system.esriLicenseProductCode;

    关于AWT和Swing的使用可以参考相关的书籍,从引用的包中,可以看到TOC、toolbar、globe显示窗都已经封装到JavaBean中,可以直接调用,为开发者省了不少事,也帮助开发人员可以像在Visual Studio下设计UI一样来设计Java的窗体。

    看看它的窗体设计代码:

//
//  Create and display the frame
//
private   void  display()  throws  IOException  {
  setSize(
500400);
  
//
  
// Create the globe, toolbar, and table of contents beans.
  
//
  GlobeBean globeBean = new GlobeBean();
  ToolbarBean toolbarBean 
= new ToolbarBean();
  TOCBean tocBean 
= new TOCBean();
  
//
  
// Add beans to the content pane.
  
//
  getContentPane().add(toolbarBean, BorderLayout.NORTH);
  getContentPane().add(globeBean, BorderLayout.CENTER);
  getContentPane().add(tocBean, BorderLayout.WEST);
  
//
  
// Add commands and tool to the toolbar.
  
//
  toolbarBean.addItem(new ControlsGlobeOpenDocCommand(), 0-1false01);
  toolbarBean.addItem(
new ControlsGlobeNavigateTool(), 0-1false01);
  toolbarBean.addItem(
new ControlsGlobeFullExtentCommand(), 0-1false01);
  
//
  
// Buddy up the globe with the toolbar and table of contents.
  
//
  toolbarBean.setBuddyControl(globeBean);
  tocBean.setBuddyControl(globeBean);
  
//
  
// Shutdown ArcObjects when the window closes.
  
//
  addWindowListener(new WindowAdapter() {
    
public void windowClosing(WindowEvent e) {
      
try {
        
new AoInitialize().shutdown();
        System.exit(
0);
      }

      
catch (IOException ex) {
        System.out.println(ex.getMessage());
        System.exit(
1);
      }

    }

  }
);
  setVisible(
true);
}

    纯粹的Java窗体设计风格,简单易用。再看看main方法中的内容,和前面一篇《 AE92 SDK for Java 最小示例学习》稍有区别。

    main方法:

public   static   void  main(String args[])  {
  
try {
    EngineInitializer.initializeVisualBeans();            
    AoInitialize aoInitializer 
= new AoInitialize();
    aoInitializer.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
    aoInitializer.checkOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst);
    HelloGlobe thisApp 
= new HelloGlobe();
    thisApp.setTitle(
"Hello, Globe!");
    thisApp.display();
  }

  
catch (IOException ex) {
    System.out.println(ex.getMessage());
  }

}

    由于应用程序使用了窗体,因此在原始AO组建和Java Class建立关联时,需要initializeVisualBeans方法来初始化,initializeVisualBeans和initializeEngine两者选其一,使用可视化Beans选择前者,否则选择后者。这里aoInitializer对象除了指定相应的license授权,还检查相应的应用扩展。

    AE92 SDK for Java 已经集成到Eclipse3.2中,通过ArcEngine模板建立一个HelloGlobe工程,看看运行显示的结果:

HelloGlobe.gif

    基于这个模板框架,可以方便我们深入扩展Globe二次开发的功能。

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值