arcgissamples\globebean\UseGlobeBean.java
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. * * You may freely redistribute and use this sample code, with or * without modification, provided you include the original copyright * notice and use restrictions. * * See the use restrictions. * */ package arcgissamples.globebean; import java.awt.BorderLayout; import java.awt.Dimension; 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.ControlsGlobeFixedZoomInCommand; import com.esri.arcgis.controls.ControlsGlobeFixedZoomOutCommand; import com.esri.arcgis.controls.ControlsGlobeFlyTool; import com.esri.arcgis.controls.ControlsGlobeFullExtentCommand; import com.esri.arcgis.controls.ControlsGlobeGlobeToolbar; import com.esri.arcgis.controls.ControlsGlobeNavigateTool; import com.esri.arcgis.controls.ControlsGlobeNavigationModeCommand; import com.esri.arcgis.controls.ControlsGlobeOpenDocCommand; import com.esri.arcgis.controls.ControlsGlobeZoomInOutTool; import com.esri.arcgis.system.AoInitialize; import com.esri.arcgis.system.EngineInitializer; import com.esri.arcgis.system.esriLicenseExtensionCode; import com.esri.arcgis.system.esriLicenseProductCode; import com.esri.arcgis.system.esriLicenseStatus; /** * Sample showing GlobeBean, ToolbarBean and TOCBean */ public class UseGlobeBean { static javax.swing.JFrame frame = null; static GlobeBean globeBean = null; static ToolbarBean toolbarBean = null; static TOCBean tocBean = null; public UseGlobeBean() { initializeArcGISLicenses(); frame = new JFrame("GlobeBean Java Sample: GlobeBean, Toolbar and Toc"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); globeBean = new GlobeBean(); toolbarBean = new ToolbarBean(); tocBean = new TOCBean(); } public static void main(String[] args) { try { EngineInitializer.initializeVisualBeans(); UseGlobeBean globe = new UseGlobeBean(); globe.display(); } catch (IOException ex) { // ignore } } void initializeArcGISLicenses() { try { AoInitialize ao = new AoInitialize(); if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine) == esriLicenseStatus.esriLicenseAvailable) ao.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine); else if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcView) == esriLicenseStatus.esriLicenseAvailable) ao.initialize(esriLicenseProductCode.esriLicenseProductCodeArcView); else if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcEditor) == esriLicenseStatus.esriLicenseAvailable) ao.initialize(esriLicenseProductCode.esriLicenseProductCodeArcEditor); else if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcInfo) == esriLicenseStatus.esriLicenseAvailable) ao.initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo); ao.checkOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst); } catch (Exception e) { e.printStackTrace(); System.out.println(" Program Exit: Unable to check out proper licenses"); System.exit(0); } } public void display() throws java.io.IOException { globeBean.setSize(600, 600); toolbarBean.setSize(800, 25); tocBean.setSize(200, 600); frame.getContentPane().add(toolbarBean, BorderLayout.NORTH); frame.getContentPane().add(globeBean, BorderLayout.CENTER); frame.getContentPane().add(tocBean, BorderLayout.WEST); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); tocBean.setBuddyControl(globeBean); toolbarBean.setBuddyControl(globeBean); // Load the pre-built tools toolbarBean.addItem(new ControlsGlobeOpenDocCommand(), 0, -1, false, 0, 1); // Open toolbarBean.addItem(new ControlsGlobeNavigateTool(), 0, -1, false, 0, 1); // Navigate toolbarBean.addItem(new ControlsGlobeZoomInOutTool(), 0, -1, false, 0, 1); // ZoomInOut toolbarBean.addItem(new ControlsGlobeFlyTool(), 0, -1, false, 0, 1); // Fly toolbarBean.addItem(new ControlsGlobeFixedZoomInCommand(), 0, -1, false, 0, 1); // FixedZoomIn toolbarBean.addItem(new ControlsGlobeFixedZoomOutCommand(), 0, -1, false, 0, 1); // FixedZoomOut toolbarBean.addItem(new ControlsGlobeFullExtentCommand(), 0, -1, false, 0, 1); // FullExtent toolbarBean.addItem(new ControlsGlobeGlobeToolbar(), 0, -1, false, 0, 1); // ToolbarGlobe toolbarBean.addItem(new ControlsGlobeNavigationModeCommand(), 0, -1, false, 0, 1); // NavigationMode } }