Bernhard Kastner a écrit :
[solved]
Using org.geotools.renderer.j2d.GeoMouseEvent.getMapCoordinate();
Sorry for having been slow to answer... Glad you find it.
2. How do I change the behaviour of the mouse on a map? When clicking
and draging the mouse, it generates a zoom-pane with the selected
area. I want to change this behaviour to pan the map. So, when moving
the mouse, the map also moves, but doesn't zoom or anything else. Is
this possible?
You can create yours own subclass of StyledMapPane and override the
following method:
protected void mouseSelectionPerformed(Shape area) {
}
See ZoomPane javadoc for details about this method. There is some other
methods that you can override in order to control different events.
And another question: As already mentioned, I'm using the methods as
in the Spearfish Sample, which uses J2D-renderer. I experienced
OutOfMemoryExceptions when dealing with larger shapefiles (3x 30 MB).
Is there a possibility to avoid that?
Technically yes, but it is hard to use at this time.
There is some chances that the shapefile datastore stores the geometries
as JTS object with arrays of CoordinatePoint. This storage scheme is
expensive. You can "compress" them, but with a cost: the lost of the
underlying JTS geometries. Explanation:
J2D renderer internally stores all geometries as
org.geotools.renderer.geom.Geometry objects using an abstract PointArray
structure. The point array may be JTS's Coordinate[] array, a plain
double[] array, etc. The idea is to switch from the Coordinate[]
representation to a float[] representation.
We first need to find the underlying Geometry objects. One possible way
is to invokes MapPane.getRenderer().getLayers(). Then iterates through
those layers and search for "if (layer instanceof RenderedGeometries)".
Invokes RenderedGeometries.getGeometry(). You should not have a
GeometryCollection (maybe not the only one, the search should continue
for other layers).
Invoke Geometry.compress(CompressionLevel.DIRECT_AS_FLOATS). If you get
an UnmodifiableGeometryException, try to clone the geometry before to
compress it.
Set the new geometry to the RenderedGeometries layer.
Make sure that there is no reference to the original JTS geometry
floating around (you may need to checks in a profiler to make sure that
their memory is reclaimed).
Martin.
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users