AE92 SDK for Java 窗体简例
2007-05-19 14:51
225 查看
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(500, 400);
//
// 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, -1, false, 0, 1);
toolbarBean.addItem(new ControlsGlobeNavigateTool(), 0, -1, false, 0, 1);
toolbarBean.addItem(new ControlsGlobeFullExtentCommand(), 0, -1, false, 0, 1);
//
// 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工程,看看运行显示的结果:
基于这个模板框架,可以方便我们深入扩展Globe二次开发的功能。
引用的包:
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(500, 400);
//
// 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, -1, false, 0, 1);
toolbarBean.addItem(new ControlsGlobeNavigateTool(), 0, -1, false, 0, 1);
toolbarBean.addItem(new ControlsGlobeFullExtentCommand(), 0, -1, false, 0, 1);
//
// 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工程,看看运行显示的结果:
基于这个模板框架,可以方便我们深入扩展Globe二次开发的功能。
相关文章推荐
- AE92 SDK for Java 最小示例学习
- AE92 SDK for Java 最小示例学习
- AE92 SDK for Java 窗体简例
- eclipse for javaEE 不显示AVD及SDK Manager的菜单
- 安装 Nokia SDK for java 1.0
- HPSocket for Java SDK 提供以下通信组件
- ArcGIS Runtime SDK for Java 运行时找不到相关类解决办法
- 在Eclipse for JavaEE中配置SDK
- android开发 android studio配置opencv for android sdk,使用opencv的java函数
- live domains sdk version 2.0 for java 更新
- Teamprise Readies Java SDK for TFS
- IBM SDK for Java 6 beta 版本发布
- 使用版本 1.0.0 的 Azure ARM SDK for Java 创建虚拟机时报错
- Teamprise Readies Java SDK for TFS
- Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > compileSdkVersion 'android-24' r
- 使用AWS SDK for Java创建并启动EC2实例
- ArcSDE SDK For Java二次开发介绍、演示样例
- AmazonS3 使用 AWS SDK for Java
- 【Java-Android开发系列】Android SDK for Windows全部文件打包下载【115已死,文件无法下载】
- Teamprise Readies Java SDK for TFS