package uk.ac.leeds.ccg.cluster; /** Larsen test parameters class */ import java.io.*; import java.awt.*; import java.awt.event.*; public class LarsenTimeParameters extends TimeParameters { // Version id private static final String version = "$id$"; // Members /**@err no parameters here either */ // Constructors public LarsenTimeParameters(){ setDefaultTimeParameters(); } public LarsenTimeParameters(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 Larsen parameters from "+file); st.nextToken(); if (st.sval.equalsIgnoreCase("true")) {setAnimate(true);} else {setAnimate(false);} st.nextToken(); setNumBin((int)st.nval); st.nextToken(); setStartTime((int)st.nval); st.nextToken(); setEndTime((int)st.nval); st.nextToken(); setSignificanceThreshold(st.nval); } public LarsenTimeParameters(boolean animate, int numBin, int minTime, int maxTime, double thresh){ setAnimate(animate); setNumBin(numBin); setStartTime(minTime); setEndTime(maxTime); setSignificanceThreshold(thresh); } // Methods public String toString(){ return "[animate "+getAnimate()+"]\n"+ "[Number of Bins "+getNumBin()+"]\n"+ "[Earliest time start "+getStartTime()+"]\n"+ "[Latest time end "+getEndTime()+"]\n"; } // public Parameters getParameters() {return this;} public void setTimeParameters(boolean animate, int numBin, int minTime, int maxTime, double thresh){ setAnimate(animate); setNumBin(numBin); setStartTime(minTime); setEndTime(maxTime); setSignificanceThreshold(thresh); } public void setDefaultTimeParameters(){ super.setDefaultTimeParameters(); } public void writeTimeParameters(File file) throws IOException,FileNotFoundException{ PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream (file)))); pw.println(getAnimate()); pw.println(getNumBin()); pw.println(getStartTime()); pw.println(getEndTime()); pw.println(getSignificanceThreshold()); System.out.println ("Parameters saved to "+file); pw.flush(); pw.close(); } }