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.*; /** 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 Knn extends SimpleMethod implements Method, Runnable { // Members KnnParameters parameters; KnnParametersViewer parametersViewer; Database database; Results results; Viewer viewer; // Geotools viewer GeoRectangle geoRectangle = null; // Geotools geoRectangle Shader shader; // Geotools shader // Methods public static void main(String args[]){ Knn knn = new Knn(); knn.run(); } public Knn(){ parameters = new KnnParameters(); parametersViewer = new KnnParametersViewer(parameters); } public String toString() {return "Knn";} 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(){ results = new Results(); int k = parameters.getK(); MyPoint p; // MyDouble statis = new MyDouble(); double stat = (double) 0.0; System.out.println("Knn "+significanceTest); if (significanceTest == null) { System.out.println("Knn started with a null sig test using Poisson"); significanceTest = new PoissonTest(); significanceTest.setParameters(parameters); } System.out.println(""+this+" "+significanceTest); if(geoRectangle==null) geoRectangle=database.getBounds(); Vector tcases = database.getCases(); Vector cases= new Vector(); for(int i=0;idist[j]){ top[kk]=dist[j]; index=j; } } // Replace the shortest distance with infinity so that next // we find the next shortest. dist[index]=Double.POSITIVE_INFINITY; } // Create a circle with a radius of the distance to the kth point GeoCircle cc = new GeoCircle(id++,p.x,p.y,(int)top[k-1]); // Create a Poisson test object // MyPoint p2; // int totcase=0; // double totpop=0; // Go through the vector of cases and add up all the cases with in // the circle using the contains method // for(int j=0;j