Hi,
I have associated my JMapPane to a MouseMotionListener  with the 
mouseDragged method. In fact, a want to extend the Pan tool  to allow 
the user the drag map View.
In the method mouseDragged, i catch the JmapPane and i verify the tools 
used is the Pan. In this method I would like to repaint the mapArea as 
the user drag the mouse in the view.
I have some problem to understand how i can do that. I have used to 
method Pan (in the JmapPane class) to test and try to modify it to 
repaint just a little displacment :

 public void mouseDragged(MouseEvent e){
        JMapPane mapPane = (JMapPane)e.getSource();   
        if(mapPane.getState() == JMapPane.Pan){
            Rectangle bounds = mapPane.getBounds();
            double x = e.getX();
            double y = e.getY();
            double width = mapPane.getMapArea().getWidth();
            double height = mapPane.getMapArea().getHeight();
            double width2 = mapPane.getMapArea().getWidth() / 2D;
            double height2 = mapPane.getMapArea().getHeight() / 2D;
            double mapX = (x * width) / (double)bounds.width + 
mapPane.getMapArea().getMinX();
            double mapY = ((bounds.getHeight() - y) * height) / 
(double)bounds.height + mapPane.getMapArea().getMinY();
            double zlevel = 1.0D;
            Coordinate ll = new Coordinate(mapX - width2 / zlevel, mapY 
- height2 / zlevel);
            //System.out.println("ll : minX : "+(mapX - width2 / 
zlevel)+"    minY : "+(mapY - height2 / zlevel));
            Coordinate ur = new Coordinate(mapX + width2 / zlevel, mapY 
+ height2 / zlevel);
            //System.out.println("ll : minX : "+(mapX + width2 / 
zlevel)+"    minY : "+(mapY + height2 / zlevel));
            mapPane.setMapArea(new Envelope(ll, ur));
            mapPane.repaint();
    }
}

But when I do that (modifications), the result is horrible (map 
discplacements are huge)!! If someone knows what must be modify to 
answer my need i will help me great.
Thanks
manu

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to