package uk.ac.leeds.ccg.cluster; import java.awt.*; import java.awt.event.*; import java.util.*; //import com.sun.java.util.collections.*; //change for 1.2! import uk.ac.leeds.ccg.geotools.*; // import uk.ac.leeds.ccg.geotools.classification.*; /** A class that implements Scan test * The main class BandN creates the main frame and proivides 3 buttons * modified to use the new results object - 31/01/01 */ public class Scan extends SimpleMethod implements Method, Runnable { // Members // ScanParameters parameters; // ScanParametersViewer parametersViewer; ScanTimeParameters parameters; ScanTimeParametersViewer parametersViewer; Database database; Results results; Viewer viewer; // Geotools viewer GeoRectangle geoRectangle = null; // Geotools geoRectangle Shader shader; // Geotools shader EqualInterval2 equalinterval2; // Methods public static void main(String args[]){ Scan scan = new Scan(); scan.run(); } public Scan(){ // parameters = new ScanParameters(); // parametersViewer = new ScanParametersViewer(parameters); parameters = new ScanTimeParameters(); parametersViewer = new ScanTimeParametersViewer(parameters); } public String toString() {return "Scan";} public Parameters getParameters() {return parameters;} public ParametersViewer getParametersViewer() {return parametersViewer;} public void setShader(Shader s) {shader=s;} public void setViewer(Viewer v) {viewer=v;} public void setData(Database d) {database=d;} public SignificanceTest getSignificanceTest(){return significanceTest;} public void setSearch(GeoRectangle r) {geoRectangle=r;} public Results getResults(){return results;} public void run(){ int scanmax = 0; int scanstat = 0; double prodm = 1; int N,m; double prob, p, q, pm, qNm, binp; double bL, bU, to, from; results = new Results(); int w = parameters.getW(); int numbin = parameters.getNumBin(); int scanF[] = new int[numbin]; int scanB[] = new int[numbin]; double bin[] = new double[numbin]; double mintime = parameters.getStartTime(); double maxtime = parameters.getEndTime(); double thresh = parameters.getSignificanceThreshold(); boolean flag = parameters.getFilter(); int filt_step = parameters.getFilt_step(); int week[] = new int[filt_step]; if (flag == true) w = 1; double stat = (double) 0.0; System.out.println(""+this+" "+significanceTest); GeoData gcases = database.getCaseVals(); Vector points = database.getPoints(); equalinterval2 = new EqualInterval2(gcases, numbin, mintime, maxtime); // System.out.println("gcases.getSize "+gcases.getSize()); for (int i=0; i= bU || to < bL) continue; if (from < mintime) from=mintime; if (to > maxtime) to = maxtime; for (int j=equalinterval2.classify(from); j<=equalinterval2.classify(to)+w-1; j++){ if (j>=numbin) continue; scanF[j]++; } for (int j=equalinterval2.classify(from)-w+1; j<=equalinterval2.classify(to); j++){ if (j<0) continue; scanB[j]++; } } int where = 0, fl; for (int i=0; i scanmax || scanF[i] > scanmax){ scanmax = Math.max(scanF[i], scanB[i]); where = i; } } if (flag == true) { for (int i=0; i maxtime) continue; // bin[ equalinterval2.classify((double) gcases.getValue(i)) ]++ ; // } System.out.println("Scan statistic = " +" "+ scanmax); // messagesTextArea.append("Scanmax, stat " +" "+ scanmax +" "+ scanstat); // Calculate the probability p = (double) w/numbin; if (flag == true) p = 1./filt_step; q = 1. - p; // for (int i=0; i