@Override public void onMessage(String name, Object sender, Map<Object, Object> userProperties) { if (name.equals(WorldWind.REQUEST_REDRAW)) { this.requestRedraw(); // may be called on any thread } }
/** * Updates the status overlay after the background processing is complete. */ @Override protected void onPostExecute(Void notUsed) { super.onPostExecute(notUsed); statusText.setText(String.format(Locale.US, "%,d places, %,d highways and %,d countries created", this.numPlacesCreated, this.numHighwaysCreated, this.numCountriesCreated)); getWorldWindow().requestRedraw(); }
/** * Updates the aircraft placemark positions on the UI Thread. */ @Override protected void onPostExecute(Void notUsed) { super.onPostExecute(notUsed); // Update the aircraft placemark positions with the positions computed on the background thread. for (Placemark aircraft : aircraftPositions.keySet()) { aircraft.setPosition(aircraftPositions.get(aircraft)); } getWorldWindow().requestRedraw(); // Determine if the animation is done if (frameCount > ANIMATION_FRAMES) { // All the aircraft have arrived at their destinations; pause the animation pauseAnimation = true; statusText.setText("Animation complete"); } // Re-execute the animation after the prescribed delay if (!pauseAnimation) { handler.postDelayed(PlacemarksMilStd2525DemoActivity.this, DELAY_TIME); } } }
/** * Updates the WorldWindow layer list on the UI Thread. */ @Override protected void onPostExecute(Void notUsed) { super.onPostExecute(notUsed); getWorldWindow().getLayers().addLayer(this.placeLayer); statusText.setText(String.format(Locale.US, "%,d US places created", this.numPlacesCreated)); getWorldWindow().requestRedraw(); }
@Override public boolean handleMessage(Message msg) { if (msg.what == MSG_ID_CLEAR_CACHE) { renderResourceCache.clear(); } else if (msg.what == MSG_ID_REQUEST_REDRAW) { requestRedraw(); } else if (msg.what == MSG_ID_SET_VIEWPORT) { viewport.set((Viewport) msg.obj); } else if (msg.what == MSG_ID_SET_DEPTH_BITS) { depthBits = (Integer) msg.obj; } return false; } });
/** * Updates the RenderableLayer on the UI Thread. Invoked by calls to publishProgress. * * @param renderables An array of Renderables (length = 1) to add to the shapes layer. */ @Override protected void onProgressUpdate(Renderable... renderables) { super.onProgressUpdate(renderables); Renderable shape = renderables[0]; statusText.setText("Added " + shape.getDisplayName() + " feature..."); shapesLayer.addRenderable(shape); getWorldWindow().requestRedraw(); }
/** * Toggles the highlighted state of a picked object. */ public void togglePickedObjectHighlights() { String message = ""; for (Object pickedObject : pickedObjects) { if (pickedObject instanceof Highlightable) { Highlightable highlightable = (Highlightable) pickedObject; highlightable.setHighlighted(!highlightable.isHighlighted()); if (highlightable.isHighlighted()) { if (!message.isEmpty()) { message += ", "; } message += ((Renderable) highlightable).getDisplayName(); } } } if (!message.isEmpty()) { Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show(); } this.getWorldWindow().requestRedraw(); } }
/** * Toggles the selected state of a picked object. */ public void toggleSelection() { // Display the highlight or normal attributes to indicate the // selected or unselected state respectively. if (pickedObject instanceof Highlightable) { // Determine if we've picked a "new" object so we know to deselect the previous selection boolean isNewSelection = pickedObject != this.selectedObject; // Only one object can be selected at time, deselect any previously selected object if (isNewSelection && this.selectedObject instanceof Highlightable) { ((Highlightable) this.selectedObject).setHighlighted(false); } // Show the selection by showing its highlight attributes ((Highlightable) pickedObject).setHighlighted(isNewSelection); this.getWorldWindow().requestRedraw(); // Track the selected object this.selectedObject = isNewSelection ? pickedObject : null; } } }
@Override public void run() { this.wwd.getNavigator().setAsCamera(this.wwd.getGlobe(), this.camera); this.wwd.requestRedraw(); pool.release(this.reset()); } }
public void onFinished(String vehicleType) { PlacemarksSelectDragActivity activity = (PlacemarksSelectDragActivity) getActivity(); if (activity.controller.selectedObject instanceof Placemark) { Placemark placemark = (Placemark) activity.controller.selectedObject; String currentType = (String) placemark.getUserProperty(this.vehicleKey); if (currentType.equals(vehicleType)) { return; } // Update the placemark's icon attributes and vehicle type property. ImageSource imageSource = ImageSource.fromResource(this.vehicleIcons.get(vehicleType)); placemark.putUserProperty(this.vehicleKey, vehicleType); placemark.getAttributes().setImageSource(imageSource); placemark.getHighlightAttributes().setImageSource(imageSource); // Show the change activity.getWorldWindow().requestRedraw(); } }
@Override public void doFrame(long frameTimeNanos) { if (this.lastFrameTimeNanos != 0) { // Compute the frame duration in seconds. double frameDurationSeconds = (frameTimeNanos - this.lastFrameTimeNanos) * 1.0e-9; double cameraDegrees = (frameDurationSeconds * this.cameraDegreesPerSecond); // Move the navigator to continuously bring new tiles into view. Navigator navigator = getWorldWindow().getNavigator(); navigator.setLongitude(navigator.getLongitude() + cameraDegrees); // Redraw the WorldWindow to display the above changes. this.getWorldWindow().requestRedraw(); } Choreographer.getInstance().postFrameCallback(this); this.lastFrameTimeNanos = frameTimeNanos; }
@Override public void doFrame(long frameTimeNanos) { if (this.lastFrameTimeNanos != 0) { // Compute the frame duration in seconds. double frameDurationSeconds = (frameTimeNanos - this.lastFrameTimeNanos) * 1.0e-9; double cameraDegrees = (frameDurationSeconds * this.cameraDegreesPerSecond); // Move the navigator to simulate the Earth's rotation about its axis. Navigator navigator = getWorldWindow().getNavigator(); navigator.setLongitude(navigator.getLongitude() - cameraDegrees); // Redraw the WorldWindow to display the above changes. this.getWorldWindow().requestRedraw(); } if (!this.activityPaused) { // stop animating when this Activity is paused Choreographer.getInstance().postFrameCallback(this); } this.lastFrameTimeNanos = frameTimeNanos; }
@Override public void doFrame(long frameTimeNanos) { if (this.lastFrameTimeNanos != 0) { // Compute the frame duration in seconds. double frameDurationSeconds = (frameTimeNanos - this.lastFrameTimeNanos) * 1.0e-9; double cameraDegrees = (frameDurationSeconds * this.cameraDegreesPerSecond); // Move the navigator to simulate the Earth's rotation about its axis. Navigator navigator = getWorldWindow().getNavigator(); navigator.setLongitude(navigator.getLongitude() - cameraDegrees); // Redraw the WorldWindow to display the above changes. this.getWorldWindow().requestRedraw(); } if (!this.activityPaused) { // stop animating when this Activity is paused Choreographer.getInstance().postFrameCallback(this); } this.lastFrameTimeNanos = frameTimeNanos; }
protected void handlePinch(GestureRecognizer recognizer) { int state = recognizer.getState(); float scale = ((PinchRecognizer) recognizer).getScale(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); } else if (state == WorldWind.CHANGED) { if (scale != 0) { // Apply the change in scale to the navigator, relative to when the gesture began. this.lookAt.range = this.beginLookAt.range / scale; this.applyLimits(this.lookAt); this.wwd.getNavigator().setAsLookAt(this.wwd.getGlobe(), this.lookAt); this.wwd.requestRedraw(); } } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
protected void handleRotate(GestureRecognizer recognizer) { int state = recognizer.getState(); float rotation = ((RotationRecognizer) recognizer).getRotation(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); this.lastRotation = 0; } else if (state == WorldWind.CHANGED) { // Apply the change in rotation to the navigator, relative to the navigator's current values. double headingDegrees = this.lastRotation - rotation; this.lookAt.heading = WWMath.normalizeAngle360(this.lookAt.heading + headingDegrees); this.lastRotation = rotation; this.wwd.getNavigator().setAsLookAt(this.wwd.getGlobe(), this.lookAt); this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
@Override protected void handleRotate(GestureRecognizer recognizer) { int state = recognizer.getState(); float rotation = ((RotationRecognizer) recognizer).getRotation(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); this.lastRotation = 0; } else if (state == WorldWind.CHANGED) { // Apply the change in rotation to the navigator, relative to the navigator's current values. double headingDegrees = this.lastRotation - rotation; this.camera.heading = WWMath.normalizeAngle360(this.camera.heading + headingDegrees); this.lastRotation = rotation; this.wwd.getNavigator().setAsCamera(this.wwd.getGlobe(), this.camera); this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
@Override protected void handlePinch(GestureRecognizer recognizer) { int state = recognizer.getState(); float scale = ((PinchRecognizer) recognizer).getScale(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); } else if (state == WorldWind.CHANGED) { if (scale != 0) { // Apply the change in scale to the navigator, relative to when the gesture began. scale = ((scale - 1) * 0.1f) + 1; // dampen the scale factor this.camera.altitude = this.camera.altitude * scale; this.applyLimits(this.camera); this.wwd.getNavigator().setAsCamera(this.wwd.getGlobe(), this.camera); this.wwd.requestRedraw(); } } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
@Override public void doFrame(long frameTimeNanos) { if (this.lastFrameTimeNanos != 0) { // Compute the frame duration in seconds. double frameDurationSeconds = (frameTimeNanos - this.lastFrameTimeNanos) * 1.0e-9; double cameraDegrees = (frameDurationSeconds * this.cameraDegreesPerSecond); double lightDegrees = (frameDurationSeconds * this.lightDegreesPerSecond); // Move the navigator to simulate the Earth's rotation about its axis. Navigator navigator = getWorldWindow().getNavigator(); navigator.setLongitude(navigator.getLongitude() - cameraDegrees); // Move the sun location to simulate the Sun's rotation about the Earth. this.sunLocation.set(this.sunLocation.latitude, this.sunLocation.longitude - lightDegrees); this.atmosphereLayer.setLightLocation(this.sunLocation); // Redraw the WorldWindow to display the above changes. this.getWorldWindow().requestRedraw(); } if (!this.activityPaused) { // stop animating when this Activity is paused Choreographer.getInstance().postFrameCallback(this); } this.lastFrameTimeNanos = frameTimeNanos; }
protected void handleTilt(GestureRecognizer recognizer) { int state = recognizer.getState(); float dx = recognizer.getTranslationX(); float dy = recognizer.getTranslationY(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); this.lastRotation = 0; } else if (state == WorldWind.CHANGED) { // Apply the change in tilt to the navigator, relative to when the gesture began. double headingDegrees = 180 * dx / this.wwd.getWidth(); double tiltDegrees = -180 * dy / this.wwd.getHeight(); this.lookAt.heading = WWMath.normalizeAngle360(this.beginLookAt.heading + headingDegrees); this.lookAt.tilt = this.beginLookAt.tilt + tiltDegrees; this.applyLimits(this.lookAt); this.wwd.getNavigator().setAsLookAt(this.wwd.getGlobe(), this.lookAt); this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
@Override protected void handleTilt(GestureRecognizer recognizer) { int state = recognizer.getState(); float dx = recognizer.getTranslationX(); float dy = recognizer.getTranslationY(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); this.lastRotation = 0; } else if (state == WorldWind.CHANGED) { // Apply the change in tilt to the navigator, relative to when the gesture began. double headingDegrees = 180 * dx / this.wwd.getWidth(); double tiltDegrees = -180 * dy / this.wwd.getHeight(); this.camera.heading = WWMath.normalizeAngle360(this.beginCamera.heading + headingDegrees); this.camera.tilt = this.beginCamera.tilt + tiltDegrees; this.applyLimits(camera); this.wwd.getNavigator().setAsCamera(this.wwd.getGlobe(), this.camera); this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }