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 Besag and Newell Cluster Hunt * The main class BandN creates the main frame and proivides 3 buttons * modified to use the new results object - 31/01/01 */ public class ECells extends SimpleMethod implements Method, Runnable { // Members ECellsTimeParameters parameters; ECellsTimeParametersViewer 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[]){ ECells ecells = new ECells(); ecells.run(); } public ECells(){ parameters = new ECellsTimeParameters(); parametersViewer = new ECellsTimeParametersViewer(parameters); } public String toString() {return "ECells";} 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 ecells = 0; double prodk1, prodE1 = 1., prodkE; double prodt = 1., prodk, prodtk; int t, N = 0; double prob = 0., p, pN, pm, bin1, bin2; double bL, bU, to, from; results = new Results(); int numbin = parameters.getNumBin(); double bin[] = new double[numbin]; double mintime = parameters.getStartTime(); double maxtime = parameters.getEndTime(); double thresh = parameters.getSignificanceThreshold(); // MyPoint p; double stat = (double) 0.0; // System.out.println("ECells "+significanceTest); // if (significanceTest == null) { // System.out.println("ECells started with a null sig test using Poisson"); // significanceTest = new PoissonTest(); // significanceTest.setParameters(parameters); // } System.out.println(""+this+" "+significanceTest); GeoData gcases = database.getCaseVals(); Vector points = database.getPoints(); equalinterval2 = new EqualInterval2(gcases, numbin, mintime, maxtime); for (int j=0; j= bU || to < bL) continue; if (from < mintime) from=mintime; if (to > maxtime) to = maxtime; if (to == from){ bin[j]++; continue; } double length = to - from; if (from <= bL){ if (to < bU) bin[j] += (to - bL)/length; else bin[j] += (bU - bL)/length; } else{ if (to < bU) bin[j] += 1.; else bin[j] += (bU - from)/length; } } // System.out.println(bin[j]); } // for (int i=1; i<=gcases.getSize(); i++){ // if (gcases.getValue(i) < mintime || gcases.getValue(i) > maxtime) continue; // bin[ equalinterval2.classify((double) gcases.getValue(i)) ]++; // } for (int i=0; i