/* * PostGISLayer.java * * Created on 01 December 2001, 01:36 */ package uk.ac.leeds.ccg.sfsql; import uk.ac.leeds.ccg.geotools.*; /** * * @author James Macgill * @version */ public class PostGISLayer extends MixedLayer implements Runnable{ PostGISDataSource featureSource; GeoRectangle last; /** Creates new PostGISLayer */ public PostGISLayer(PostGISDataSource featureSource,GeoRectangle initalExtent) { super.setBounds(initalExtent); this.featureSource = featureSource; updateFeatures(initalExtent); } public void paintScaled(GeoGraphics g){ GeoRectangle bbox = g.getScale().getMapExtent(); if(!bbox.equals(last)){ updateFeatures(bbox); } super.paintScaled(g); } public void updateFeatures(GeoRectangle bounds){ last = bounds; Thread updater = new Thread(this); updater.start(); } public void run() { try{ featureSource.addFeatures(this,(GeoRectangle)last.clone()); System.out.println("New features in place"); } catch(Exception e){ System.err.println("Update failed "+e); e.printStackTrace(); } } }