arcgissamples\globe\AnimationPanel.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.Color; import java.awt.ComponentOrientation; import java.awt.Dimension; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import javax.swing.BorderFactory; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JTextField; import javax.swing.border.TitledBorder; import com.esri.arcgis.beans.globe.GlobeBean; /** * This class contains the code to build the Animation Panel UI. The real * arcobjects work is done in the AnimationPanelActionListener which is used to * handle events triggered by swing components in this class. */ public class AnimationPanel extends JPanel { private static final long serialVersionUID = 1L; //private Action closeAction; private GlobeBean globeBean; public AnimationPanel(GlobeBean globeBean) { super(); this.globeBean = globeBean; initializeUI(); } public void initializeUI() { buildUI(); try { // register the action listener ActionListener listener = new AnimationPanelActionListener(this, this.globeBean); this.getBtnBrowse_Load().addActionListener(listener); this.getBtnBrowse_Save().addActionListener(listener); this.getBtnCaptureView().addActionListener(listener); this.getBtnClear().addActionListener(listener); this.getBtnLoad().addActionListener(listener); this.getBtnPause().addActionListener(listener); this.getBtnPlay().addActionListener(listener); this.getBtnSave().addActionListener(listener); this.getBtnStop().addActionListener(listener); } catch (Exception e) { e.printStackTrace(); } } private void buildUI() { GridBagConstraints gridBagConstraints31 = new GridBagConstraints(); gridBagConstraints31.gridx = 0; gridBagConstraints31.ipadx = 3; gridBagConstraints31.insets = new Insets(8, 0, 0, 0); gridBagConstraints31.weightx = 1.0D; gridBagConstraints31.weighty = 1.0D; gridBagConstraints31.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints31.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints31.gridy = 2; GridBagConstraints gridBagConstraints30 = new GridBagConstraints(); gridBagConstraints30.gridx = 0; gridBagConstraints30.ipadx = -63; gridBagConstraints30.insets = new Insets(8, 0, 0, 0); gridBagConstraints30.weightx = 1.0D; gridBagConstraints30.weighty = 0.0D; gridBagConstraints30.fill = GridBagConstraints.BOTH; gridBagConstraints30.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints30.gridy = 1; GridBagConstraints gridBagConstraints29 = new GridBagConstraints(); gridBagConstraints29.fill = GridBagConstraints.BOTH; gridBagConstraints29.gridy = 0; gridBagConstraints29.ipadx = -239; gridBagConstraints29.weightx = 1.0; gridBagConstraints29.weighty = 0.0D; gridBagConstraints29.insets = new Insets(8, 0, 0, 0); gridBagConstraints29.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints29.gridx = 0; this.setLayout(new GridBagLayout()); this.add(getJTabbedPane(), gridBagConstraints29); this.add(getJPanel3(), gridBagConstraints30); this.add(getJPanel2(), gridBagConstraints31); this.setPreferredSize(new Dimension(275, 70)); } private JTabbedPane getJTabbedPane() { if (jTabbedPane == null) { try { jTabbedPane = new JTabbedPane(); jTabbedPane.setTabPlacement(JTabbedPane.TOP); jTabbedPane.addTab("Create Animation", null, getJPanel(), "Create Animation"); jTabbedPane.addTab("Load Animation", null, getJPanel1(), null); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return jTabbedPane; } public JPanel getJPanel() { if (jPanel == null) { try { GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.gridx = 1; gridBagConstraints1.weightx = 1.0D; gridBagConstraints1.anchor = GridBagConstraints.WEST; gridBagConstraints1.insets = new Insets(5, 5, 5, 0); gridBagConstraints1.gridy = 0; GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.weightx = 1.0D; gridBagConstraints.anchor = GridBagConstraints.EAST; gridBagConstraints.insets = new Insets(5, 0, 5, 5); gridBagConstraints.fill = GridBagConstraints.VERTICAL; gridBagConstraints.gridy = 0; jPanel = new JPanel(); jPanel.setLayout(new GridBagLayout()); jPanel.setName("Capture"); jPanel.setBorder(BorderFactory.createLineBorder(Color.black, 0)); jPanel.setComponentOrientation(ComponentOrientation.UNKNOWN); jPanel.add(getBtnCaptureView(), gridBagConstraints); jPanel.add(getBtnClear(), gridBagConstraints1); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return jPanel; } public JPanel getJPanel1() { if (jPanel1 == null) { try { GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); gridBagConstraints6.insets = new Insets(5, 5, 0, 0); gridBagConstraints6.anchor = GridBagConstraints.NORTHWEST; GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); gridBagConstraints5.gridwidth = 1; gridBagConstraints5.insets = new Insets(5, 0, 0, 5); gridBagConstraints5.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL; GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.gridy = 1; gridBagConstraints3.anchor = GridBagConstraints.NORTHEAST; gridBagConstraints3.ipady = 0; gridBagConstraints3.insets = new Insets(5, 5, 5, 5); gridBagConstraints3.gridwidth = 4; gridBagConstraints3.gridx = 0; GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.fill = GridBagConstraints.BOTH; gridBagConstraints2.gridwidth = 2; gridBagConstraints2.insets = new Insets(5, 0, 0, 5); gridBagConstraints2.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints2.weightx = 1.0; jLabel = new JLabel(); jLabel.setText("Load animation : "); jPanel1 = new JPanel(); jPanel1.setLayout(new GridBagLayout()); jPanel1.add(jLabel, gridBagConstraints6); jPanel1.add(getTxtLoad(), gridBagConstraints2); jPanel1.add(getBtnBrowse_Load(), gridBagConstraints5); jPanel1.add(getBtnLoad(), gridBagConstraints3); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return jPanel1; } public JPanel getJPanel2() { if (jPanel2 == null) { try { GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); gridBagConstraints10.insets = new Insets(5, 0, 0, 5); gridBagConstraints10.gridx = 0; gridBagConstraints10.anchor = GridBagConstraints.EAST; gridBagConstraints10.gridwidth = 4; gridBagConstraints10.gridy = 1; GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); gridBagConstraints9.gridx = 3; gridBagConstraints9.insets = new Insets(0, 0, 0, 5); gridBagConstraints9.fill = GridBagConstraints.NONE; gridBagConstraints9.gridy = 0; GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); gridBagConstraints8.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints8.insets = new Insets(0, 0, 0, 5); gridBagConstraints8.gridwidth = 2; gridBagConstraints8.weightx = 1.0; GridBagConstraints gridBagConstraints7 = new GridBagConstraints(); gridBagConstraints7.insets = new Insets(0, 5, 0, 0); jLabel1 = new JLabel(); jLabel1.setText("Save Animation : "); jLabel1.setName("txtSaveAnimation"); jPanel2 = new JPanel(); jPanel2.setLayout(new GridBagLayout()); jPanel2.setBorder(BorderFactory.createTitledBorder(null, "Save Animation", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); jPanel2.add(jLabel1, gridBagConstraints7); jPanel2.add(getTxtSave(), gridBagConstraints8); jPanel2.add(getBtnBrowse_Save(), gridBagConstraints9); jPanel2.add(getBtnSave(), gridBagConstraints10); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return jPanel2; } public JButton getBtnCaptureView() { if (btnCaptureView == null) { try { btnCaptureView = new JButton(); btnCaptureView.setText("Capture View"); btnCaptureView.setPreferredSize(new Dimension(110, 50)); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnCaptureView; } public JButton getBtnClear() { if (btnClear == null) { try { btnClear = new JButton(); btnClear.setText("Clear"); btnClear.setPreferredSize(new Dimension(64, 50)); btnClear.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnClear; } public JTextField getTxtLoad() { if (txtLoad == null) { try { txtLoad = new JTextField(); txtLoad.setPreferredSize(new Dimension(300, 20)); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return txtLoad; } public JButton getBtnBrowse_Load() { if (btnBrowse_Load == null) { try { btnBrowse_Load = new JButton(); btnBrowse_Load.setText("..."); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnBrowse_Load; } public JButton getBtnLoad() { if (btnLoad == null) { try { btnLoad = new JButton(); btnLoad.setText("Load"); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnLoad; } public JTextField getTxtSave() { if (txtSave == null) { try { txtSave = new JTextField(); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return txtSave; } public JButton getBtnBrowse_Save() { if (btnBrowse_Save == null) { try { btnBrowse_Save = new JButton(); btnBrowse_Save.setText("..."); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnBrowse_Save; } public JButton getBtnSave() { if (btnSave == null) { try { btnSave = new JButton(); btnSave.setText("Save"); btnSave.setName("btnSave"); btnSave.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnSave; } public JPanel getJPanel3() { if (jPanel3 == null) { try { GridBagConstraints gridBagConstraints19 = new GridBagConstraints(); gridBagConstraints19.gridx = 0; gridBagConstraints19.gridwidth = 3; gridBagConstraints19.anchor = GridBagConstraints.NORTH; gridBagConstraints19.fill = GridBagConstraints.BOTH; gridBagConstraints19.insets = new Insets(10, 0, 0, 0); gridBagConstraints19.gridy = 1; GridBagConstraints gridBagConstraints15 = new GridBagConstraints(); gridBagConstraints15.insets = new Insets(0, 5, 0, 0); GridBagConstraints gridBagConstraints14 = new GridBagConstraints(); gridBagConstraints14.insets = new Insets(0, 5, 0, 5); gridBagConstraints14.gridx = 2; gridBagConstraints14.weightx = 1.0D; gridBagConstraints14.anchor = GridBagConstraints.WEST; gridBagConstraints14.gridy = 0; GridBagConstraints gridBagConstraints13 = new GridBagConstraints(); gridBagConstraints13.insets = new Insets(0, 5, 0, 5); gridBagConstraints13.gridy = 0; gridBagConstraints13.weightx = 0.0D; gridBagConstraints13.anchor = GridBagConstraints.WEST; gridBagConstraints13.gridx = 1; GridBagConstraints gridBagConstraints12 = new GridBagConstraints(); gridBagConstraints12.insets = new Insets(0, 0, 0, 5); gridBagConstraints12.gridy = 0; gridBagConstraints12.weightx = 0.0D; gridBagConstraints12.anchor = GridBagConstraints.WEST; gridBagConstraints12.gridx = 0; jPanel3 = new JPanel(); jPanel3.setLayout(new GridBagLayout()); jPanel3.setBorder(BorderFactory.createTitledBorder(null, "Play Animation", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); jPanel3.add(getBtnPlay(), gridBagConstraints12); jPanel3.add(getBtnStop(), gridBagConstraints13); jPanel3.add(getBtnPause(), gridBagConstraints14); jPanel3.add(getJPanel5(), gridBagConstraints19); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return jPanel3; } public JButton getBtnPlay() { if (btnPlay == null) { try { btnPlay = new JButton(); btnPlay.setText("Play"); btnPlay.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnPlay; } public JButton getBtnStop() { if (btnStop == null) { try { btnStop = new JButton(); btnStop.setText("Stop"); btnStop.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnStop; } public JButton getBtnPause() { if (btnPause == null) { try { btnPause = new JButton(); btnPause.setText("Pause"); btnPause.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnPause; } public JPanel getJPanel4() { if (jPanel4 == null) { try { GridBagConstraints gridBagConstraints18 = new GridBagConstraints(); gridBagConstraints18.anchor = GridBagConstraints.WEST; gridBagConstraints18.weightx = 1.0D; gridBagConstraints18.insets = new Insets(0, 0, 0, 5); jLabel3 = new JLabel(); jLabel3.setText("seconds"); GridBagConstraints gridBagConstraints17 = new GridBagConstraints(); gridBagConstraints17.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints17.anchor = GridBagConstraints.WEST; gridBagConstraints17.insets = new Insets(0, 5, 0, 5); gridBagConstraints17.weightx = 1.0D; jLabel2 = new JLabel(); jLabel2.setText("Animation Duration : "); jPanel4 = new JPanel(); jPanel4.setLayout(new GridBagLayout()); jPanel4.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); jPanel4.add(jLabel2, new GridBagConstraints()); jPanel4.add(getTxtDuration(), gridBagConstraints17); jPanel4.add(jLabel3, gridBagConstraints18); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return jPanel4; } public JTextField getTxtDuration() { if (txtDuration == null) { try { txtDuration = new JTextField(); txtDuration.setPreferredSize(new Dimension(50, 20)); txtDuration.setText("20"); txtDuration.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return txtDuration; } public JPanel getJPanel5() { if (jPanel5 == null) { try { GridBagConstraints gridBagConstraints25 = new GridBagConstraints(); gridBagConstraints25.gridx = 0; gridBagConstraints25.fill = GridBagConstraints.BOTH; gridBagConstraints25.insets = new Insets(5, 0, 5, 0); gridBagConstraints25.gridy = 2; GridBagConstraints gridBagConstraints21 = new GridBagConstraints(); gridBagConstraints21.gridx = 0; gridBagConstraints21.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints21.insets = new Insets(5, 0, 5, 0); gridBagConstraints21.gridy = 1; GridBagConstraints gridBagConstraints16 = new GridBagConstraints(); gridBagConstraints16.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints16.insets = new Insets(5, 0, 5, 0); gridBagConstraints16.gridwidth = 1; gridBagConstraints16.gridx = -1; gridBagConstraints16.gridy = -1; gridBagConstraints16.weighty = 0.0D; gridBagConstraints16.fill = GridBagConstraints.BOTH; jPanel5 = new JPanel(); jPanel5.setLayout(new GridBagLayout()); jPanel5.setBorder(BorderFactory.createTitledBorder(null, "Options", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); jPanel5.add(getJPanel4(), gridBagConstraints16); jPanel5.add(getJPanel6(), gridBagConstraints21); jPanel5.add(getJPanel7(), gridBagConstraints25); // Setting this to invisible jPanel5.setVisible(true); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return jPanel5; } public JPanel getJPanel6() { if (jPanel6 == null) { try { GridBagConstraints gridBagConstraints27 = new GridBagConstraints(); gridBagConstraints27.insets = new Insets(0, 0, 0, 5); GridBagConstraints gridBagConstraints24 = new GridBagConstraints(); gridBagConstraints24.gridx = 4; gridBagConstraints24.gridy = 0; jLabel5 = new JLabel(); jLabel5.setText("seconds"); GridBagConstraints gridBagConstraints23 = new GridBagConstraints(); gridBagConstraints23.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints23.insets = new Insets(0, 0, 0, 5); gridBagConstraints23.weightx = 1.0; jLabel4 = new JLabel(); jLabel4.setText("to"); GridBagConstraints gridBagConstraints22 = new GridBagConstraints(); gridBagConstraints22.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints22.insets = new Insets(0, 0, 0, 5); gridBagConstraints22.weightx = 1.0; GridBagConstraints gridBagConstraints20 = new GridBagConstraints(); gridBagConstraints20.gridy = 0; gridBagConstraints20.gridx = 0; jPanel6 = new JPanel(); jPanel6.setLayout(new GridBagLayout()); jPanel6.add(getCheckboxUseIntervals(), gridBagConstraints20); jPanel6.add(getTxtIntervalFrom(), gridBagConstraints22); jPanel6.add(jLabel4, gridBagConstraints27); jPanel6.add(getTxtIntervalTo(), gridBagConstraints23); jPanel6.add(jLabel5, gridBagConstraints24); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return jPanel6; } public JCheckBox getCheckboxUseIntervals() { if (checkboxUseIntervals == null) { try { checkboxUseIntervals = new JCheckBox(); checkboxUseIntervals.setMnemonic(KeyEvent.VK_UNDEFINED); checkboxUseIntervals.setText("Play using intervals"); checkboxUseIntervals.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return checkboxUseIntervals; } public JTextField getTxtIntervalFrom() { if (txtIntervalFrom == null) { try { txtIntervalFrom = new JTextField(); txtIntervalFrom.setPreferredSize(new Dimension(50, 20)); txtIntervalFrom.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return txtIntervalFrom; } public JTextField getTxtIntervalTo() { if (txtIntervalTo == null) { try { txtIntervalTo = new JTextField(); txtIntervalTo.setPreferredSize(new Dimension(50, 20)); txtIntervalTo.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return txtIntervalTo; } public JPanel getJPanel7() { if (jPanel7 == null) { try { GridBagConstraints gridBagConstraints28 = new GridBagConstraints(); gridBagConstraints28.insets = new Insets(0, 0, 0, 5); GridBagConstraints gridBagConstraints26 = new GridBagConstraints(); gridBagConstraints26.fill = GridBagConstraints.VERTICAL; gridBagConstraints26.anchor = GridBagConstraints.WEST; gridBagConstraints26.weightx = 1.0; jLabel6 = new JLabel(); jLabel6.setText("Looping option :"); jPanel7 = new JPanel(); jPanel7.setLayout(new GridBagLayout()); jPanel7.add(jLabel6, gridBagConstraints28); jPanel7.add(getComboLoopingOption(), gridBagConstraints26); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return jPanel7; } public JComboBox getComboLoopingOption() { if (comboLoopingOption == null) { try { comboLoopingOption = new JComboBox(); comboLoopingOption.setPreferredSize(new Dimension(160, 25)); DefaultComboBoxModel model = new DefaultComboBoxModel(); model.addElement("Play once forward"); model.addElement("Loop forwad"); model.addElement("Play once reverse"); model.addElement("Loop forward and reverse"); comboLoopingOption.setModel(model); comboLoopingOption.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return comboLoopingOption; } private JTabbedPane jTabbedPane = null; private JPanel jPanel = null; private JPanel jPanel1 = null; private JPanel jPanel2 = null; private JButton btnCaptureView = null; private JButton btnClear = null; private JLabel jLabel = null; private JTextField txtLoad = null; private JButton btnBrowse_Load = null; private JButton btnLoad = null; private JLabel jLabel1 = null; private JTextField txtSave = null; private JButton btnBrowse_Save = null; private JButton btnSave = null; private JPanel jPanel3 = null; private JButton btnPlay = null; private JButton btnStop = null; private JButton btnPause = null; private JPanel jPanel4 = null; private JLabel jLabel2 = null; private JTextField txtDuration = null; private JLabel jLabel3 = null; private JPanel jPanel5 = null; private JPanel jPanel6 = null; private JCheckBox checkboxUseIntervals = null; private JTextField txtIntervalFrom = null; private JLabel jLabel4 = null; private JTextField txtIntervalTo = null; private JLabel jLabel5 = null; private JPanel jPanel7 = null; private JLabel jLabel6 = null; private JComboBox comboLoopingOption = null; }