package uk.ac.leeds.ccg.cluster; import java.awt.*; import uk.ac.leeds.ccg.geotools.*; public class SearchTool extends SimpleTool{ GeoRectangle rec=null; Rectangle srec=null; public SearchTool(){ data = new byte[cubs.length]; for(int i= 0 ; i< cubs.length; i++){ try{ data[i] = Byte.decode(cubs[i]).byteValue(); } catch (NumberFormatException nfe){ System.out.println("" + nfe + " "+ cubs[i]); } } } public int getRubberBandShape(){ return SimpleTool.RECTANGLE; } public void paint(Graphics g){ if(rec!=null){ Scaler s = context.getScale(); int [] origin = s.toGraphics(rec.x,rec.y); int gh = s.toGraphics(rec.height); int gw = s.toGraphics(rec.width); g.drawRect(origin[0],origin[1]-gh,gw,gh); } } public void release(){ if(mouse.isValidDrag()){ super.release(); rec=(GeoRectangle)mouse.getMapDragBox().clone(); }else{ rec=null; } } public Cursor getCursor(){ Toolkit tk = Toolkit.getDefaultToolkit(); //Image im = tk.getImage("search.gif"); Image im = null; //tk.createImage(data); // don't know why this doesn't work // System.out.println("loaded from data " + im); // if(im == null){ // im = tk.getImage("search.gif"); // System.out.println("loaded from gif " + im); // // } if(im != null){ System.out.println("building new cursor"); Cursor c = tk.createCustomCursor(im,new Point(0,0),"search"); return c; } System.out.println("returning default cursor"); return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR); } public GeoRectangle getBox(){ return rec; } public String getDescription() { return"search tool"; } public String getName() { return "search tool "; } static String[] cubs = { "0107","0111","0106","0070","0067","0141","0020","0000","0020","0000","0200","0000","0000","0000","0000","0000", "0377","0377","0377","0054","0000","0000","0000","0000","0020","0000","0020","0000","0000","0002","0057","0204", "0217","0151","0301","0333","0036","0034","0150","0164","0276","0030","0117","0266","0271","0137","0006","0056", "0022","0005","0156","0037","0371","0160","0045","0026","0102","0253","0252","0255","0351","0245","0176","0323", "0030","0262","0067","0207","0264","0247","0374","0252","0001","0123","0212","0042","0240","0000","0000","0073" }; static byte[] data; }