AE92 SDK for Java 窗体简例
发布日期:2021-10-01 08:45:03 浏览次数:3 分类:技术文章

本文共 2994 字,大约阅读时间需要 9 分钟。

    作者:
    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方法中的内容,和前面一篇《》稍有区别。
    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二次开发的功能。

转载地址:https://blog.csdn.net/iteye_263/article/details/81427083 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:菜鸟硕枫设计模式系列之1 单例模式
下一篇:AE92 SDK for Java 最小示例学习

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年03月25日 07时17分20秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

java中类加载根路径_java中获取类加载路径和项目根路径的5种方法 2019-04-21
Java套接字传文件_Java通过套接字传输多个文件 2019-04-21
递归字符串逆序 java_在Java中使用递归反转字符串 2019-04-21
java推送功能实现原理图_IOS 基于APNS消息推送原理与实现(JAVA后台) - 图文 2019-04-21
java streamencoder_[求助]关于apcche与tomcat 2019-04-21
golang mongodb mysql_分享一个golang+mongodb+vuejs开发的博客程序 gocms 2019-04-21
hive java insert_hive表insert报错 2019-04-21
java 调试dll jna_Java调用dll的实现,JNA框架 | 学步园 2019-04-21
ios php上传视频文件_IOS上传图片 PHP服务器接收并上传 2019-04-21
php redis zrevrange,Redis Zrevrange 命令 2019-04-21
php利用word模板导出excel文件,php生成导出word doc和excel文件实例 2019-04-21
java 边缓存边播放,java动态缓存技术:WEB缓存应用 2019-04-21
php云盘匿名,PHP7之匿名类 2019-04-21
matlab数据大小不兼容,MATLAB无法执行赋值,因为左侧的索引与右侧的大小不兼容。 求解... 2019-04-21
editor.md使用php,editor.md 配置参数和使用方法 2019-04-21
python mod,mod_python的安装 2019-04-21
python分析彩票数据,这波太炸了!Python脚本可视化居然可以这么玩 2019-04-21
简单的mysql重置root密码,重置mysql的root密码最简单的方法 2019-04-21
用matlab仿真mmc环流抑制器,一种基于准PR控制原理的MMC阀组环流抑制方法 2019-04-21
oracle 排序的分析函数,Oracle SQL:使用分析排序函数 2019-04-21