Package jSimMacs.display.gromacs

Source Code of jSimMacs.display.gromacs.TrjcatPanel

/**
*
*/
package jSimMacs.display.gromacs;

import jSimMacs.data.GromacsDefaultValues;
import jSimMacs.data.Project;
import jSimMacs.data.RemoteProject;
import jSimMacs.display.JFileTextField;
import jSimMacs.display.dialog.ssh.SSHFileChooser;
import jSimMacs.logic.JSimLogic;
import jSimMacs.logic.ProjectLocation;

import java.awt.GridLayout;
import java.util.Set;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
* @author sr
*
*/
public class TrjcatPanel extends JPanel implements GromacsPanel {

  private JPanel filesPanel;

  private JPanel inputPanel;

  private JPanel outputPanel;
 
  private JPanel optionalInputPanel;

  private JPanel optionPanel;
 
  private JLabel inputLabel = new JLabel("Trajectory:");
 
  private JLabel inputIndexLabel = new JLabel("Index:");
 
  private JLabel inputDemuxLabel = new JLabel("Demux:");
 
  private JLabel outputLabel = new JLabel("Trajectory:");
 
  private JLabel firstTimeLabel = new JLabel("First time:");
 
  private JLabel lastTimeLabel = new JLabel("Last time:");
 
  private JCheckBox velocity = new JCheckBox("Read and write velocities");
 
  private JCheckBox settime = new JCheckBox("Change starting time");
 
  private JCheckBox sort = new JCheckBox("Sort trajectory files");
 
  private JCheckBox keeplast = new JCheckBox("Keep overlapping frames");
 
  private JCheckBox cat = new JCheckBox("Double time frames");
 
  private JFileTextField inputField;
 
  private JFileTextField inputIndexField;
 
  private JFileTextField inputDemuxField;
 
  private JFileTextField outputField;
 
  private JTextField firstTimeField;
 
  private JTextField lastTimeField;
 
  private Project project;
 
  private Object fileChooser;
 
  private TextCommandPanel textCommandPanel;
 
  public TrjcatPanel(Project project){
    super();
    this.project = project;
    createFileChooser();
   
    inputField = new JFileTextField(10, fileChooser);
    inputField.setMultiSelectionEnabled();
    inputDemuxField = new JFileTextField(10, fileChooser);
    inputIndexField = new JFileTextField(10, fileChooser);
    outputField = new JFileTextField(10, fileChooser);
    outputField.setMultiSelectionEnabled();
    firstTimeField = new JTextField(10);
    lastTimeField = new JTextField(10);
   
    initPanel();
    initData();
  }
 
  private void initData() {
    firstTimeField.setText("-1");
    lastTimeField.setText("-1");
    velocity.setSelected(true);
    sort.setSelected(true);
  }

  private void initPanel() {
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
   
    filesPanel = new JPanel();
    filesPanel.setLayout(new BoxLayout(filesPanel, BoxLayout.PAGE_AXIS));
    inputPanel = new JPanel(new GridLayout(0, 4, 0, 0));
    outputPanel = new JPanel(new GridLayout(0, 4, 5, 5));
    optionPanel = new JPanel(new GridLayout(0, 4, 5, 5));
    optionalInputPanel = new JPanel(new GridLayout(0, 4, 5, 5));
    textCommandPanel = new TextCommandPanel(15);
   
    inputPanel.add(inputLabel);
    inputPanel.add(inputField);
    optionalInputPanel.add(inputIndexLabel);
    optionalInputPanel.add(inputIndexField);
    optionalInputPanel.add(inputDemuxLabel);
    optionalInputPanel.add(inputDemuxField);
   
    outputPanel.add(outputLabel);
    outputPanel.add(outputField);
   
    filesPanel.setBorder(BorderFactory.createTitledBorder("Files"));
    inputPanel.setBorder(BorderFactory.createTitledBorder("Input"));
    outputPanel.setBorder(BorderFactory.createTitledBorder("Output"));
    optionPanel.setBorder(BorderFactory.createTitledBorder("Option"));
    optionalInputPanel.setBorder(BorderFactory
        .createTitledBorder("Optional Input"));
    textCommandPanel.setBorder(BorderFactory.createTitledBorder("Command"));
   
    filesPanel.add(inputPanel);
    filesPanel.add(optionalInputPanel);
    filesPanel.add(outputPanel);
   
    optionPanel.add(firstTimeLabel);
    optionPanel.add(firstTimeField);
    optionPanel.add(lastTimeLabel);
    optionPanel.add(lastTimeField);
    optionPanel.add(velocity);
    optionPanel.add(settime);
    optionPanel.add(sort);
    optionPanel.add(keeplast);
    optionPanel.add(cat);
   
    initToolTipText();
   
    this.add(filesPanel);
    this.add(optionPanel);
    this.add(textCommandPanel);
    this.add(Box.createVerticalStrut(150));
   
  }

