package uk.ac.leeds.ccg.cluster; /** Grimson test parameters class */ import java.io.*; import java.awt.*; import java.awt.event.*; public class GrimsonTimeParameters extends TimeParameters { // Version id private static final String version = "$id$"; // Members /**@param highrisk high risk threshold */ private double highrisk; // high risk threshold // Constructors public GrimsonTimeParameters(){ setDefaultTimeParameters(); } public GrimsonTimeParameters(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 Grimson parameters from "+file); st.nextToken(); if (st.sval.equalsIgnoreCase("true")) {setAnimate(true);} else {setAnimate(false);} st.nextToken(); setHR((double)st.nval); st.nextToken(); setNumBin((int)st.nval); st.nextToken(); setStartTime((int)st.nval); st.nextToken(); setEndTime((int)st.nval); st.nextToken(); setSignificanceThreshold(st.nval); } public GrimsonTimeParameters(boolean animate, double highrisk, int numBin, int minTime, int maxTime, double thresh){ setAnimate(animate); setHR(highrisk); setNumBin(numBin); setStartTime(minTime); setEndTime(maxTime); setSignificanceThreshold(thresh); } // Methods public String toString(){ return "[animate "+getAnimate()+"]\n"+ "[High risk threshold "+getHR()+"]\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, double highrisk, int numBin, int minTime, int maxTime, double thresh){ setAnimate(animate); setHR(highrisk); setNumBin(numBin); setStartTime(minTime); setEndTime(maxTime); setSignificanceThreshold(thresh); } public void setDefaultTimeParameters(){ setHR(2.); super.setDefaultTimeParameters(); } public double getHR() {return highrisk;} public void setHR(double i) {highrisk=i;} public void writeTimeParameters(File file) throws IOException,FileNotFoundException{ PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream (file)))); pw.println(getAnimate()); pw.println(getHR()); pw.println(getNumBin()); pw.println(getStartTime()); pw.println(getEndTime()); pw.println(getSignificanceThreshold()); System.out.println ("Parameters saved to "+file); pw.flush(); pw.close(); } }