arcgissamples\cartography\propertypage\PointDispersalPropertyPageUI.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.cartography.propertypage; import java.awt.Rectangle; import java.io.File; import java.io.IOException; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.border.TitledBorder; import com.esri.arcgis.controls.ISymbologyControlEventsAdapter; import com.esri.arcgis.controls.ISymbologyControlEventsOnItemSelectedEvent; import com.esri.arcgis.controls.SymbologyControl; import com.esri.arcgis.controls.esriSymbologyStyleClass; import com.esri.arcgis.display.IStyleGalleryItem; import com.esri.arcgis.display.IStyleGalleryItemProxy; import com.esri.arcgis.system.AoInitialize; import com.esri.arcgis.system.EngineInitializer; import com.esri.arcgis.system.esriLicenseProductCode; import com.esri.arcgis.system.esriLicenseStatus; public class PointDispersalPropertyPageUI extends JFrame { static AoInitialize aoInit; private JPanel jContentPane = null; private JLabel jLabel = null; private JTextField jTextField = null; private JPanel jPanel = null; private JLabel jLabel1 = null; private JPanel jPanel1 = null; private JLabel jLabel2 = null; private SymbologyControl symbologyControl; public static IStyleGalleryItem styleGalleryItem; /** * This method initializes jTextField * @return javax.swing.JTextField */ public JTextField getJTextField() { if (jTextField == null) { jTextField = new JTextField(); jTextField.setBounds(new Rectangle(107, 98, 100, 27)); } return jTextField; } /** * This is the default constructor */ public PointDispersalPropertyPageUI() throws Exception { super(); initialize(); addListener(); } /** * This method initializes this * @return void */ private void initialize() throws Exception { this.setSize(512, 368); this.setResizable(false); this.setContentPane(getJContentPane()); this.setTitle("Dispersal Property Page"); } /** * This method initializes jContentPane * @return javax.swing.JPanel */ private JPanel getJContentPane() throws Exception { if (jContentPane == null) { jContentPane = new JPanel(); jLabel = new JLabel(); jLabel.setText("Dispersal Ratio"); jLabel.setBounds(new Rectangle(14, 97, 83, 27)); jContentPane.setLayout(null); jContentPane.add(getJPanel(), null); } return jContentPane; } static { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } } /** * This method initializes jPanel * @return javax.swing.JPanel */ private JPanel getJPanel() { if (jPanel == null) { jLabel2 = new JLabel(); jLabel2.setBounds(new Rectangle(16, 151, 83, 27)); jLabel2.setText("Select Symbol"); jLabel1 = new JLabel(); jLabel1.setBounds(new Rectangle(12, 35, 385, 40)); jLabel1.setText("This ratio affects how far the marker symbol is moved from it's original location"); jPanel = new JPanel(); jPanel.setLayout(null); jPanel.setBounds(new Rectangle(8, 14, 502, 329)); TitledBorder titled = new TitledBorder("Change Dispersal Ratio"); jPanel.setBorder(titled); jPanel.add(jLabel, null); jPanel.add(getJTextField(), null); jPanel.add(jLabel1, null); jPanel.add(getJPanel1(), null); jPanel.add(jLabel2, null); } return jPanel; } /** * This method initializes jPanel1 * @return javax.swing.JPanel */ private JPanel getJPanel1() { if (jPanel1 == null) { jPanel1 = new JPanel(); jPanel1.setLayout(null); jPanel1.setBounds(new Rectangle(109, 138, 297, 158)); symbologyControl = new SymbologyControl(); //Get the ArcGIS Engine runtime, if it is available String arcObjectsHome = System.getenv("AGSENGINEJAVA"); //If the ArcGIS Engine runtime is not available, then we can try ArcGIS Desktop runtime if(arcObjectsHome == null){ arcObjectsHome = System.getenv("AGSDESKTOPJAVA"); } try { symbologyControl.loadStyleFile(arcObjectsHome + "Styles" + File.separator + "ESRI.ServerStyle"); symbologyControl.setStyleClass(esriSymbologyStyleClass.esriStyleClassMarkerSymbols); symbologyControl.setSize(300, 100); jPanel1.add(symbologyControl); } catch (IOException e) { e.printStackTrace(); } } return jPanel1; } public void addListener() { try { symbologyControl.addISymbologyControlEventsListener(new ISymbologyControlEventsAdapter() { private static final long serialVersionUID = 1L; public void onItemSelected( ISymbologyControlEventsOnItemSelectedEvent theEvent) { try { // get the selected stylegalleryitem styleGalleryItem = new IStyleGalleryItemProxy(theEvent.getStyleGalleryItem()); } catch (Exception e) { e.printStackTrace(); } } }); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) throws Exception { PointDispersalPropertyPageUI thisClass; EngineInitializer.initializeVisualBeans(); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); initializeArcGISLicenses(); try { thisClass = new PointDispersalPropertyPageUI(); thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); thisClass.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } static void initializeArcGISLicenses() { try { aoInit = new AoInitialize(); if (aoInit.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcView) == esriLicenseStatus.esriLicenseAvailable) aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeArcView); } catch (Exception e) {e.printStackTrace();} } }