arcgissamples\globe\DigitizeGlobeApplication.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.globe; import java.awt.BorderLayout; import java.awt.Rectangle; import java.io.File; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import com.esri.arcgis.beans.globe.GlobeBean; import com.esri.arcgis.beans.toolbar.ToolbarBean; import com.esri.arcgis.controls.ControlsGlobeNavigateTool; import com.esri.arcgis.controls.ControlsGlobeNavigationModeCommand; import com.esri.arcgis.controls.ControlsGlobeRotateToolbar; 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; import com.esri.arcgis.systemUI.esriCommandStyles; public class DigitizeGlobeApplication extends JFrame { private static final long serialVersionUID = 1L; /** * @param args */ public static void main(String[] args) { // initialize the interop initializeInterop(); // initialize to a license level initializeArcGISLicenses(); // start the sample final DigitizeGlobeApplication thisClass = new DigitizeGlobeApplication(); thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SwingUtilities.invokeLater(new Runnable() { public void run() { thisClass.initializeUI(); thisClass.setVisible(true); try { String devKitHome = System.getenv("AGSDEVKITJAVA"); thisClass.getGlobe().load3dFile(devKitHome + "java" + File.separator + "samples" + File.separator + "data" + File.separator + "globe_data" + File.separator + "Default_Document.3dd"); } catch (java.lang.Throwable e) { e.printStackTrace(); } } }); } private void initializeUI() { this.setContentPane(getJContentPane()); this.setTitle("Digitize Points Sample"); this.setBounds(new Rectangle(0, 0, 600, 500)); } private JPanel jContentPane = null; private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout()); jContentPane.add(getGlobe(), BorderLayout.CENTER); jContentPane.add(getToolbar(), BorderLayout.NORTH); } return jContentPane; } private GlobeBean globe = null; private GlobeBean getGlobe() { if (globe == null) { globe = new GlobeBean(); } return globe; } private ToolbarBean toolbar = null; private ToolbarBean getToolbar() { if (toolbar == null) { try { toolbar = new ToolbarBean(); toolbar.addItem(new DigitizeTool(), 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconAndText); toolbar.addItem(new ControlsGlobeNavigateTool(), 0, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); toolbar.addItem(new ControlsGlobeNavigationModeCommand(), 0, 2, false, 0, esriCommandStyles.esriCommandStyleIconOnly); toolbar.addItem(new ControlsGlobeRotateToolbar(), 0, 3, false, 0, esriCommandStyles.esriCommandStyleIconOnly); toolbar.setBuddyControl(getGlobe()); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return toolbar; } static void initializeInterop() { // Visual beans mode required for multi-threaded applciations like // Swing. EngineInitializer.initializeVisualBeans(); } static 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 { System.err.println("Could not initialize an Engine or ArcView license. Exiting application."); System.exit(-1); } ao.checkOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst); } catch (Exception e) { e.printStackTrace(); } } }