package uk.ac.leeds.ccg.cluster; /**SpaceTimeParameters class * Description: SpaceTimeParameter methods used by all spacetime series methods */ import java.io.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class SpaceTimeParameters extends Parameters { // Version id private static final String version = "$id$"; // Members /**@param animate control for visualising search * @param thresh significance threshold for the test * @param numRuns number of runs */ private boolean animate; private double thresh; private int numRuns; // Constructors public SpaceTimeParameters(){ setDefaultSpaceTimeParameters(); } public SpaceTimeParameters(File file) throws IOException,FileNotFoundException{ // Read into a stream tokenised buffered input stream StreamTokenizer st = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( new FileInputStream (file)))); System.out.println ("Setting spacetimeparameters from "+file); st.nextToken(); if (st.sval.equalsIgnoreCase("true")) {setAnimate(true);} else {setAnimate(false);} st.nextToken(); setSignificanceThreshold(st.nval); st.nextToken(); setNumRuns((int)st.nval); } public SpaceTimeParameters(boolean animate, double thresh, int numRuns){ setAnimate(animate); setSignificanceThreshold(thresh); setNumRuns(numRuns); } // Methods public String tostring(){ return "[animate "+getAnimate()+"]\n"+ "[significance threshold "+getSignificanceThreshold()+"]\n"+ "[number of runs "+getNumRuns()+"]\n"; } public void setSpaceTimeParameters(boolean animate, double thresh, int numRuns){ setAnimate(animate); setSignificanceThreshold(thresh); setNumRuns(numRuns); } public void setDefaultSpaceTimeParameters(){ setSpaceTimeParameters(false,0.01d,249); } public boolean getAnimate() {return animate;} public void setAnimate(boolean b) {animate=b;} public double getSignificanceThreshold() {return thresh;} public void setSignificanceThreshold(double d) {thresh=d;} public int getNumRuns() {return numRuns;} public void setNumRuns(int d) {numRuns=d;} public void writeSpaceTimeParameters(File file) throws IOException,FileNotFoundException{ PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream (file)))); pw.println(getAnimate()); pw.println(getSignificanceThreshold()); pw.println(getNumRuns()); System.out.println ("SpaceTimeParameters saved to "+file); pw.flush(); pw.close(); } Vector listeners = new Vector(); }