  private void initToolTipText() {
    inputField.setToolTipText("Input File Generic trajectory: xtc trr trj gro g96 pdb");
    inputIndexField.setToolTipText("Input Opt. Index file ");
    inputDemuxField.setToolTipText("Input Opt. xvgr/xmgr file. The N trajectories that are read, are written in another order as specified in the xvg file");
    outputField.setToolTipText("Output File Generic trajectory: xtc trr trj gro g96 pdb");
    firstTimeField.setToolTipText("First time to use (ps)");
    lastTimeField.setToolTipText("Last time to use (ps)");
    velocity.setToolTipText("Read and write velocities if possible");
    settime.setToolTipText("Change starting time interactively");
    sort.setToolTipText("Sort trajectory files (not frames)");
    keeplast.setToolTipText("keep overlapping frames at end of trajectory");
    keeplast.setToolTipText("do not discard double time frames");
  }

  private void createFileChooser() {
    if(project.getLocation() == ProjectLocation.LOCALE){
      String inputDir = JSimLogic.getInstance().getWorkspaceDir()
        + project.getName();
      fileChooser = new JFileChooser(inputDir);
    }
    else
      fileChooser = new SSHFileChooser(null, (RemoteProject)project)
  }

  /* (non-Javadoc)
   * @see jSimMacs.display.gromacs.GromacsPanel#directoryEntries()
   */
  public Set<String> directoryEntries() {
    // TODO Auto-generated method stub
    return null;
  }

  /* (non-Javadoc)
   * @see jSimMacs.display.gromacs.GromacsPanel#isInteractive()
   */
  public boolean isInteractive() {
    // TODO Auto-generated method stub
    return false;
  }

  /* (non-Javadoc)
   * @see jSimMacs.display.gromacs.GromacsPanel#updateData()
   */
  public void updateData() {
    // TODO Auto-generated method stub

  }

  /* (non-Javadoc)
   * @see jSimMacs.display.gromacs.GromacsPanel#updateProjectData()
   */
  public void updateProjectData() {
    // TODO Auto-generated method stub

  }

  public boolean getVelocity() {
    return velocity.isSelected();
  }

  public boolean getSettime() {
    return settime.isSelected();
  }

  public boolean getSort() {
    return sort.isSelected();
  }

  public boolean getKeeplast() {
    return keeplast.isSelected();
  }

  public boolean getCat() {
    return cat.isSelected();
  }

  public String getInputField() {
    return inputField.getText();
  }
 
  public String[] getMultipleInputField(){
    return inputField.getMultipleFiles();
  }

  public String getInputIndexField() {
    return inputIndexField.getText();
  }

  public String getInputDemuxField() {
    return inputDemuxField.getText();
  }

  public String getOutputField() {
    return outputField.getText();
  }
 
  public String[] getMultiplOutputField(){
    return outputField.getMultipleFiles();
  }

  public String getFirstTimeField() {
    if (firstTimeField.getText().length() != 0
        && Double.parseDouble(firstTimeField.getText()) != GromacsDefaultValues.DEFAULTTIME)
      return firstTimeField.getText();
    return null;
  }

  public String getLastTimeField() {
    if (lastTimeField.getText().length() != 0
        && Double.parseDouble(lastTimeField.getText()) != GromacsDefaultValues.DEFAULTTIME)
      return lastTimeField.getText();
    return null;
  }

  public String getTextCommand() {
    return textCommandPanel.getTextCommandField();
  }

}
TOP

Related Classes of jSimMacs.display.gromacs.TrjcatPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.