Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[no subject]

------=_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&#39;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;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IToolContext toolContext = ApplicationGIS.createContext(ApplicationGIS.getActiveMap());</span><br style="font-style: italic;">
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; toolContext.getViewportPane().addMouseListener(this);</span><br>2. When user double clicks the pane, check whether the event&#39;s point is within 10 points from the airpoint location. So we can get the airport&#39;s name and use it in the further query.<br>
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;ILayer&gt; layers = ApplicationGIS.getActiveMap().getMapLayers();</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (ILayer layer : layers) {</span><br style="font-style: italic;">
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; IGeoResource resource = layer.getGeoResource();</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><br style="font-style: italic;">
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; PropertyResource pr = resource.resolve(PropertyResource.class, null);</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><br style="font-style: italic;">
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (Map.Entry&lt;String, Coordinate&gt; entry : pr.getValues().entrySet()) {</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; IToolContext context = ApplicationGIS.createContext(ApplicationGIS.getActiveMap());</span><br style="font-style: italic;">
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Point p = context.worldToPixel(entry.getValue());</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.err.println(&quot;Distance: &quot; + p.distance(e.getPoint()));</span><br style="font-style: italic;">
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (p.distance(e.getPoint()) &lt; 10) {</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.err.println(&quot;Hacked successfully.&quot;);</span><br style="font-style: italic;">
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println(&quot;Airport name is: &quot; + entry.getKey());</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br style="font-style: italic;">
<span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<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 &lt;<a href="mailto:jgarnett@xxxxxxxxxxxxxxx";>jgarnett@xxxxxxxxxxxxxxx</a>&gt;:</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>&gt; Hi,<br> &gt;<br> &gt; I want to support some kind of interactivity when user clicks the map.<br> &gt; For example, when user double clicks a point in the map, could I get<br>
&gt; an event notification so I can do corresponding works?<br> &gt;<br> &gt; To be specific, I finished the tutorials for the custom property<br> &gt; resource and property renderer, could I be notified when user double<br>
&gt; click one of hospitals? Any listener mechanism exists?<br> &gt;<br> &gt; Pls give me some suggestions or code examples if any. Your help is<br> &gt; appreciate.<br> &gt;<br> &gt; BTW, I am not sure whether this list is the right place to send this<br>
&gt; email. If this kind of email should go to the users mailing list, pls<br> &gt; tell me.<br> &gt;<br> &gt; Best Regards,<br> &gt; Yang Sun<br> &gt;<br> <br>&gt; ------------------------------------------------------------------------<br>
&gt;<br> &gt; _______________________________________________<br> &gt; User-friendly Desktop Internet GIS (uDig)<br> &gt; <a href="http://udig.refractions.net";>http://udig.refractions.net</a><br> &gt; <a href="http://lists.refractions.net/mailman/listinfo/udig-devel";>http://lists.refractions.net/mailman/listinfo/udig-devel</a><br>
&gt;<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--


Back to the top