[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
------=_Part_9447_17725299.1206954816872
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
<span style="font-family: arial,sans-serif;">Hi, Jody:<br><br>Thanks for your suggestion. I achieve some progress with your suggestion. Could you have a look and check whether I am in the right direction?<br><br>My imaginary scenario is to extend the property example so if user double-clicks the airport, we could open a view and show some information for the selected airport (such as the camera view of the airport entrance from other application). To achieve this goal, I have to get the unique key for the selected data (eg, the airport name) and then use that key to query the information from other application source.<br>
I don't want to firstly put the user into some tool mode. So I have a quick look at the source code and make some hacks there. <br><br>1. Add a MouseListener to the ViewportPane.<br><span style="font-style: italic;"> IToolContext toolContext = ApplicationGIS.createContext(ApplicationGIS.getActiveMap());</span><br style="font-style: italic;">
<span style="font-style: italic;"> toolContext.getViewportPane().addMouseListener(this);</span><br>2. When user double clicks the pane, check whether the event's point is within 10 points from the airpoint location. So we can get the airport's name and use it in the further query.<br>
<span style="font-style: italic;"> List<ILayer> layers = ApplicationGIS.getActiveMap().getMapLayers();</span><br style="font-style: italic;"><span style="font-style: italic;"> for (ILayer layer : layers) {</span><br style="font-style: italic;">
<span style="font-style: italic;"> IGeoResource resource = layer.getGeoResource();</span><br style="font-style: italic;"><span style="font-style: italic;"> </span><br style="font-style: italic;">
<span style="font-style: italic;"> PropertyResource pr = resource.resolve(PropertyResource.class, null);</span><br style="font-style: italic;"><span style="font-style: italic;"> </span><br style="font-style: italic;">
<span style="font-style: italic;"> for (Map.Entry<String, Coordinate> entry : pr.getValues().entrySet()) {</span><br style="font-style: italic;"><span style="font-style: italic;"> IToolContext context = ApplicationGIS.createContext(ApplicationGIS.getActiveMap());</span><br style="font-style: italic;">
<span style="font-style: italic;"> Point p = context.worldToPixel(entry.getValue());</span><br style="font-style: italic;"><span style="font-style: italic;"> System.err.println("Distance: " + p.distance(e.getPoint()));</span><br style="font-style: italic;">
<span style="font-style: italic;"> if (p.distance(e.getPoint()) < 10) {</span><br style="font-style: italic;"><span style="font-style: italic;"> System.err.println("Hacked successfully.");</span><br style="font-style: italic;">
<span style="font-style: italic;"> System.out.println("Airport name is: " + entry.getKey());</span><br style="font-style: italic;"><span style="font-style: italic;"> }</span><br style="font-style: italic;">
<span style="font-style: italic;"> </span><br style="font-style: italic;"><span style="font-style: italic;"> }</span><br style="font-style: italic;"><span style="font-style: italic;"> }<br>
<br></span>From this way, I can get the airport name when I double clicks the airport in the map. But is it the best way to do that? Could I extend some extension points to achieve the same goal.<br><br>Another thinking is that the InfoTool you suggested is based on querying the feature source. How could I introduce the feature source in the property example? Could you give me some suggestions?<br>
<br>Thanks for reading this long letter and your help so long.<br><br>Best Regards,<br>Yang Sun<br><br><br></span><br><br><div><span class="gmail_quote">2008/3/27, Jody Garnett <<a href="mailto:jgarnett@xxxxxxxxxxxxxxx">jgarnett@xxxxxxxxxxxxxxx</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Have a look at the normal DistanceTool tutorial; it provides a tool that<br> responds to mouse down, and mouse release events. You can modify the<br> example to take care of double clicks. When you do get a double click<br>
you can do a query on your hospital layer to see if they clicked on one.<br> You may also enjoy looking at the InfoTool (it operates as a single<br> click; and opens a view up to show the result of a query at that location).<br>
<br> This email list is a great location for these kinds of questions.<br> Jody<br> <br>> Hi,<br> ><br> > I want to support some kind of interactivity when user clicks the map.<br> > For example, when user double clicks a point in the map, could I get<br>
> an event notification so I can do corresponding works?<br> ><br> > To be specific, I finished the tutorials for the custom property<br> > resource and property renderer, could I be notified when user double<br>
> click one of hospitals? Any listener mechanism exists?<br> ><br> > Pls give me some suggestions or code examples if any. Your help is<br> > appreciate.<br> ><br> > BTW, I am not sure whether this list is the right place to send this<br>
> email. If this kind of email should go to the users mailing list, pls<br> > tell me.<br> ><br> > Best Regards,<br> > Yang Sun<br> ><br> <br>> ------------------------------------------------------------------------<br>
><br> > _______________________________________________<br> > User-friendly Desktop Internet GIS (uDig)<br> > <a href="http://udig.refractions.net">http://udig.refractions.net</a><br> > <a href="http://lists.refractions.net/mailman/listinfo/udig-devel">http://lists.refractions.net/mailman/listinfo/udig-devel</a><br>
><br> <br> <br> _______________________________________________<br> User-friendly Desktop Internet GIS (uDig)<br> <a href="http://udig.refractions.net">http://udig.refractions.net</a><br> <a href="http://lists.refractions.net/mailman/listinfo/udig-devel">http://lists.refractions.net/mailman/listinfo/udig-devel</a><br>
</blockquote></div><br>
------=_Part_9447_17725299.1206954816872--