/** * Computes the aircraft positions on a background thread. */ @Override protected Void doInBackground(Void... params) { double amount = (double) frameCount++ / ANIMATION_FRAMES; // fractional amount along path for (Placemark aircraft : aircraftPositions.keySet()) { // Move the aircraft placemark along its great circle flight path. Position origin = (Position) aircraft.getUserProperty("origin"); Position destination = (Position) aircraft.getUserProperty("destination"); Position currentPosition = aircraftPositions.get(aircraft); // Update the currentPosition members (in-place) origin.interpolateAlongPath(destination, WorldWind.GREAT_CIRCLE, amount, currentPosition); } return null; }
/** * Edits the currently selected object. */ public void edit() { if (this.selectedObject instanceof Placemark && this.selectedObject.hasUserProperty(EDITABLE)) { Placemark placemark = (Placemark) this.selectedObject; // Pass the current aircraft type in a Bundle Bundle args = new Bundle(); args.putString("title", "Select the " + placemark.getDisplayName() + "'s type"); if (placemark.hasUserProperty(AIRCRAFT_TYPE)) { args.putString("vehicleKey", AIRCRAFT_TYPE); args.putString("vehicleValue", (String) placemark.getUserProperty(AIRCRAFT_TYPE)); } else if (placemark.hasUserProperty(AUTOMOTIVE_TYPE)) { args.putString("vehicleKey", AUTOMOTIVE_TYPE); args.putString("vehicleValue", (String) placemark.getUserProperty(AUTOMOTIVE_TYPE)); } // The VehicleTypeDialog calls onFinished VehicleTypeDialog dialog = new VehicleTypeDialog(); dialog.setArguments(args); dialog.show(getSupportFragmentManager(), "aircraft_type"); } else { Toast.makeText(getApplicationContext(), (this.selectedObject == null ? "Object " : this.selectedObject.getDisplayName()) + " is not editable.", Toast.LENGTH_LONG).show(); } }
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(); } }