package uk.ac.leeds.ccg.cluster; import java.io.*; import java.awt.*; import java.awt.event.*; /** Class: MantelTimeParametersViewer * Function: To display and modify MantelTimeParameters */ public class MantelTimeParametersViewer extends SpaceTimeParametersViewer implements ActionListener { // Members Container mantelTimeParametersContainer; // These Doubles and TextFields allow for the setting of // MantelTimeParameters from the MantelTimeParametersViewer // Constructcts public MantelTimeParametersViewer(SpaceTimeParameters p){ super(p); } // Methods public static void main(String args[]) throws IOException,FileNotFoundException{ MantelTimeParametersViewer mantelTimeParametersViewer = new MantelTimeParametersViewer (new MantelTimeParameters()); mantelTimeParametersViewer.run(); } public void run(){ initComponents(); setDisplay(); } public void initComponents(){ // SpaceTimeParameters come first as SpaceTimeParametersViewer instantiates the // gridBagLayout gridBagLayout and gridBagConstraints gridBagConstraints super.initComponents(); mantelTimeParametersContainer = new Container(); mantelTimeParametersContainer.setLayout(gridBagLayout); } public void setDisplay(){ super.setDisplay(); gridBagConstraints.gridwidth=GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(mantelTimeParametersContainer,gridBagConstraints); frame.add(mantelTimeParametersContainer,frame.getComponentCount()); frame.setTitle("SpaceTimeParameters - Mantel"); 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 SpaceTimeParameters File"); fileDialog = new FileDialog(new Frame()); fileFil = new FileFil(fileDialog,".pars"); fileDialog.setTitle("Load Mantel SpaceTimeParameters File"); fileDialog.setFilenameFilter(fileFil); fileDialog.setVisible(true); if (fileDialog.getFile()==null) {return;} file = new File(fileDialog.getDirectory(),fileDialog.getFile()); try{ parameters = new MantelTimeParameters(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); } } }