public BasicModel() { String globeName = Configuration.getStringValue(AVKey.GLOBE_CLASS_NAME); if (globeName == null) { return; } this.setGlobe((Globe)WorldWind.createComponent(globeName)); // Look for the old-style, property-based layer configuration first. If not found then use the new-style // configuration. LayerList layers = null; String layerNames = Configuration.getStringValue(AVKey.LAYERS_CLASS_NAMES); if (layerNames != null) { // Usage of this deprecated method is intentional. It provides backwards compatibility for deprecated // functionality. //noinspection deprecation layers = this.createLayersFromProperties(layerNames); } else { Element el = Configuration.getElement("./LayerList"); if (el != null) { layers = this.createLayersFromElement(el); } } this.setLayers(layers != null ? layers : new LayerList(/*empty list*/)); // an empty list is ok }
/** * @param classNameKey the key identifying the component * * @return the new component * * @throws IllegalStateException if no name could be found which corresponds to <code>classNameKey</code> * @throws ArgumentException if <code>classNameKey<code> is null * @throws WWRuntimeException if the component could not be created */ public static object createConfigurationComponent(string classNameKey) { if (classNameKey == null || classNameKey.Length == 0) { Logging.logger().severe("nullValue.ClassNameKeyNullZero"); throw new ArgumentException(Logging.getMessage("nullValue.ClassNameKeyNullZero")); } String name = Configuration.getStringValue(classNameKey); if (name == null) { Logging.logger().log(Level.SEVERE, "WorldWind.NoClassNameInConfigurationForKey", classNameKey); throw new WWRuntimeException( Logging.getMessage("WorldWind.NoClassNameInConfigurationForKey", classNameKey)); } try { return(WorldWind.createComponent(name.Trim())); } catch (Exception e) { Logging.logger().log(Level.SEVERE, "WorldWind.UnableToCreateClassForConfigurationKey", name); throw new IllegalStateException( Logging.getMessage("WorldWind.UnableToCreateClassForConfigurationKey", name), e); } }
/** * Create the layer list from the old-style properties list of layer class names. * * @param layerNames a comma separated list of layer class names. * * @return a new layer list containing the specified layers. * * @deprecated Use {@link #createLayersFromElement(org.w3c.dom.Element)} instead. */ protected LayerList createLayersFromProperties(String layerNames) { LayerList layers = new LayerList(); if (layerNames == null) { return(null); } String[] names = layerNames.split(","); foreach (String name in names) { try { if (name.length() > 0) { Layer l = (Layer)WorldWind.createComponent(name); layers.add(l); } } catch (Exception e) { Logging.logger().log(Level.WARNING, Logging.getMessage("BasicModel.LayerNotFound", name), e); } } return(layers); }