diff --git a/modules/me-worldwind/src/main/java/org/mapton/worldwind/api/LayerBundle.java b/modules/me-worldwind/src/main/java/org/mapton/worldwind/api/LayerBundle.java index 37febae35..9391c4cb9 100644 --- a/modules/me-worldwind/src/main/java/org/mapton/worldwind/api/LayerBundle.java +++ b/modules/me-worldwind/src/main/java/org/mapton/worldwind/api/LayerBundle.java @@ -22,6 +22,7 @@ import gov.nasa.worldwind.layers.Layer; import gov.nasa.worldwind.layers.RenderableLayer; import gov.nasa.worldwind.render.Renderable; +import gov.nasa.worldwind.render.airspaces.AbstractAirspace; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -34,6 +35,7 @@ import javafx.collections.ObservableList; import javafx.scene.Node; import org.mapton.api.MKey; +import org.openide.util.Exceptions; import se.trixon.almond.util.Dict; /** @@ -224,7 +226,11 @@ public void setDragEnabled(boolean enabled, RenderableLayer... layers) { for (var layer : layers) { for (var renderable : layer.getRenderables()) { if (renderable instanceof Draggable) { - ((Draggable) renderable).setDragEnabled(enabled); + if (renderable instanceof AbstractAirspace) { + setDragEnabled((AbstractAirspace) renderable, enabled); + } else { + ((Draggable) renderable).setDragEnabled(enabled); + } } } } @@ -282,4 +288,17 @@ private boolean getChildVisibility(Layer layer) { return visible; } + + private void setDragEnabled(AbstractAirspace abstractAirspace, boolean enabled) { + //TODO Remove this method once resolved: https://github.com/NASAWorldWind/WorldWindJava/issues/240 + try { + var dragEnabledField = AbstractAirspace.class.getDeclaredField("dragEnabled"); + boolean accessible = dragEnabledField.canAccess(abstractAirspace); + dragEnabledField.setAccessible(true); + dragEnabledField.set(abstractAirspace, enabled); + dragEnabledField.setAccessible(accessible); + } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) { + Exceptions.printStackTrace(ex); + } + } }