package uk.ac.leeds.ccg.cluster; /** Scan test parameters class */ import java.io.*; import java.awt.*; import java.awt.event.*; public class ScanTimeParameters extends TimeParameters { // Version id private static final String version = "$id$"; // Members /**@param w window width * @param filt_step step size for filtering */ private int w; // Window width private boolean filter; // to filter or not? private int filt_step; // Step size for filtering // Constructors public ScanTimeParameters(){ setDefaultTimeParameters(); } public ScanTimeParameters(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 Scan parameters from "+file); st.nextToken(); if (st.sval.equalsIgnoreCase("true")) {setAnimate(true);} else {setAnimate(false);} st.nextToken(); setW((int)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); st.nextToken(); if (st.sval.equalsIgnoreCase("true")) {setFilter(true);} else {setFilter(false);} st.nextToken(); setFilt_step((int)st.nval); } public ScanTimeParameters(boolean animate, int w, int numBin, double minTime, double maxTime, double thresh, boolean filter, int filt_step){ setAnimate(animate); setW(w); setNumBin(numBin); setStartTime(minTime); setEndTime(maxTime); setSignificanceThreshold(thresh); setFilter(filter); setFilt_step(filt_step); } // Methods public String toString(){ return "[animate "+getAnimate()+"]\n"+ "[Width of window "+getW()+"]\n"+ "[Number of bins "+getNumBin()+"]\n"+ "[Earliest time start "+getStartTime()+"]\n"+ "[Latest time end "+getEndTime()+"]\n"+ "[filter "+getFilter()+"]\n"+ "[Size of filter step "+getFilt_step()+"]\n"; } // public TimeParameters getParameters() {return this;} public void setTimeParameters(boolean animate, int w, int numBin, int minTime, int maxTime, double thresh, boolean filter, int filt_step){ setAnimate(animate); setW(w); setNumBin(numBin); setStartTime(minTime); setEndTime(maxTime); setSignificanceThreshold(thresh); setFilter(filter); setFilt_step(filt_step); } public void setDefaultTimeParameters(){ setW(2); setFilter(false); setFilt_step(7); super.setDefaultTimeParameters(); } public int getW() {return w;} public void setW(int i) {w=i;} public boolean getFilter() {return filter;} public void setFilter(boolean b) {filter=b;} public int getFilt_step() {return filt_step;} public void setFilt_step(int i) {filt_step=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(getW()); pw.println(getNumBin()); pw.println(getStartTime()); pw.println(getEndTime()); pw.println(getSignificanceThreshold()); pw.println(getFilter()); pw.println(getFilt_step()); System.out.println ("TimeParameters saved to "+file); pw.flush(); pw.close(); } }