World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 11-23-2009, 11:14 PM   #1
jas511
Senior Member
 
Join Date: Aug 2009
Posts: 152
Default [Solved] Select Listener

I'm trying to add a select listener to a screen annotation but I can't seem to get it to work. I have a simple renderable layer and as a test added one ImageAnnotation. I then add a select listener to the ww canvas, but I never see a select event when the mouse is over the annotation. Should I? If not, I'm not sure I understand...That seems to be how the View Controls layer works.

thanks,
Jeff
__________________
Jeff Storey
Software Developer
http://jeffastorey.blogspot.com

Last edited by patmurris; 11-30-2009 at 05:31 PM. Reason: Solved
jas511 is offline   Reply With Quote
Old 11-23-2009, 11:42 PM   #2
nlneilson
Super Member
 
Join Date: Nov 2006
Location: 35.0376,-117.9688
Posts: 1,519
Default

Take a look at several of the examples that use picking, like DraggingShapes.
I don't recall what is necessary other than:
Code:
import gov.nasa.worldwind.event.SelectEvent;
import gov.nasa.worldwind.event.SelectListener;

and

	    wwd.addSelectListener(new SelectListener(){
	    	public void selected(SelectEvent event){
	    		if (event.getEventAction().equals(SelectEvent.LEFT_CLICK) 
	    				&& event.hasObjects()
	    				&& event.getTopObject() instanceof Polyline){
	    			positions = (ArrayList<Position>) ((Polyline) event.getTopObject()).getPositions();	    			
	    			System.out.println("#39 PathsList: " + positions);
	    		}
	    	}	
	    });
For Annotations it would be "instanceof Annotation"
For mouse over it would be "SelectEvent.ROLLOVER"

I just used the above code for initial testing. DraggingShapes has the Object highlighted.

Last edited by nlneilson; 11-23-2009 at 11:50 PM.
nlneilson is offline   Reply With Quote
Old 11-24-2009, 12:00 AM   #3
jas511
Senior Member
 
Join Date: Aug 2009
Posts: 152
Default

Hmm...that's what I thought but I just put a println in the selected method and I'm not even seeing that being called when I mouse over or click on the screen annotation. I tried removing the other select listener I have for the view controls but that didn't fix anything either. I'll investigate further...thanks.
__________________
Jeff Storey
Software Developer
http://jeffastorey.blogspot.com
jas511 is offline   Reply With Quote
Old 11-24-2009, 12:46 AM   #4
nlneilson
Super Member
 
Join Date: Nov 2006
Location: 35.0376,-117.9688
Posts: 1,519
Default

You might need to put this in your main, but if you are using View Controls also it should all ready be in somewhere.

import gov.nasa.worldwind.pick.PickedObjectList ;

edit: Look at examples.Annotations.java, it has:
import gov.nasa.worldwind.pick.*;

I don't use ApplicationTemplate so your app may be different.

Last edited by nlneilson; 11-24-2009 at 12:53 AM.
nlneilson is offline   Reply With Quote
Old 11-24-2009, 12:54 AM   #5
jas511
Senior Member
 
Join Date: Aug 2009
Posts: 152
Default

As you suspected, that didn't really do anything. Would it be incorrect to have 2 select listeners (though removing one of them didn't help). I'll let you know if I can figure anything out.
__________________
Jeff Storey
Software Developer
http://jeffastorey.blogspot.com
jas511 is offline   Reply With Quote
Old 11-24-2009, 01:10 AM   #6
jas511
Senior Member
 
Join Date: Aug 2009
Posts: 152
Default

I think I inadvertently had an overridden method from AbstractLayer (doPick) and didn't call super first and I think that broke it.
__________________
Jeff Storey
Software Developer
http://jeffastorey.blogspot.com
jas511 is offline   Reply With Quote
Old 11-24-2009, 01:13 AM   #7
nlneilson
Super Member
 
Join Date: Nov 2006
Location: 35.0376,-117.9688
Posts: 1,519
Default

Run examples.Annotations.java, and then see where your app/layer is different.
nlneilson is offline   Reply With Quote
Old 11-26-2009, 05:04 PM   #8
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
Default

Is your layer pick enabled?
__________________
My World Wind Java Blog & WW.net Plugins page
patmurris is offline   Reply With Quote
Old 11-30-2009, 03:48 PM   #9
jas511
Senior Member
 
Join Date: Aug 2009
Posts: 152
Default

My layer extended RenderableLayer and I had overridden doPick and not called the super doPick and that seemed to fix the issue. Thanks.
__________________
Jeff Storey
Software Developer
http://jeffastorey.blogspot.com
jas511 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solved] Annotation Select agreen53 Development Help 11 08-04-2009 12:42 PM
How to add a Java listener for position change? emaronchi Development Help 6 04-13-2008 11:08 PM
File listener nlneilson Development Help 0 03-29-2008 10:34 PM
Mouse Listener ayman Development Help 1 03-16-2008 09:51 AM
Select many icons Akhesa Development Help 1 02-20-2008 12:00 AM


All times are GMT +1. The time now is 05:19 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.