package uk.ac.leeds.ccg.cluster; /** Random Parameters class */ import java.io.*; import java.awt.*; import java.awt.event.*; public class RandomParameters extends Parameters { // Version id private static final String version = "$id$"; // Members /**@param nCircles number of circles * @param radMax maximum circle radius * @param radMin minimum circle radius */ private int nCircles; private double radMin,radMax; // Constructors public RandomParameters(){ setDefaultParameters(); } public RandomParameters(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 Random parameters from "+file); st.nextToken(); if (st.sval.equalsIgnoreCase("true")) {setAnimate(true);} else {setAnimate(false);} st.nextToken(); setNCircles((int)st.nval); st.nextToken(); setRadMin(st.nval); st.nextToken(); setRadMax(st.nval); st.nextToken(); setSignificanceThreshold(st.nval); st.nextToken(); setMinPopSize(st.nval); st.nextToken(); setMinIncidenceCount(st.nval); st.nextToken(); setMonteCarloRejectionCount(st.nval); st.nextToken(); setStatType((int)st.nval); st.nextToken(); setMinPointCount((int)st.nval); st.nextToken(); setBootstrapSampleSize((int)st.nval); st.nextToken(); setMonteCarloSampleSize((int)st.nval); st.nextToken(); setMultipleTestReruns((int)st.nval); } public RandomParameters(boolean animate, int nCircles, double radMin, double radMax, double thresh, double popMin, double canMin, double hH, int meas, int minPnt, int maxSam, int maxMC, int maxRep){ setAnimate(animate); setNCircles(nCircles); setRadMin(radMin); setRadMax(radMax); setSignificanceThreshold(thresh); setMinPopSize(popMin); setMinIncidenceCount(canMin); setMonteCarloRejectionCount(hH); setStatType(meas); setMinPointCount(minPnt); setBootstrapSampleSize(maxSam); setMonteCarloSampleSize(maxMC); setMultipleTestReruns(maxRep); } //Methods public String toString(){ return "[animate "+getAnimate()+"]\n"+ "[Number of circles "+getNCircles()+"]\n"+ "[minimum circle radius "+getRadMin()+"]\n"+ "[maximum circle radius "+getRadMax()+"]\n"+ "[significance threshold "+getSignificanceThreshold()+"]\n"+ "[minimum population size "+getMinPopSize()+"]\n"+ "[minimum incidence count "+getMinIncidenceCount()+"]\n"+ "[rejection count for Monte Carlo test "+getMonteCarloRejectionCount()+"]\n"+ "[type of statistic "+ getStatType()+"]\n"+ "[minimum point count "+getMinPointCount()+"]\n"+ "[sample size for bootstrap "+getBootstrapSampleSize()+"]\n"+ "[integer Monte Carlo sample size "+getMonteCarloSampleSize()+"]\n"+ "[number of multiple testing re-runs "+getMultipleTestReruns()+"]\n"; } public Parameters getParameters() {return this;} public void setParameters(boolean animate, int nCircles, double radMin, double radMax, double thresh, double popMin, double canMin, double hH, int meas, int minPnt, int maxSam, int maxMC, int maxRep){ setAnimate(animate); setNCircles(nCircles); setRadMin(radMin); setRadMax(radMax); setSignificanceThreshold(thresh); setMinPopSize(popMin); setMinIncidenceCount(canMin); setMonteCarloRejectionCount(hH); setStatType(meas); setMinPointCount(minPnt); setBootstrapSampleSize(maxSam); setMonteCarloSampleSize(maxMC); setMultipleTestReruns(maxRep); } public void setDefaultParameters(){ setNCircles(1000); setRadMin(500.0f); setRadMax(5000.0f); super.setDefaultParameters(); } public void setNCircles(int i) {nCircles=i;} public int getNCircles() {return nCircles;} public void setRadMin(double d) {radMin=d;} public double getRadMin() {return radMin;} public void setRadMax(double d) {radMax=d;} public double getRadMax() {return radMax;} public void writeParameters(File file) throws IOException,FileNotFoundException { PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream (file)))); pw.println(getAnimate()); pw.println(getNCircles()); pw.println(getRadMin()); pw.println(getRadMax()); pw.println(getSignificanceThreshold()); pw.println(getMinPopSize()); pw.println(getMinIncidenceCount()); pw.println(getMonteCarloRejectionCount()); pw.println(getStatType()); pw.println(getMinPointCount()); pw.println(getBootstrapSampleSize()); pw.println(getMonteCarloSampleSize()); pw.println(getMultipleTestReruns()); System.out.println ("Parameters saved to "+file); pw.flush(); pw.close(); } }