package uk.ac.leeds.ccg.cluster; /** Knox test parameters class */ import java.io.*; import java.awt.*; import java.awt.event.*; public class KnoxTimeParameters extends SpaceTimeParameters { // Version id private static final String version = "$id$"; // Members /**@param delta Critical space distance *@param tau Critical space distance */ private int delta; // Critical space distance private int tau; // Critical time distance // Constructors public KnoxTimeParameters(){ setDefaultSpaceTimeParameters(); } public KnoxTimeParameters(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 Knox parameters from "+file); st.nextToken(); if (st.sval.equalsIgnoreCase("true")) {setAnimate(true);} else {setAnimate(false);} st.nextToken(); setDelta((int)st.nval); st.nextToken(); setTau((int)st.nval); st.nextToken(); setNumRuns((int)st.nval); st.nextToken(); setSignificanceThreshold(st.nval); } public KnoxTimeParameters(boolean animate, int delta, int tau, int numRuns, double thresh){ setAnimate(animate); setDelta(delta); setTau(tau); setNumRuns(numRuns); setSignificanceThreshold(thresh); } // Methods public String toString(){ return "[animate "+getAnimate()+"]\n"+ "[Critical space distance "+getDelta()+"]\n"+ "[Critical time distance "+getTau()+"]\n"+ "[Number of runs "+getNumRuns()+"]\n"; } public void setTimeParameters(boolean animate, int delta, int tau, int numRuns, double thresh){ setAnimate(animate); setDelta(delta); setTau(tau); setNumRuns(numRuns); setSignificanceThreshold(thresh); } public void setDefaultSpaceTimeParameters(){ setDelta(2); setTau(2); super.setDefaultSpaceTimeParameters(); } public int getDelta() {return delta;} public void setDelta(int i) {delta=i;} public int getTau() {return tau;} public void setTau(int i) {tau=i;} public void writeSpaceTimeParameters(File file) throws IOException,FileNotFoundException{ PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream (file)))); pw.println(getAnimate()); pw.println(getDelta()); pw.println(getTau()); pw.println(getNumRuns()); pw.println(getSignificanceThreshold()); System.out.println ("SpaceTimeParameters saved to "+file); pw.flush(); pw.close(); } }