|
From: Bernhard K. <bka...@li...> - 2005-10-07 06:18:57
|
Hi,
I'm new to Geotools and would like to do a small project which reads
Shapefiles and displays them in a JFrame.
However, I managed to display my Shapefiles using the same methods as
the Spearfish Sample on the homepage (JAI, ...).
Now, I have two questions:
1. How do I get the world-coordinates when clicking with the mouse? When
adding a normal MouseListener, it only returns the coordinates on the
screen, but I would like to know the position on the map.
I tried adding a MouseListener to the map by doing
8<------------------
public class do_it implements MouseListener {
[...]
StyledMapPane mapPane = new StyledMapPane();
[...]
mapPane.addMousteListener(this);
[...]
public void mouseReleased(MouseEvent me) {
GeoMouseEvent event = (GeoMouseEvent) me;
}
[...]
8<------------------
Unfortunately I get an InvalidClassCast-Exception, but this is the
syntax suggested in org.geotools.gui.swing.event.GeoMouseEvent.class so
I'm confused.
I also tried creating a new GeoMouseEvent with it's constructor using a
null-transform MathTransform var and manually creating a new Coordinate.
Didn't work.
So how do I get the world-coordinate of the mouse on the map?
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?
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?
greetings
Bernhard
|