/**
   * Causes resources used by the World Window to be freed. The World Window cannot be used once
   * this method is called. An OpenGL context for the window must be current.
   */
  public void shutdown() {
    WorldWind.getDataFileStore().removePropertyChangeListener(this);

    if (this.inputHandler != null) {
      this.inputHandler.dispose();
      this.inputHandler = new NoOpInputHandler();
    }

    // Clear the texture cache
    if (this.getGpuResourceCache() != null) this.getGpuResourceCache().clear();

    // Dispose all the layers //  TODO: Need per-window dispose for layers
    if (this.getModel() != null && this.getModel().getLayers() != null) {
      for (Layer layer : this.getModel().getLayers()) {
        try {
          layer.dispose();
        } catch (Exception e) {
          Logging.logger()
              .log(
                  java.util.logging.Level.SEVERE,
                  Logging.getMessage("WorldWindowGLCanvas.ExceptionWhileShuttingDownWorldWindow"),
                  e);
        }
      }
    }

    SceneController sc = this.getSceneController();
    if (sc != null) sc.dispose();
  }
 private void unhideHiddenLayers() {
   if (!_hasHiddenLayers) {
     return;
   }
   for (final Layer layer : _hiddenLayers) {
     layer.setEnabled(true);
   }
 }
  @Override
  protected Layer createLayer() {
    Layer layer = this.doCreateLayer();

    layer.setPickEnabled(false);

    return layer;
  }
Example #4
0
    protected RenderableLayer getLayer() {
      for (Layer layer : getWwd().getModel().getLayers()) {
        if (layer.getName().contains("Renderable")) {
          return (RenderableLayer) layer;
        }
      }

      return null;
    }
 /**
  * Insert the given Layer before or after the first occurrence of the given layer type.
  *
  * @param layer The layer to insert
  * @param layerType The type of layer to insert before or after
  * @param insertBefore Boolean that if true, will all insertion before the given type and if
  *     false, will insert after the type has been encountered.
  */
 public void insertAtLayer(Layer layer, Class<?> layerType, boolean insertBefore) {
   LayerList layers = getWWD().getModel().getLayers();
   int offset = insertBefore ? 0 : 1;
   for (Layer aLayer : layers) {
     if (aLayer.getClass().isInstance(layerType)) {
       layers.add(layers.indexOf(aLayer) + offset, layer);
       break;
     }
   }
 }
  private void hideOtherLayers(final Layer visibleLayer, final GHUDLayer hudLayer) {
    _hasHiddenLayers = true;

    final GGlobeApplication application = GGlobeApplication.instance();
    for (final Layer layer : application.getLayerList()) {
      if ((layer == visibleLayer) || (layer == hudLayer)) {
        continue;
      }

      if (layer.isEnabled()) {
        _hiddenLayers.add(layer);
        layer.setEnabled(false);
      }
    }
    redraw();
  }
Example #7
0
  public Layer addInternalActiveLayer(Layer layer) {
    // Internal Active layers are not shown in the layer tree but are shown in the active layers
    // list
    layer.setValue(Constants.ACTIVE_LAYER, true);

    return addLayer(layer, Constants.INTERNAL_LAYER);
  }
Example #8
0
  private Layer addLayer(Layer layer, String layerType) {
    if (layer != null) {
      layer.setValue(layerType, true);
      this.getWWPanel().addLayer(layer);
    }

    return layer;
  }