/* * IdlsavDataSourceFormatEditorPanel.java * */ package org.autoplot.matsupport; import java.util.HashMap; import java.util.Map; import javax.swing.JPanel; import org.autoplot.datasource.URISplit; import java.lang.Short; // because of Short object in this package. import org.autoplot.datasource.DataSourceFormatEditorPanel; /** * * @author jbf */ public class MatDataSourceFormatEditorPanel extends javax.swing.JPanel implements DataSourceFormatEditorPanel { /** Creates new form BinaryDataSourceFormatEditorPanel */ public MatDataSourceFormatEditorPanel() { initComponents(); } String file; /** 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") // //GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); typeComboBox = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); jLabel1.setText("Time Units:"); typeComboBox.setEditable(true); typeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "t1970", "t2000", "cdfTT2000", "seconds since 2010-02-03T00:00" })); jLabel2.setText("1-D and 2-D data can be exported to .mat files."); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE) .add(layout.createSequentialGroup() .add(jLabel1) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(typeComboBox, 0, 292, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(jLabel2) .add(7, 7, 7) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1) .add(typeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addContainerGap(237, Short.MAX_VALUE)) ); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JComboBox typeComboBox; // End of variables declaration//GEN-END:variables public JPanel getPanel() { return this; } private String getParam( Map args, String name, String defl ) { String s= args.get(name); if ( s==null ) { return defl; } else { return s; } } public void setURI(String uri) { URISplit split= URISplit.parse(uri); Map args= URISplit.parseParams(split.params); String s= getParam( args, "tunits", "t1970" ); typeComboBox.setSelectedItem(s); file= split.file; } public String getURI() { String result= file; Map args= new HashMap(); String s; s= (String) typeComboBox.getSelectedItem(); if ( !s.equals("t1970") ) args.put( "tunits", s ); String params= URISplit.formatParams(args); if ( result==null ) result= "file:///"; URISplit ss= URISplit.parse(result); if ( params.length()>0 ) { ss.params= params; } return URISplit.format( ss ); } }