arcgissamples\cartography\propertypage\MZPropertyPageUI.java—ArcObjects 10.4 Help for Java | ArcGIS for Desktop
MZ renderer
arcgissamples\cartography\propertypage\MZPropertyPageUI.java
/* Copyright 2015 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 at <your ArcGIS install location>/DeveloperKit10.4/userestrictions.txt.
* 
*/
package arcgissamples.cartography.propertypage;

import java.awt.Rectangle;
import java.awt.event.ActionEvent;

import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;

import arcgissamples.cartography.MZRenderer;

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 MZPropertyPageUI extends JFrame {

  public JPanel jContentPane = null;
  public JPanel jPanel = null;
  public static JRadioButton jrdMeasures = null;
  public static JRadioButton jrdZValues = null;
  public JLabel jLblMeasures = null;
  public JLabel jLblZMeasures = null;
  public JLabel jLblOrientation = null;
  public JLabel jLblInterval = null;
  public static JComboBox jCmbLabelOrientation = null;
  public static JComboBox jCmbLabelInterval = null;
  public static JComboBox jCmbMarkerOrientation = null;
  public JLabel jLblMOrientation = null;
  public static ButtonGroup group;
  static AoInitialize aoInit;

  /**
   * This is the default constructor
   */
  public MZPropertyPageUI() {
    super();
    initialize();
  }

  /**
   * This method initializes this
   *
   * @return void
   */
  private void initialize() {
    this.setSize(424, 254);
    this.setContentPane(getJContentPane());
    this.setTitle("MZRenderer");
  }

  /**
   * This method initializes jContentPane
   *
   * @return javax.swing.JPanel
   */
  private JPanel getJContentPane() {
    if (jContentPane == null) {
      jLblMOrientation = new JLabel();
      jLblMOrientation.setBounds(new Rectangle(226, 89, 126, 16));
      jLblMOrientation.setText("Marker Orientation :");
      jLblInterval = new JLabel();
      jLblInterval.setBounds(new Rectangle(227, 15, 105, 16));
      jLblInterval.setText("Label Interval :");
      jLblOrientation = new JLabel();
      jLblOrientation.setBounds(new Rectangle(18, 132, 140, 16));
      jLblOrientation.setText("Label Orientation :");
      jContentPane = new JPanel();
      jContentPane.setLayout(null);
      jContentPane.add(getJPanel(), null);
      jContentPane.add(jLblOrientation, null);
      jContentPane.add(getJCmbLabelOrientation(), null);
      jContentPane.add(jLblInterval, null);
      jContentPane.add(getJCmbLabelInterval(), null);
      jContentPane.add(jLblMOrientation, null);
      jContentPane.add(getJCmbMarkerOrientation(), 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) {
      jLblZMeasures = new JLabel();
      jLblZMeasures.setBounds(new Rectangle(46, 59, 121, 16));
      jLblZMeasures.setText("Z-Values");
      jLblMeasures = new JLabel();
      jLblMeasures.setBounds(new Rectangle(45, 32, 121, 16));
      jLblMeasures.setText("Measures");
      jPanel = new JPanel();
      jPanel.setLayout(null);
      TitledBorder titled = new TitledBorder("Rendering mode");
      jPanel.setBorder(titled);
      jPanel.setBounds(new Rectangle(16, 12, 199, 105));
      jPanel.add(getJRadioMeasures(), null);
      jPanel.add(getJRadioZValues(), null);
      group = new ButtonGroup();
      group.add(jrdMeasures);
      group.add(jrdZValues);
      jPanel.add(jLblMeasures, null);
      jPanel.add(jLblZMeasures, null);
    }
    return jPanel;
  }

  /**
   * This method initializes jRadioButton
   *
   * @return javax.swing.JRadioButton
   */
  private JRadioButton getJRadioMeasures() {
    if (jrdMeasures == null) {
      jrdMeasures = new JRadioButton("Measures");
      jrdMeasures.setName("Measures");
      jrdMeasures.setBounds(new Rectangle(17, 30, 21, 21));
      jrdMeasures.setEnabled(true);
    }
    return jrdMeasures;
  }

  /**
   * This method initializes jRadioButton1
   *
   * @return javax.swing.JRadioButton
   */
  private JRadioButton getJRadioZValues() {
    if (jrdZValues == null) {
      jrdZValues = new JRadioButton("ZValues");
      jrdMeasures.setName("Zvalues");
      jrdZValues.setBounds(new Rectangle(17, 59, 21, 21));
      jrdZValues.setEnabled(true);
    }
    return jrdZValues;
  }

  /**
   * This method initializes jCmbLabelOrientation
   *
   * @return javax.swing.JComboBox
   */
  private JComboBox getJCmbLabelOrientation() {
    if (jCmbLabelOrientation == null) {
      jCmbLabelOrientation = new JComboBox();
      jCmbLabelOrientation.setBounds(new Rectangle(17, 151, 142, 26));
      jCmbLabelOrientation.addItem("Along");
      jCmbLabelOrientation.addItem("Horizontal");
      jCmbLabelOrientation.addItem("Perpendicular");
    }
    return jCmbLabelOrientation;
  }

  /**
   * This method initializes jCmbLabelInterval
   *
   * @return javax.swing.JComboBox
   */
  private JComboBox getJCmbLabelInterval() {
    if (jCmbLabelInterval == null) {
      jCmbLabelInterval = new JComboBox();
      jCmbLabelInterval.setBounds(new Rectangle(226, 39, 106, 25));
      jCmbLabelInterval.addItem("1");
      jCmbLabelInterval.addItem("2");
      jCmbLabelInterval.addItem("3");
      jCmbLabelInterval.addItem("4");
      jCmbLabelInterval.addItem("5");
      jCmbLabelInterval.addItem("6");
    }
    return jCmbLabelInterval;
  }

  /**
   * This method initializes jCmbMarkerOrientation
   *
   * @return javax.swing.JComboBox
   */
  private JComboBox getJCmbMarkerOrientation() {
    if (jCmbMarkerOrientation == null) {
      jCmbMarkerOrientation = new JComboBox();
      jCmbMarkerOrientation.setBounds(new Rectangle(226, 113, 127, 25));
      jCmbMarkerOrientation.addItem("Along");
      jCmbMarkerOrientation.addItem("Horizontal");
      jCmbMarkerOrientation.addItem("Perpendicular");
    }
    return jCmbMarkerOrientation;
  }

  public void actionPerformed(ActionEvent event) {
    Object eventSource = event.getSource();
    try {
      MZRenderer rend = new MZRenderer();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  public static void main(String[] args) throws Exception {
    EngineInitializer.initializeVisualBeans();

    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    initializeArcGISLicenses();

    MZPropertyPageUI thisClass;
    try {
      thisClass = new MZPropertyPageUI();
      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.esriLicenseProductCodeBasic)
          == esriLicenseStatus.esriLicenseAvailable)
        aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeBasic);
    } catch (Exception e) {e.printStackTrace();}
  }
}