/* * GridTest.java * * Created on 20 November 2001, 15:57 */ package uk.ac.leeds.ccg.cluster.grids; import uk.ac.leeds.ccg.raster.*; import uk.ac.leeds.ccg.geotools.*; import uk.ac.leeds.ccg.geotools.classification.*; import uk.ac.leeds.ccg.widgets.*; import java.awt.*; import java.io.*; /** * @author andyt * @version */ public class GridTest { /** Version id */ private static final String version = "$id$"; /** Creates new GridTest */ public GridTest() { } /** * @param args the command line arguments */ public static void main(String args[]) { // Set data directory String dataDirectory = new String( "d:/andyt/data/TestData/gridascii/" ); // Set input filename String infile = new String( dataDirectory + "test_160x230.asc" ); // Set output filename String outfile = new String( dataDirectory + "out.asc" ); // Initialise grid Grid2DSquareCellDouble g1 = null; //try { g1 = new Grid2DSquareCellDouble( new File( infile ) ); //} catch ( java.io.FileNotFoundException e ) { // System.out.println( e ); // System.exit( 0 ); //} // Initialise Grid Factories Grid2DSquareCellDoubleFactory gridFactory = new Grid2DSquareCellDoubleFactory(); Grid2DSquareCellDoubleFileFactory gridFileFactory = new Grid2DSquareCellDoubleFileFactory(); // Test geometricDensity Method //AbstractGrid2DSquareCellDouble g2 = g1.geometricDensity(); //AbstractGrid2DSquareCellDouble g2 = g1.geometricDensity(1,32); //AbstractGrid2DSquareCellDouble g2 = g1.geometricDensity(2,8); //AbstractGrid2DSquareCellDouble g2 = g1.geometricDensity(0,8,50,gridFileFactory); //AbstractGrid2DSquareCellDouble g2 = g1.geometricDensity(0,2,gridFileFactory); AbstractGrid2DSquareCellDouble g2 = g1.geometricDensity( 0 , 2 ); // Write out result //try { g2.toAsciiFile( new File( outfile ) ); //} catch ( java.io.FileNotFoundException e ) { // System.out.println( e ); // System.exit( 0 ); //} /* // Display GeometricDensity output as a raster on screen // Get output Raster r2 = new Raster(outfile1); r2.setMissingValueCode(-9999.0d); System.out.println("(min,max)=("+r2.getMin()+","+r2.getMax()+")"); // Set Frame Frame frame2 = new Frame(); frame2.setLayout(new BorderLayout()); // Set RasterLayer RasterLayer rl1 = new RasterLayer(r2); // Set a Shader and Key //HSVShader hsvs1 = new HSVShader(Color.black,Color.red,true); //hsvs1.setMissingValueColor(Color.white); //hsvs1.setMissingValueCode((double)r1.getMissingValueCode()); //hsvs1.setRange(r1.getMin()+r1.getTol()+(r1.getMax()-r1.getMin())/100.0d,r1.getMax()); //t1.setShader(hsvs1); //Key k1=hsvs1.getKey(); //ClassificationShader cs1=new ClassificationShader(r2,6,ClassificationShader.QUANTILE); ClassificationShader cs1=new ClassificationShader(r2,4,ClassificationShader.EQUAL_INTERVAL); cs1.setRange(r2.getMin(),r2.getMax()); cs1.setMissingValueColor(Color.white); Key k1=cs1.getKey(); // Add key to frame frame2.add(k1,"East"); // Set theme Theme t1=new Theme(rl1,cs1); // Set viewer Viewer v1=new Viewer(); v1.setBackground(Color.white); v1.addTheme(t1); // Add viewer to theme frame2.add(v1,"Center"); // Set Toolbar ToolBar tb1=new ToolBar(v1); // Add Toolbar to frame frame2.add(tb1,"South"); // Display frame frame2.pack(); frame2.setVisible(true); // Annonymous inner class set up for closing frame. frame2.addWindowListener(new java.awt.event.WindowAdapter(){ public void windowClosing(java.awt.event.WindowEvent e){ System.exit(0); } }); */ } }