Hello

I'm willing to develop a small GIS application and I chose geotools, but
when I test my prototype I encounter a huge problem. When I resize my
application several times, for example full screen it 3 times, it freezes
and never comes back to life. I don't get any exception, message or
whatever, it just stops to react to clicks and to refresh. If I remove the
map, then the problem goes away. Actually I've been able to reproduce the
problem with very few lines, which I've copied downwards.
In this code snippet, I'm creating a layer with 2 points, but I had the same
problem when displaying a layer that reads a shapefile. The only way I found
to avoid it is when I display a map with no layer at all...

I can't believe that such a bug could stay in a well-known and tested
project like geotools, thus I must be doing something wrong. Could someone
point it out if it's obvious ? Thanks in advance.

Guillaume

Configuration : Windows XP, jre 1.5.0_19 (reproduced with 1.6), Geotools
2.6.1

///////////////////////// CODE. To reproduce problem, make the window
full-screen and then window again a few times (3-4 times)
import org.geotools.data.
DataUtilities;
import org.geotools.data.FeatureSource;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureCollections;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.geometry.jts.JTSFactoryFinder;
import org.geotools.map.DefaultMapContext;
import org.geotools.map.MapContext;
import org.geotools.swing.JMapFrame;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;

public class FailingCode {
    public static void main(String[] args) throws Exception {

        FeatureCollection collection = FeatureCollections.newCollection();
        final SimpleFeatureType TYPE = DataUtilities.createType("Location",
"location:Point,name:String");
        double lon[] = { 123.31, 0 };
        double lat[] = { 48.4, 52 };
        String name[] = { "Point1", "Point2" };
        GeometryFactory factory = JTSFactoryFinder.getGeometryFactory(null);
        for (int i = 0; i <= 1; i++) {
            Point point = factory.createPoint(new Coordinate(lon[i],
lat[i]));
            SimpleFeature feature = SimpleFeatureBuilder.build(TYPE, new
Object[] { point, name[i] }, null);
            collection.add(feature);
        }

        FeatureSource featureSource = DataUtilities.source(collection);
        MapContext map = new DefaultMapContext();
        map.addLayer(featureSource, null);
        JMapFrame.showMap(map);
    }
}
------------------------------------------------------------------------------
Download Intel&reg; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs 
proactively, and fine-tune applications for parallel performance. 
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to