package uk.ac.leeds.ccg.cluster; import java.io.*; import java.awt.*; import java.awt.event.*; /** Class: LarsenTimeParametersViewer * Function: To display and modify LarsenTimeParameters */ public class LarsenTimeParametersViewer extends TimeParametersViewer implements ActionListener { // Members Container larsenTimeParametersContainer; // These Doubles and TextFields allow for the setting of // LarsenTimeParameters from the LarsenTimeParametersViewer // Constructors public LarsenTimeParametersViewer(TimeParameters p){ super(p); } // Methods public static void main(String args[]) throws IOException,FileNotFoundException{ LarsenTimeParametersViewer larsenTimeParametersViewer = new LarsenTimeParametersViewer (new LarsenTimeParameters()); larsenTimeParametersViewer.run(); } public void run(){ initComponents(); setDisplay(); } public void initComponents(){ // TimeParameters come first as TimeParametersViewer instantiates the // gridBagLayout gridBagLayout and gridBagConstraints gridBagConstraints super.initComponents(); larsenTimeParametersContainer = new Container(); larsenTimeParametersContainer.setLayout(gridBagLayout); } public void setDisplay(){ super.setDisplay(); gridBagConstraints.gridwidth=GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(larsenTimeParametersContainer,gridBagConstraints); frame.add(larsenTimeParametersContainer,frame.getComponentCount()); frame.setTitle("TimeParameters - Larsen"); frame.pack(); } public void parseValues(){ super.parseValues(); } public void setText(){ super.setText(); } public void actionPerformed(ActionEvent actionEvent){ String actionCommand = new String(actionEvent.getActionCommand()); if(actionCommand.equals("load parameters")){ System.out.println("Load TimeParameters File"); fileDialog = new FileDialog(new Frame()); fileFil = new FileFil(fileDialog,".pars"); fileDialog.setTitle("Load Larsen TimeParameters File"); fileDialog.setFilenameFilter(fileFil); fileDialog.setVisible(true); if (fileDialog.getFile()==null) {return;} file = new File(fileDialog.getDirectory(),fileDialog.getFile()); try{ parameters = new LarsenTimeParameters(file); setText(); parseValues(); //dbase.load(file); } catch(IOException error){ System.err.println("Error loading file "+error); return; } } else{ // This works because calling super.actionPerformed(actionEvent) from this class // uses the methods in this class first if they exist. super.actionPerformed(actionEvent); } } }