예제 #1
0
        /**
         * Static method to create an object from a factory, a configuration source, and an optional configuration parameter
         * list.
         *
         * @param factoryKey   the key identifying the factory in {@link Configuration}.
         * @param configSource the configuration source. May be any of the types listed for {@link
         *                     #createFromConfigSource(object, SharpEarth.avlist.AVList)}
         * @param parameters       key-value parameters to override or supplement the information provided in the specified
         *                     configuration source. May be null.
         *
         * @return a new instance of the requested object.
         *
         * @throws ArgumentException if the factory key is null, or if the configuration source is null or an empty
         *                                  string.
         */
        public static object create(string factoryKey, object configSource, AVList parameters)
        {
            if (factoryKey == null)
            {
                string message = Logging.getMessage("generic.FactoryKeyIsNull");
                throw new ArgumentException(message);
            }

            if (WWUtil.isEmpty(configSource))
            {
                string message = Logging.getMessage("generic.ConfigurationSourceIsInvalid", configSource);
                throw new ArgumentException(message);
            }

            Factory factory = (Factory)WorldWind.createConfigurationComponent(factoryKey);

            return(factory.createFromConfigSource(configSource, parameters));
        }
예제 #2
0
        /**
         * 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)
            {
                foreach (Layer layer in 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();
            }
        }
예제 #3
0
 /**
  * Reinitialize World Wind to its initial ready state. Shut down and restart all World Wind services and clear all
  * World Wind memory caches. Cache memory will be released at the next JVM garbage collection.
  * <p/>
  * Call this method to reduce World Wind's current resource usage to its initial, empty state. This is typically
  * required by applets when the user leaves the applet page.
  * <p/>
  * The state of any open {@link WorldWindow} objects is indeterminate subsequent to invocation of this method. The
  * core WorldWindow objects attempt to shut themselves down cleanly during the call, but their resulting window
  * state is undefined.
  * <p/>
  * World Wind can continue to be used after calling this method.
  */
 public static synchronized void shutDown()
 {
     instance.wwo.firePropertyChange(SHUTDOWN_EVENT, null, -1);
     instance.dispose();
     instance = new WorldWind();
 }