Java tutorial
/* * MainFrame.java * * Created by DFKI AV on 14.09.2011. * Copyright (c) 2011-2012 DFKI GmbH, Kaiserslautern. All rights reserved. * Use is subject to license terms. */ package com.dfki.av.sudplan.ui; import com.dfki.av.sudplan.Configuration; import com.dfki.av.sudplan.camera.AnimatedCamera; import com.dfki.av.sudplan.camera.Camera; import com.dfki.av.sudplan.camera.SimpleCamera; import com.dfki.av.sudplan.camera.Vector3D; import com.dfki.av.sudplan.vis.VisualizationPanel; import com.dfki.av.sudplan.vis.core.IVisAlgorithm; import com.dfki.av.sudplan.vis.core.VisPointCloud; import com.dfki.av.sudplan.vis.spi.VisAlgorithmFactory; import com.dfki.av.sudplan.wms.EventHolder; import com.dfki.av.sudplan.wms.LayerInfo; import com.dfki.av.sudplan.wms.LayerInfoRetreiver; import gov.nasa.worldwind.View; import gov.nasa.worldwind.awt.WorldWindowGLCanvas; import gov.nasa.worldwind.geom.Position; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.net.URI; import java.util.List; import javax.swing.*; import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileNameExtensionFilter; import org.apache.commons.configuration.XMLConfiguration; import org.apache.log4j.Level; import org.apache.log4j.PatternLayout; import org.apache.log4j.RollingFileAppender; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * * @author Daniel Steffen <daniel.steffen at dfki.de> */ public class MainFrame extends javax.swing.JFrame implements PropertyChangeListener { /** * The root logger. */ private static org.apache.log4j.Logger rootLog = org.apache.log4j.Logger.getRootLogger(); /** * The logger. */ private static final Logger log = LoggerFactory.getLogger(MainFrame.class); /** * The size of the {@link #wwPanel}. */ private Dimension canvasSize; /** * The visualization panel wrapping the WorldWind canvas. */ private VisualizationPanel wwPanel; /** * The counter of saved views. */ private static int viewID = 0; /** * Creates new form MainFrame */ public MainFrame() { JPopupMenu.setDefaultLightWeightPopupEnabled(false); this.canvasSize = new Dimension(1500, 800); this.wwPanel = new VisualizationPanel(canvasSize); this.wwPanel.setPreferredSize(canvasSize); initComponents(); // Add LayerTreeComponent to the left split panel. JPanel layerTreeComponent = wwPanel.getLayerPanel(); if (layerTreeComponent != null) { pLeftPanel.add(layerTreeComponent); } else { log.debug("layerTreeComponent == null"); } } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { dGoTo = new javax.swing.JDialog(); pGoTo = new javax.swing.JPanel(); lLatitude = new javax.swing.JLabel(); lLongitude = new javax.swing.JLabel(); txtLatitude = new javax.swing.JTextField(); txtLongitude = new javax.swing.JTextField(); btnCancelGoToDialoag = new javax.swing.JButton(); btnGo = new javax.swing.JButton(); dWMSHeight = new javax.swing.JDialog(); lMaxEle = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); lServerURL = new javax.swing.JLabel(); rbCbServerUrl = new javax.swing.JRadioButton(); rbTxtServerUrl = new javax.swing.JRadioButton(); txtServerURL = new javax.swing.JTextField(); cbServerURL = new javax.swing.JComboBox(); bGoWMSHeight = new javax.swing.JButton(); pbWMS = new javax.swing.JProgressBar(); jPanel4 = new javax.swing.JPanel(); bCancelWMSHeight = new javax.swing.JButton(); bAddWMSHeight = new javax.swing.JButton(); cLayerList = new javax.swing.JComboBox(); txtHeight = new javax.swing.JTextField(); lHeight = new javax.swing.JLabel(); lOpacity = new javax.swing.JLabel(); txtOpacity = new javax.swing.JTextField(); bgWMS = new javax.swing.ButtonGroup(); pMain = new javax.swing.JPanel(); jSplitPane1 = new javax.swing.JSplitPane(); pLeftPanel = new javax.swing.JPanel(); pVisualization = new javax.swing.JPanel(); mbMain = new javax.swing.JMenuBar(); mFile = new javax.swing.JMenu(); miOpenKMLFile = new javax.swing.JMenuItem(); miAddGeoTiff = new javax.swing.JMenuItem(); miAddShape = new javax.swing.JMenuItem(); miAddShapeZip = new javax.swing.JMenuItem(); jSeparator2 = new javax.swing.JPopupMenu.Separator(); miExit = new javax.swing.JMenuItem(); mEdit = new javax.swing.JMenu(); miRemoveAllLayer = new javax.swing.JMenuItem(); mNavi = new javax.swing.JMenu(); miGotoLinz = new javax.swing.JMenuItem(); miGotoPraque = new javax.swing.JMenuItem(); miGoToStockhom = new javax.swing.JMenuItem(); miGotoWuppertal = new javax.swing.JMenuItem(); miGotoKaiserslautern = new javax.swing.JMenuItem(); jSeparator5 = new javax.swing.JPopupMenu.Separator(); miFullSphere = new javax.swing.JMenuItem(); miGoto = new javax.swing.JMenuItem(); jSeparator3 = new javax.swing.JPopupMenu.Separator(); miSaveView = new javax.swing.JMenuItem(); mCustomViewPoints = new javax.swing.JMenu(); mWMS = new javax.swing.JMenu(); miAddWMS = new javax.swing.JMenuItem(); miAddWMSHeight = new javax.swing.JMenuItem(); mTools = new javax.swing.JMenu(); miWizard = new javax.swing.JMenuItem(); mView = new javax.swing.JMenu(); miSideBySide = new javax.swing.JMenuItem(); mHelp = new javax.swing.JMenu(); miAbout = new javax.swing.JMenuItem(); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("com/dfki/av/sudplan/ui/Bundle"); // NOI18N dGoTo.setTitle(bundle.getString("MainFrame.dGoTo.title")); // NOI18N dGoTo.setAlwaysOnTop(true); dGoTo.setMinimumSize(new java.awt.Dimension(230, 150)); dGoTo.setResizable(false); pGoTo.setMaximumSize(new java.awt.Dimension(200, 100)); lLatitude.setLabelFor(txtLatitude); lLatitude.setText(bundle.getString("MainFrame.lLatitude.text")); // NOI18N lLongitude.setLabelFor(txtLongitude); lLongitude.setText(bundle.getString("MainFrame.lLongitude.text")); // NOI18N txtLatitude.setText(bundle.getString("MainFrame.txtLatitude.text")); // NOI18N txtLongitude.setText(bundle.getString("MainFrame.txtLongitude.text")); // NOI18N javax.swing.GroupLayout pGoToLayout = new javax.swing.GroupLayout(pGoTo); pGoTo.setLayout(pGoToLayout); pGoToLayout.setHorizontalGroup(pGoToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pGoToLayout.createSequentialGroup().addContainerGap() .addGroup(pGoToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lLongitude).addComponent(lLatitude)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE) .addGroup(pGoToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtLatitude, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtLongitude)) .addContainerGap())); pGoToLayout.setVerticalGroup(pGoToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pGoToLayout.createSequentialGroup().addContainerGap().addGroup(pGoToLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(lLatitude) .addComponent(txtLatitude, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(pGoToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lLongitude).addComponent(txtLongitude, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); btnCancelGoToDialoag.setText(bundle.getString("MainFrame.btnCancelGoToDialoag.text")); // NOI18N btnCancelGoToDialoag.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCancelGoToDialoagActionPerformed(evt); } }); btnGo.setText(bundle.getString("MainFrame.btnGo.text")); // NOI18N btnGo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnGoActionPerformed(evt); } }); javax.swing.GroupLayout dGoToLayout = new javax.swing.GroupLayout(dGoTo.getContentPane()); dGoTo.getContentPane().setLayout(dGoToLayout); dGoToLayout.setHorizontalGroup(dGoToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(dGoToLayout.createSequentialGroup().addContainerGap() .addGroup(dGoToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dGoToLayout.createSequentialGroup().addComponent(btnGo) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnCancelGoToDialoag)) .addComponent(pGoTo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); dGoToLayout.setVerticalGroup(dGoToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(dGoToLayout.createSequentialGroup().addContainerGap() .addComponent(pGoTo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(dGoToLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnCancelGoToDialoag).addComponent(btnGo)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); dWMSHeight.setTitle(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.dWMSHeight.title")); // NOI18N dWMSHeight.setIconImage(com.dfki.av.sudplan.Configuration.SUDPLAN_3D_IMAGE); dWMSHeight.setLocationByPlatform(true); dWMSHeight.setMinimumSize(new java.awt.Dimension(800, 360)); dWMSHeight.setResizable(false); lMaxEle.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.lMaxEle.text")); // NOI18N jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.jPanel1.border.title"))); // NOI18N jPanel1.setToolTipText( org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.jPanel1.toolTipText")); // NOI18N jPanel1.setName(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.jPanel1.name")); // NOI18N lServerURL.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.lServerURL.text")); // NOI18N bgWMS.add(rbCbServerUrl); rbCbServerUrl.setSelected(true); rbCbServerUrl .setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.rbCbServerUrl.text")); // NOI18N rbCbServerUrl.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { rbCbServerUrlActionPerformed(evt); } }); bgWMS.add(rbTxtServerUrl); rbTxtServerUrl .setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.rbTxtServerUrl.text")); // NOI18N rbTxtServerUrl.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { rbTxtServerUrlActionPerformed(evt); } }); txtServerURL.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.txtServerURL.text")); // NOI18N txtServerURL.setToolTipText( org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.txtServerURL.toolTipText")); // NOI18N txtServerURL.setEnabled(false); cbServerURL.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "http://aniara.smhi.se/cap_SERVICE=WMS.xml", "http://geoportal.wuppertal.de:8083/deegree/wms?", "http://serv-2118.kl.dfki.de:8888/geoserver/wms?service=WMS&version=1.1.0", "http://www2.demis.nl/worldmap/wms.asp?Service=WMS&Version=1.1.0&Request=GetCapabilities", "http://www.wms.nrw.de/geobasis/DOP", "http://mapbender.wheregroup.com/cgi-bin/mapserv?map=/data/umn/osm/osm_basic.map&VERSION=1.1.1&REQUEST=GetCapabilities&SERVICE=WMS", "http://kartor.stockholm.se/bios/wms/app/baggis/web/WMS_STHLM_ORTOFOTO_2009?", "http://kartor.stockholm.se/bios/wms/app/baggis/web/WMS_STHLM_TATORTSKARTA_RASTER?", "http://85.24.165.10/cap_SERVICE=WMS.xml" })); bGoWMSHeight.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.bGoWMSHeight.text")); // NOI18N bGoWMSHeight.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bGoWMSHeightActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout .setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(lServerURL).addGap(0, 0, Short.MAX_VALUE)) .addGroup( jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(rbCbServerUrl) .addComponent(rbTxtServerUrl)) .addGap(10, 10, 10) .addGroup(jPanel1Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtServerURL) .addComponent(cbServerURL, 0, 1, Short.MAX_VALUE))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout .createSequentialGroup() .addComponent(pbWMS, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18).addComponent(bGoWMSHeight))) .addContainerGap())); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addComponent(lServerURL) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cbServerURL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(rbCbServerUrl)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtServerURL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(rbTxtServerUrl)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(bGoWMSHeight).addComponent(pbWMS, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder( org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.jPanel4.border.title"))); // NOI18N bCancelWMSHeight .setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.bCancelWMSHeight.text")); // NOI18N bCancelWMSHeight.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bCancelWMSHeightActionPerformed(evt); } }); bAddWMSHeight .setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.bAddWMSHeight.text")); // NOI18N bAddWMSHeight.setEnabled(false); bAddWMSHeight.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bAddWMSHeightActionPerformed(evt); } }); cLayerList.setEnabled(false); txtHeight.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.txtHeight.text")); // NOI18N lHeight.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.lHeight.text")); // NOI18N lOpacity.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.lOpacity.text")); // NOI18N txtOpacity.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.txtOpacity.text")); // NOI18N javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup().addComponent(lHeight) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtHeight, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(lOpacity) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtOpacity, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 194, Short.MAX_VALUE) .addComponent(bAddWMSHeight) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bCancelWMSHeight)) .addComponent(cLayerList, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() .addContainerGap() .addComponent(cLayerList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(bCancelWMSHeight) .addComponent(bAddWMSHeight, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lHeight).addComponent(lOpacity).addComponent(txtOpacity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap())); javax.swing.GroupLayout dWMSHeightLayout = new javax.swing.GroupLayout(dWMSHeight.getContentPane()); dWMSHeight.getContentPane().setLayout(dWMSHeightLayout); dWMSHeightLayout.setHorizontalGroup(dWMSHeightLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(dWMSHeightLayout.createSequentialGroup().addContainerGap() .addGroup(dWMSHeightLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(dWMSHeightLayout.createSequentialGroup().addGap(732, 732, 732) .addComponent(lMaxEle, javax.swing.GroupLayout.PREFERRED_SIZE, 287, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(dWMSHeightLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); dWMSHeightLayout.setVerticalGroup(dWMSHeightLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(dWMSHeightLayout.createSequentialGroup().addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(296, 296, 296) .addComponent(lMaxEle, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle(bundle.getString("MainFrame.title")); // NOI18N pMain.setPreferredSize(new java.awt.Dimension(1200, 1024)); jSplitPane1.setContinuousLayout(true); jSplitPane1.setLastDividerLocation(1); jSplitPane1.setPreferredSize(new java.awt.Dimension(1024, 768)); pLeftPanel.setLayout(new java.awt.BorderLayout()); jSplitPane1.setLeftComponent(pLeftPanel); pVisualization.setLayout(new java.awt.BorderLayout()); pVisualization.add(wwPanel, java.awt.BorderLayout.CENTER); jSplitPane1.setRightComponent(pVisualization); javax.swing.GroupLayout pMainLayout = new javax.swing.GroupLayout(pMain); pMain.setLayout(pMainLayout); pMainLayout.setHorizontalGroup(pMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 804, Short.MAX_VALUE)); pMainLayout.setVerticalGroup(pMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 610, Short.MAX_VALUE)); mFile.setText(bundle.getString("MainFrame.mFile.text")); // NOI18N miOpenKMLFile .setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.miOpenKMLFile.text")); // NOI18N miOpenKMLFile.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miOpenDataActionPerformed(evt); } }); mFile.add(miOpenKMLFile); miAddGeoTiff.setText(bundle.getString("MainFrame.miAddGeoTiff.text")); // NOI18N miAddGeoTiff.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miOpenDataActionPerformed(evt); } }); mFile.add(miAddGeoTiff); miAddShape.setText(bundle.getString("MainFrame.miAddShape.text")); // NOI18N miAddShape.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miOpenDataActionPerformed(evt); } }); mFile.add(miAddShape); miAddShapeZip .setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.miAddShapeZip.text")); // NOI18N miAddShapeZip.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miOpenDataActionPerformed(evt); } }); mFile.add(miAddShapeZip); mFile.add(jSeparator2); miExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.ALT_MASK)); miExit.setText(bundle.getString("MainFrame.miExit.text")); // NOI18N miExit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miExitActionPerformed(evt); } }); mFile.add(miExit); mbMain.add(mFile); mEdit.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.mEdit.text")); // NOI18N miRemoveAllLayer.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.ALT_MASK)); miRemoveAllLayer.setText(bundle.getString("MainFrame.miRemoveAllLayer.text")); // NOI18N miRemoveAllLayer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miRemoveAllLayerActionPerformed(evt); } }); mEdit.add(miRemoveAllLayer); mbMain.add(mEdit); mNavi.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.mNavi.text")); // NOI18N miGotoLinz.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.CTRL_MASK)); miGotoLinz.setText(bundle.getString("MainFrame.miGotoLinz.text")); // NOI18N miGotoLinz.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miGotoLinzActionPerformed(evt); } }); mNavi.add(miGotoLinz); miGotoPraque.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK)); miGotoPraque.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.miGotoPraque.text")); // NOI18N miGotoPraque.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miGotoPraqueActionPerformed(evt); } }); mNavi.add(miGotoPraque); miGoToStockhom.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); miGoToStockhom.setText(bundle.getString("MainFrame.miGoToStockhom.text")); // NOI18N miGoToStockhom.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miGoToStockhomActionPerformed(evt); } }); mNavi.add(miGoToStockhom); miGotoWuppertal.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK)); miGotoWuppertal.setText(bundle.getString("MainFrame.miGotoWuppertal.text")); // NOI18N miGotoWuppertal.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miGotoWuppertalActionPerformed(evt); } }); mNavi.add(miGotoWuppertal); miGotoKaiserslautern.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_K, java.awt.event.InputEvent.CTRL_MASK)); miGotoKaiserslautern.setText( org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.miGotoKaiserslautern.text")); // NOI18N miGotoKaiserslautern.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miGotoKaiserslauternActionPerformed(evt); } }); mNavi.add(miGotoKaiserslautern); mNavi.add(jSeparator5); miFullSphere.setText(bundle.getString("MainFrame.miFullSphere.text")); // NOI18N miFullSphere.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miFullSphereActionPerformed(evt); } }); mNavi.add(miFullSphere); miGoto.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.CTRL_MASK)); miGoto.setText(bundle.getString("MainFrame.miGoto.text")); // NOI18N miGoto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miGotoActionPerformed(evt); } }); mNavi.add(miGoto); mNavi.add(jSeparator3); miSaveView.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SPACE, java.awt.event.InputEvent.CTRL_MASK)); miSaveView.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.miSaveView.text")); // NOI18N miSaveView.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miSaveViewActionPerformed(evt); } }); mNavi.add(miSaveView); mCustomViewPoints .setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.mCustomViewPoints.text")); // NOI18N mNavi.add(mCustomViewPoints); mbMain.add(mNavi); mWMS.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.mWMS.text")); // NOI18N miAddWMS.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.miAddWMS.text")); // NOI18N miAddWMS.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miAddWMSActionPerformed(evt); } }); mWMS.add(miAddWMS); miAddWMSHeight .setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.miAddWMSHeight.text")); // NOI18N miAddWMSHeight.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miAddWMSHeightActionPerformed(evt); } }); mWMS.add(miAddWMSHeight); mbMain.add(mWMS); mTools.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.mTools.text")); // NOI18N miWizard.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.ALT_MASK)); miWizard.setText(bundle.getString("MainFrame.miWizard.text")); // NOI18N miWizard.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miWizardActionPerformed(evt); } }); mTools.add(miWizard); mbMain.add(mTools); mView.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.mView.text")); // NOI18N miSideBySide.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK)); miSideBySide.setText(org.openide.util.NbBundle.getMessage(MainFrame.class, "MainFrame.miSideBySide.text")); // NOI18N miSideBySide.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miSideBySideActionPerformed(evt); } }); mView.add(miSideBySide); mbMain.add(mView); mHelp.setText(bundle.getString("MainFrame.mHelp.text")); // NOI18N miAbout.setText(bundle.getString("MainFrame.miAbout.text")); // NOI18N miAbout.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { miAboutActionPerformed(evt); } }); mHelp.add(miAbout); mbMain.add(mHelp); setJMenuBar(mbMain); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(pMain, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 804, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( pMain, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 610, Short.MAX_VALUE)); pack(); }// </editor-fold>//GEN-END:initComponents private void miExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miExitActionPerformed System.exit(0); }//GEN-LAST:event_miExitActionPerformed private void miGotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miGotoActionPerformed dGoTo.setVisible(true); }//GEN-LAST:event_miGotoActionPerformed private void btnCancelGoToDialoagActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelGoToDialoagActionPerformed dGoTo.setVisible(false); }//GEN-LAST:event_btnCancelGoToDialoagActionPerformed private void btnGoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGoActionPerformed try { double lat = Double.parseDouble(txtLatitude.getText()); double lon = Double.parseDouble(txtLongitude.getText()); wwPanel.setCamera(new SimpleCamera(lat, lon, 200000.0)); dGoTo.setVisible(false); } catch (NumberFormatException nfe) { log.warn("The content of the \"latitude\" and \"longitude\" " + "component must be a double value."); } }//GEN-LAST:event_btnGoActionPerformed private void miAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miAboutActionPerformed ImageIcon icon = new ImageIcon(Configuration.SUDPLAN_3D_IMAGE); JOptionPane.showMessageDialog(this, "This is the sudplan3D application." + "\nDFKI (c) 2011-2012", "About sudplan3D", JOptionPane.INFORMATION_MESSAGE, icon); }//GEN-LAST:event_miAboutActionPerformed private void miWizardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miWizardActionPerformed wwPanel.runVisWiz(); }//GEN-LAST:event_miWizardActionPerformed private void miRemoveAllLayerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miRemoveAllLayerActionPerformed wwPanel.removeAllLayers(); }//GEN-LAST:event_miRemoveAllLayerActionPerformed private void miGoToStockhomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miGoToStockhomActionPerformed Camera camera = wwPanel.getCamera(); Vector3D vector = camera.getViewingDirection(); wwPanel.setCamera(new AnimatedCamera(59.328, 18.047, 20000.0, vector)); }//GEN-LAST:event_miGoToStockhomActionPerformed private void miGotoLinzActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miGotoLinzActionPerformed Camera camera = wwPanel.getCamera(); Vector3D vector = camera.getViewingDirection(); wwPanel.setCamera(new AnimatedCamera(48.2323, 14.3350, 20000.0, vector)); }//GEN-LAST:event_miGotoLinzActionPerformed private void miGotoWuppertalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miGotoWuppertalActionPerformed Camera camera = wwPanel.getCamera(); Vector3D vector = camera.getViewingDirection(); wwPanel.setCamera(new AnimatedCamera(51.249, 7.0832, 14000.0, vector)); }//GEN-LAST:event_miGotoWuppertalActionPerformed private void miFullSphereActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miFullSphereActionPerformed wwPanel.setCamera(new AnimatedCamera(37.0, 27.0, 19000000.0)); }//GEN-LAST:event_miFullSphereActionPerformed private void miGotoPraqueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miGotoPraqueActionPerformed Camera camera = wwPanel.getCamera(); Vector3D vector = camera.getViewingDirection(); wwPanel.setCamera(new AnimatedCamera(50.08781, 14.42046, 20000.0, vector)); }//GEN-LAST:event_miGotoPraqueActionPerformed private void miAddWMSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miAddWMSActionPerformed String server = JOptionPane.showInputDialog(this, "WMS URL", "http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/germany/germany.map&&VERSION=1.1.1&REQUEST=GetCapabilities&SERVICE=WMS"); try { if (server == null) { log.debug("Cancled JOptionPane."); return; } if (server.isEmpty()) { String msg = "Server URL is empty"; log.error(msg); throw new IllegalArgumentException(msg); } final URI serverURI = new URI(server.trim()); wwPanel.addAllWMSLayer(serverURI); } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(this, ex.toString(), "Error", JOptionPane.ERROR_MESSAGE); } }//GEN-LAST:event_miAddWMSActionPerformed private void bGoWMSHeightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bGoWMSHeightActionPerformed String urlString; if (rbCbServerUrl.isSelected()) { urlString = cbServerURL.getSelectedItem().toString(); } else { urlString = txtServerURL.getText(); } bGoWMSHeight.setEnabled(false); pbWMS.setIndeterminate(true); pbWMS.setVisible(true); SwingWorker worker = new LayerInfoRetreiver(urlString, false); worker.addPropertyChangeListener(this); worker.execute(); }//GEN-LAST:event_bGoWMSHeightActionPerformed private void bAddWMSHeightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bAddWMSHeightActionPerformed dWMSHeight.setVisible(false); String urlString; if (rbCbServerUrl.isSelected()) { urlString = cbServerURL.getSelectedItem().toString(); } else { urlString = txtServerURL.getText(); } URI uri = URI.create(urlString); double wmsHeight; double wmsOpacity; try { wmsHeight = Double.parseDouble(txtHeight.getText()); } catch (NumberFormatException nfe) { log.warn("The content of the \"height\" component must be a double value."); wmsHeight = 0.0; txtHeight.setText("0.0"); } try { wmsOpacity = 1.0 - (Double.parseDouble(txtOpacity.getText()) / 100.0); } catch (NumberFormatException nfe) { log.warn("The content of the \"opacity\" " + "component must be a double value between." + "0.0 and 100.0 {}", nfe); wmsOpacity = 0.0; txtOpacity.setText("0.0"); } if (cLayerList.getSelectedItem() instanceof LayerInfo) { LayerInfo li = (LayerInfo) cLayerList.getSelectedItem(); wwPanel.addWMSHeightLayer(uri, li.getName(), wmsHeight, wmsOpacity); } }//GEN-LAST:event_bAddWMSHeightActionPerformed private void bCancelWMSHeightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bCancelWMSHeightActionPerformed resetWMSHeightDialog(); }//GEN-LAST:event_bCancelWMSHeightActionPerformed private void miAddWMSHeightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miAddWMSHeightActionPerformed resetWMSHeightDialog(); dWMSHeight.setVisible(true); dWMSHeight.setModal(true); }//GEN-LAST:event_miAddWMSHeightActionPerformed private void rbCbServerUrlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbCbServerUrlActionPerformed if (rbCbServerUrl.isSelected()) { cbServerURL.setEnabled(true); txtServerURL.setEnabled(false); } else { cbServerURL.setEnabled(false); txtServerURL.setEnabled(true); } }//GEN-LAST:event_rbCbServerUrlActionPerformed private void rbTxtServerUrlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbTxtServerUrlActionPerformed if (rbTxtServerUrl.isSelected()) { txtServerURL.setEnabled(true); cbServerURL.setEnabled(false); } else { txtServerURL.setEnabled(false); cbServerURL.setEnabled(true); } }//GEN-LAST:event_rbTxtServerUrlActionPerformed private void miSideBySideActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miSideBySideActionPerformed wwPanel.startStereo(this); }//GEN-LAST:event_miSideBySideActionPerformed private void miGotoKaiserslauternActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miGotoKaiserslauternActionPerformed Camera camera = wwPanel.getCamera(); Vector3D vector = camera.getViewingDirection(); wwPanel.setCamera(new AnimatedCamera(49.4447186, 7.7690169, 20000.0, vector)); }//GEN-LAST:event_miGotoKaiserslauternActionPerformed private void miOpenDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miOpenDataActionPerformed try { String cmd = evt.getActionCommand(); final JFileChooser fc = new JFileChooser(); FileFilter fileFilter; // Set file filter.. if (cmd.equalsIgnoreCase(miOpenKMLFile.getActionCommand())) { fileFilter = new FileNameExtensionFilter("KML/KMZ File", "kml", "kmz"); } else if (cmd.equalsIgnoreCase(miAddGeoTiff.getActionCommand())) { fileFilter = new FileNameExtensionFilter("GeoTiff File ( *.tif, *.tiff)", "tif", "tiff"); } else if (cmd.equalsIgnoreCase(miAddShape.getActionCommand())) { fileFilter = new FileNameExtensionFilter("ESRI Shapefile (*.shp)", "shp", "SHP"); } else if (cmd.equalsIgnoreCase(miAddShapeZip.getActionCommand())) { fileFilter = new FileNameExtensionFilter("ESRI Shapefile ZIP (*.zip)", "zip", "ZIP"); } else { log.warn("No valid action command."); fileFilter = null; } fc.setFileFilter(fileFilter); // Set latest working directory... XMLConfiguration xmlConfig = Configuration.getXMLConfiguration(); String path = xmlConfig.getString("sudplan3D.working.dir"); File dir; if (path != null) { dir = new File(path); if (dir.exists()) { fc.setCurrentDirectory(dir); } } // Show dialog... int ret = fc.showOpenDialog(this); // Save currently selected working directory... dir = fc.getCurrentDirectory(); path = dir.getAbsolutePath(); xmlConfig.setProperty("sudplan3D.working.dir", path); if (ret != JFileChooser.APPROVE_OPTION) { return; } if (cmd.equalsIgnoreCase(miOpenKMLFile.getActionCommand())) { wwPanel.addKMLLayer(fc.getSelectedFile()); } else if (cmd.equalsIgnoreCase(miAddGeoTiff.getActionCommand())) { wwPanel.addGeoTiffLayer(fc.getSelectedFile()); } else if (cmd.equalsIgnoreCase(miAddShape.getActionCommand()) || cmd.equalsIgnoreCase(miAddShapeZip.getActionCommand())) { IVisAlgorithm algo = VisAlgorithmFactory.newInstance(VisPointCloud.class.getName()); if (algo != null) { wwPanel.addLayer(fc.getSelectedFile(), algo, null); } else { log.error("VisAlgorithm {} not supported.", VisPointCloud.class.getName()); JOptionPane.showMessageDialog(this, "Algorithm not supported.", "Error", JOptionPane.ERROR_MESSAGE); } } else { log.warn("No valid action command."); } } catch (Exception ex) { log.error(ex.toString()); JOptionPane.showMessageDialog(this, ex.toString(), "Error", JOptionPane.ERROR_MESSAGE); } }//GEN-LAST:event_miOpenDataActionPerformed private void miSaveViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miSaveViewActionPerformed String defaultName = "View " + viewID; String name = JOptionPane.showInputDialog(this, "Enter a name for the view", defaultName); if (name == null) { log.debug("Cancled JOptionPane."); return; } if (name.isEmpty()) { String msg = "Server URL is empty"; log.error(msg); name = defaultName; } WorldWindowGLCanvas worldWindow = wwPanel.getWwd(); View view = worldWindow.getView(); String xml = view.getRestorableState(); log.info(xml); final Position eyePosition = view.getEyePosition(); final Position centerPosition = view.getGlobe().computePositionFromPoint(view.getCenterPoint()); log.info("Saving view: eye({}), center({})", eyePosition.toString(), centerPosition.toString()); JMenuItem menuItem = new JMenuItem(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { WorldWindowGLCanvas canvas = wwPanel.getWwd(); View view = canvas.getView(); view.setOrientation(eyePosition, centerPosition); canvas.redraw(); } }); menuItem.setText(name); mCustomViewPoints.add(menuItem); viewID++; }//GEN-LAST:event_miSaveViewActionPerformed @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(EventHolder.LAYERINFO_RETREIVAL_COMPLETE)) { pbWMS.setIndeterminate(false); pbWMS.setVisible(false); cLayerList.removeAllItems(); if (evt.getNewValue() instanceof List<?>) { for (LayerInfo layerInfo : (List<LayerInfo>) evt.getNewValue()) { cLayerList.addItem(layerInfo); } } else if (evt.getNewValue() instanceof LayerInfo) { cLayerList.addItem((LayerInfo) evt.getNewValue()); } else { log.error("Wrong event value (not instanceof LayerInfo or List<LayerInfo>)"); } cLayerList.setEnabled(true); bAddWMSHeight.setEnabled(true); bGoWMSHeight.setEnabled(true); } if (evt.getPropertyName().equals(EventHolder.LAYERINFO_RETREIVAL_FAILED)) { resetWMSHeightDialog(); JOptionPane.showMessageDialog(dWMSHeight, "Could not retreive WMS data from server.", "WMS-Server Error", JOptionPane.WARNING_MESSAGE); } } /** * Reset the {@link #dWMSHeight} dialog. */ private void resetWMSHeightDialog() { dWMSHeight.setVisible(false); txtServerURL.setText("http://serv-2118.kl.dfki.de:8888/geoserver/wms?service=WMS&version=1.1.0"); txtServerURL.setEnabled(true); txtHeight.setText("1500.0"); bGoWMSHeight.setEnabled(true); bAddWMSHeight.setEnabled(false); cLayerList.setEnabled(false); txtServerURL.setEnabled(false); cbServerURL.setEnabled(true); pbWMS.setVisible(false); pbWMS.setIndeterminate(false); rbCbServerUrl.setSelected(true); } /** * Init logging to logs/sudplan3D.log. */ private static void initLogging() { try { String pattern = "%5p %d{ISO8601} %c{1} - %m%n"; PatternLayout layout = new PatternLayout(pattern); XMLConfiguration xmlConfig = Configuration.getXMLConfiguration(); String path = xmlConfig.getString("sudplan3D.user.dir"); String logFile = path + "/logs/sudplan3D.log"; RollingFileAppender appender = new RollingFileAppender(layout, logFile, false); appender.setMaxBackupIndex(2); appender.setMaxFileSize("1MB"); rootLog.addAppender(appender); rootLog.setLevel(Level.ALL); } catch (Exception ex) { log.error(ex.toString()); } } /** * @param args the command line arguments */ public static void main(String args[]) { initLogging(); /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* * Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { MainFrame mf = new MainFrame(); mf.setIconImage(Configuration.SUDPLAN_3D_IMAGE); mf.setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton bAddWMSHeight; private javax.swing.JButton bCancelWMSHeight; private javax.swing.JButton bGoWMSHeight; private javax.swing.ButtonGroup bgWMS; private javax.swing.JButton btnCancelGoToDialoag; private javax.swing.JButton btnGo; private javax.swing.JComboBox cLayerList; private javax.swing.JComboBox cbServerURL; private javax.swing.JDialog dGoTo; private javax.swing.JDialog dWMSHeight; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel4; private javax.swing.JPopupMenu.Separator jSeparator2; private javax.swing.JPopupMenu.Separator jSeparator3; private javax.swing.JPopupMenu.Separator jSeparator5; private javax.swing.JSplitPane jSplitPane1; private javax.swing.JLabel lHeight; private javax.swing.JLabel lLatitude; private javax.swing.JLabel lLongitude; private javax.swing.JLabel lMaxEle; private javax.swing.JLabel lOpacity; private javax.swing.JLabel lServerURL; private javax.swing.JMenu mCustomViewPoints; private javax.swing.JMenu mEdit; private javax.swing.JMenu mFile; private javax.swing.JMenu mHelp; private javax.swing.JMenu mNavi; private javax.swing.JMenu mTools; private javax.swing.JMenu mView; private javax.swing.JMenu mWMS; private javax.swing.JMenuBar mbMain; private javax.swing.JMenuItem miAbout; private javax.swing.JMenuItem miAddGeoTiff; private javax.swing.JMenuItem miAddShape; private javax.swing.JMenuItem miAddShapeZip; private javax.swing.JMenuItem miAddWMS; private javax.swing.JMenuItem miAddWMSHeight; private javax.swing.JMenuItem miExit; private javax.swing.JMenuItem miFullSphere; private javax.swing.JMenuItem miGoToStockhom; private javax.swing.JMenuItem miGoto; private javax.swing.JMenuItem miGotoKaiserslautern; private javax.swing.JMenuItem miGotoLinz; private javax.swing.JMenuItem miGotoPraque; private javax.swing.JMenuItem miGotoWuppertal; private javax.swing.JMenuItem miOpenKMLFile; private javax.swing.JMenuItem miRemoveAllLayer; private javax.swing.JMenuItem miSaveView; private javax.swing.JMenuItem miSideBySide; private javax.swing.JMenuItem miWizard; private javax.swing.JPanel pGoTo; private javax.swing.JPanel pLeftPanel; private javax.swing.JPanel pMain; private javax.swing.JPanel pVisualization; private javax.swing.JProgressBar pbWMS; private javax.swing.JRadioButton rbCbServerUrl; private javax.swing.JRadioButton rbTxtServerUrl; private javax.swing.JTextField txtHeight; private javax.swing.JTextField txtLatitude; private javax.swing.JTextField txtLongitude; private javax.swing.JTextField txtOpacity; private javax.swing.JTextField txtServerURL; // End of variables declaration//GEN-END:variables }