package uk.ac.leeds.ccg.cluster; /** ECells test parameters class */ import java.io.*; import java.awt.*; import java.awt.event.*; public class ECellsTimeParameters extends TimeParameters { // Version id private static final String version = "$id$"; // Members /**@param err, no parameters bins */ // Constructors public ECellsTimeParameters(){ setDefaultTimeParameters(); } public ECellsTimeParameters(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 ECells 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 ECellsTimeParameters(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 writeParameters(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(); } }