On 24 September 2012 15:47, Boided <[email protected]> wrote: > Thanks Andre.. > That was really helpful.. Actually my requirement is to > open a shapefile. and then draw a rectangle with mouse events on the > shapefile and get the features of the area drawn... >
Hello, You don't say whether you want to use GeoTools GUI classes (gt-swing or gt-swt) to display features and draw your mouse box. If you are using gt-swing you might find it helpful to look at the following sources: Class MouseDragBox is used to draw (XOR mode) a rectangle on a map pane with the mouse: https://github.com/geotools/geotools/blob/8.2/modules/unsupported/swing/src/main/java/org/geotools/swing/MouseDragBox.java Class ZoomInTool shows an example of how to use mouse dragging to get a bounding box (in this case an instance of Envelope2D). See the mouseDragged and mouseReleased methods: https://github.com/geotools/geotools/blob/8.2/modules/unsupported/swing/src/main/java/org/geotools/swing/tool/ZoomInTool.java ZoomInTool uses the box to set a new display area for the map pane, but in your case you could use it to create your Query. Michael PS. Just noticed that the MouseDragBox constructor and setEnabled method are both package-private which is probably just a slip-up on my part. I'll change them to public, but in the mean time you could just copy and paste to your own sources. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ GeoTools-GT2-Users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
