package view;
import com.esri.arcgis.beans.TOC.TOCBean;
import com.esri.arcgis.beans.map.MapBean;
import com.esri.arcgis.beans.toolbar.ToolbarBean;
import com.esri.arcgis.controls.*;
import com.esri.arcgis.system.AoInitialize;
import com.esri.arcgis.system.EngineInitializer;
import com.esri.arcgis.system.esriLicenseProductCode;
import com.esri.arcgis.system.esriLicenseStatus;
import com.esri.arcgis.systemUI.esriCommandStyles;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
/**
* @author czh
* @create 2022-03-09 18:52
*/
public class AppView extends JFrame {
JPanel mainPanel = null;// 主面板
JPanel rightPanel = null;// 右侧面板
MapBean mapBean = null;// 地图组件
ToolbarBean toolbarBean = null;// 工具栏
IToolbarPalette toolbarPalette = null;// 右键工具菜单
TOCBean tocBean = null;// 图层
public AppView() throws Exception {
// 界面名字
setTitle("arcObjects二次开发");
// 创建界面
buildFrame();
// 设置大小
setSize(900,600);
// 初始化toolbar
initToolBar();
// 设置关闭界面即停止程序
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// 设置界面可被看见
setVisible(true);
}
private void initToolBar() {
try {
tocBean.setBuddyControl(mapBean);
toolbarBean.setBuddyControl(mapBean);
// 设置图层可以移动
tocBean.setEnableLayerDragDrop(true);
// 对toolbarPalette菜单添加按钮
toolbarPalette = new ToolbarPalette();
toolbarPalette.addItem(new ControlsSelectTool(), 0, -1);// 选择
toolbarPalette.addItem(new ControlsNewCircleTool(), 0, -1);// 画⚪
toolbarPalette.addItem(new ControlsNewCurveTool(), 0, -1);// 曲线
toolbarPalette.addItem(new ControlsNewEllipseTool(), 0, -1);// 椭圆
toolbarPalette.addItem(new ControlsNewLineTool(), 0, -1);// 线
toolbarPalette.addItem(new ControlsNewPolygonTool(), 0, -1);// 多边形
toolbarPalette.addItem(new ControlsNewRectangleTool(), 0, -1);// 矩形
toolbarPalette.addItem(new ControlsNewFreeHandTool(), 0, -1);// 任意线
toolbarPalette.addItem(new ControlsEditingEditTool(), 0, -1);// 编辑
// 按钮,0,-1,是否开始分组,组间间隔,是否在按钮旁边显示文字
toolbarBean.addItem(new ControlsOpenDocCommand(),0,-1,true,0,esriCommandStyles.esriCommandStyleIconOnly);// 添加打开文件按钮
toolbarBean.addItem(new ControlsMapZoomInTool(),0,-1,true,0,esriCommandStyles.esriCommandStyleIconOnly);// 放大
toolbarBean.addItem(new ControlsMapZoomOutTool(),0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly);// 缩小
toolbarBean.addItem(new ControlsMapFullExtentCommand(),0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly);// 全图
toolbarBean.addItem(new ControlsMapPanTool(),0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly);// 拖拽
toolbarBean.addItem(new ControlsSelectFeaturesTool(), 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);// 选择
toolbarBean.addItem(new ControlsClearSelectionCommand(), 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);// 清除选择
toolbarBean.addItem(toolbarPalette,0,-1,true,0,1);
// 设置toolbar的按钮可移动
// toolbarBean.setCustomize(true);
} catch (IOException e) {
e.printStackTrace();
}
}
// 创建界面
public void buildFrame() throws Exception {
// 初始化操作
EngineInitializer.initializeVisualBeans();
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
initializeArcGISLicenses();
tocBean = new TOCBean();
// 对右侧面板添加元素
rightPanel = new JPanel();
mapBean = new MapBean();
rightPanel.setLayout(new BorderLayout());
rightPanel.add(mapBean, BorderLayout.CENTER);
// 对主面板添加元素
mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(tocBean, BorderLayout.WEST);
mainPanel.add(rightPanel,BorderLayout.CENTER);
toolbarBean = new ToolbarBean();
toolbarBean.setSize(650,50);
mainPanel.add(toolbarBean,BorderLayout.NORTH);
mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
getContentPane().add(mainPanel, BorderLayout.CENTER);
}
// 初始化license
public static void initializeArcGISLicenses() {
try {
AoInitialize ao = new AoInitialize();
if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine)
== esriLicenseStatus.esriLicenseAvailable)
ao.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
else if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeBasic)
== esriLicenseStatus.esriLicenseAvailable)
ao.initialize(esriLicenseProductCode.esriLicenseProductCodeBasic);
else if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeStandard)
== esriLicenseStatus.esriLicenseAvailable)
ao.initialize(esriLicenseProductCode.esriLicenseProductCodeStandard);
else if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeAdvanced)
== esriLicenseStatus.esriLicenseAvailable)
ao.initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
} catch (Exception e) {e.printStackTrace();}
}
public static void main(String[] args) throws Exception {
AppView view = new AppView();
// 关闭界面停止运行
System.out.println("运行");
}
}
arcobjects sdk for java,一个简单的GIS应用
需积分: 1 111 浏览量
2022-03-18
16:20:24
上传
评论
收藏 38.35MB ZIP 举报
哈哈哈哈瀚
- 粉丝: 8
- 资源: 4
最新资源
- 农村信用社联合社计算机信息系统投产与变更管理办.docx
- 农村信用社联合社计算机信息系统数据管理办法.docx
- 利用SPSS作临床效度分析线上计算网站介绍-医学研究部统计谘.(医学PPT课件).ppt
- 利用Zabbix监控mysqldump定时备份数据库状态.docx
- 利用计算机解决问题的基本过程.doc
- 化工铁路通信工程总结.doc
- 北京大学网络教育软件工程作业.docx
- 医药公司(连锁店)计算机操作规程未新系统的自行按照旧制修改-新系统过制的编号加修模版.doc
- 医药公司(连锁店)计算机系统操作规程模版.doc
- 医药连锁门店计算机系统的操作和管理程序未新系统的自行按照旧制修改-新系统过制的编号加修模版.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0