![]() |
|
|||||||
| Development Help Help for building applications or diagnosing problems with WWJ |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | ||
|
Junior Member
Join Date: Jul 2012
Posts: 8
![]() |
I'm using WWJ 1.3 and the ApplicationTemplate.java class. The WorldMapLayer class indicates that the ClickAndGoSelectListener can be used to move the view to a selected location when that location is clicked within the layer's map. I have modifed the ApplicationTemplate.java and ClickAndGoSelectListener classes. ClickAndGoSelectListener will display the lat/lon coordinates of the terrain when a RIGHT_CLICK occurs. However, the listener never gets called on a RIGHT_CLICK. If the user clicks on a tactical symbol, though, the listener gets called and the coordinates are displayed.
In the code below, a right click on the terrain displays nothing, but a right click on a tactical symbol displays: Quote:
Code:
this.wwd = this.createWorldWindow(); // returns new WorldWindowGLCanvas(); this.wwd.addSelectListener(new SSFClickAndGoSelectListener(this.getWwd(), WorldMapLayer.class)); Code:
public void selected(SelectEvent event)
{
if (event.isRightClick())
{System.out.println(" RIGHT Click ");
PickedObjectList pol = event.getObjects();
if (event.hasObjects())
{
System.out.println(" RIGHT Lat "+pol.getTerrainObject().getPosition().getLatitude().getDegrees()+
" Lon "+event.getObjects().getTerrainObject().getPosition().getLongitude().getDegrees());
}
else
{
System.out.println(" RIGHT, but no objects");
}
}
...
Quote:
Finally, I'd like to remove the "fly-to" functionality of the LEFT_CLICK. If I comment out the call to view.goTo() in my ClickAndGoSelectListener, the LEFT_CLICK still pans to the location. Is there another class which the example ApplicationTemplate uses to implement the ClickAndGoSelectListener functions? Thanks for your time and help. |
||
|
|
|
|
|
#2 |
|
WW Dev. Team
Join Date: Sep 2010
Location: Boston, MA, USA
Posts: 325
![]() |
You need to use a MouseListener to handle terrain selection (which I think you've already figured out, judging from this thread).
The "pan to location on left click" is handled by the default input handler, not the ClickAndGoSelectListener. An easy way to disable this feature is to add mouse listener that consumes clicks on terrain (the mouse listener will process clicks before the WW input handler, and the input handler will ignore any events that have already been consumed.) Code:
wwd.getInputHandler().addMouseListener(new MouseAdapter()
{
@Override
public void mouseClicked(MouseEvent e)
{
PickedObjectList objects = wwd.getObjectsAtCurrentPosition();
boolean isTerrain = objects != null
&& objects.getTopPickedObject() != null
&& objects.getTopPickedObject().isTerrain();
if (isTerrain)
{
e.consume(); // Prevents globe moving in response to click
}
}
});
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Does Terrain Picking Work in 1.4.0? | jscWaveLink | Development Help | 5 | 07-21-2012 05:43 AM |
| Problem picking terrain with vertical exaggeration set to 0 | NathanKronenfeld | Development Help | 3 | 01-21-2011 04:50 PM |
| Bug in the visualization for the terrain of CompoundElevationModel? | mao | Development Help | 8 | 03-20-2009 05:12 AM |
| Problem with terrain and its modification | bako | Development Help | 1 | 02-23-2009 05:35 PM |