public static NavigatorEvent obtain(Navigator navigator, @WorldWind.NavigatorAction int action, InputEvent lastInputEvent) { NavigatorEvent instance = pool.acquire(); if (instance == null) { instance = new NavigatorEvent(); } instance.navigator = navigator; instance.action = action; instance.lastInputEvent = lastInputEvent; return instance; }
protected void notifyListeners(int action, InputEvent inputEvent) { NavigatorEvent event = NavigatorEvent.obtain(this.wwd.navigator, action, inputEvent); for (int idx = 0, len = this.listeners.size(); idx < len; idx++) { this.listeners.get(idx).onNavigatorEvent(this.wwd, event); } event.recycle(); } }
@Override public void onNavigatorEvent(WorldWindow wwd, NavigatorEvent event) { long currentTime = System.currentTimeMillis(); long elapsedTime = currentTime - lastEventTime; int eventAction = event.getAction(); boolean receivedUserInput = (eventAction == WorldWind.NAVIGATOR_MOVED && event.getLastInputEvent() != null); // Update the status overlay views whenever the navigator stops moving, // and also it is moving but at an (arbitrary) maximum refresh rate of 20 Hz. if (eventAction == WorldWind.NAVIGATOR_STOPPED || elapsedTime > 50) { // Get the current navigator state to apply to the overlays event.getNavigator().getAsLookAt(wwd.getGlobe(), lookAt); event.getNavigator().getAsCamera(wwd.getGlobe(), camera); // Update the overlays updateOverlayContents(lookAt, camera); updateOverlayColor(eventAction); lastEventTime = currentTime; } // Show the crosshairs while the user is gesturing and fade them out after the user stops if (receivedUserInput) { showCrosshairs(); } else { fadeCrosshairs(); } } };
@Override public void onNavigatorEvent(WorldWindow wwd, NavigatorEvent event) { long currentTime = System.currentTimeMillis(); long elapsedTime = currentTime - lastEventTime; int eventAction = event.getAction(); boolean receivedUserInput = (eventAction == WorldWind.NAVIGATOR_MOVED && event.getLastInputEvent() != null); // Update the status overlay views whenever the navigator stops moving, // and also it is moving but at an (arbitrary) maximum refresh rate of 20 Hz. if (eventAction == WorldWind.NAVIGATOR_STOPPED || elapsedTime > 50) { // Get the current navigator state to apply to the overlays event.getNavigator().getAsLookAt(wwd.getGlobe(), lookAt); event.getNavigator().getAsCamera(wwd.getGlobe(), camera); // Update the overlays updateOverlayContents(lookAt, camera); updateOverlayColor(eventAction); lastEventTime = currentTime; } // Show the crosshairs while the user is gesturing and fade them out after the user stops if (receivedUserInput) { showCrosshairs(); } else { fadeCrosshairs(); } } };