protected void doGetRestorableStateForAVPair( String key, Object value, RestorableSupport rs, RestorableSupport.StateObject context) { if (value instanceof URLBuilder) { rs.addStateValueAsString(context, "wms.Version", ((URLBuilder) value).wmsVersion); rs.addStateValueAsString(context, "wms.Crs", ((URLBuilder) value).crs); } else { super.doGetRestorableStateForAVPair(key, value, rs, context); } }
protected static void wmsRestoreStateToParams( RestorableSupport rs, RestorableSupport.StateObject context, AVList params) { // Invoke the BasicTiledImageLayer functionality. restoreStateForParams(rs, context, params); // Parse any legacy WMSTiledImageLayer state values. legacyWmsRestoreStateToParams(rs, context, params); String s = rs.getStateValueAsString(context, AVKey.IMAGE_FORMAT); if (s != null) params.setValue(AVKey.IMAGE_FORMAT, s); s = rs.getStateValueAsString(context, AVKey.TITLE); if (s != null) params.setValue(AVKey.TITLE, s); s = rs.getStateValueAsString(context, AVKey.DISPLAY_NAME); if (s != null) params.setValue(AVKey.DISPLAY_NAME, s); RestorableSupport.adjustTitleAndDisplayName(params); s = rs.getStateValueAsString(context, AVKey.LAYER_NAMES); if (s != null) params.setValue(AVKey.LAYER_NAMES, s); s = rs.getStateValueAsString(context, AVKey.STYLE_NAMES); if (s != null) params.setValue(AVKey.STYLE_NAMES, s); s = rs.getStateValueAsString(context, "wms.Version"); if (s != null) params.setValue(AVKey.WMS_VERSION, s); params.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(params)); }
public WMSTiledImageLayer(String stateInXml) { this(wmsRestorableStateToParams(stateInXml)); RestorableSupport rs; try { rs = RestorableSupport.parse(stateInXml); } catch (Exception e) { // Parsing the document specified by stateInXml failed. String message = Logging.getMessage("generic.ExceptionAttemptingToParseStateXml", stateInXml); Logging.logger().severe(message); throw new IllegalArgumentException(message, e); } this.doRestoreState(rs, null); }
protected static AVList wmsRestorableStateToParams(String stateInXml) { if (stateInXml == null) { String message = Logging.getMessage("nullValue.StringIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } RestorableSupport rs; try { rs = RestorableSupport.parse(stateInXml); } catch (Exception e) { // Parsing the document specified by stateInXml failed. String message = Logging.getMessage("generic.ExceptionAttemptingToParseStateXml", stateInXml); Logging.logger().severe(message); throw new IllegalArgumentException(message, e); } AVList params = new AVListImpl(); wmsRestoreStateToParams(rs, null, params); return params; }
protected static void legacyWmsRestoreStateToParams( RestorableSupport rs, RestorableSupport.StateObject context, AVList params) { // WMSTiledImageLayer has historically used a different format for storing LatLon and Sector // properties // in the restorable state XML documents. Although WMSTiledImageLayer no longer writes these // properties, // we must provide support for reading them here. Double lat = rs.getStateValueAsDouble(context, AVKey.LEVEL_ZERO_TILE_DELTA + ".Latitude"); Double lon = rs.getStateValueAsDouble(context, AVKey.LEVEL_ZERO_TILE_DELTA + ".Longitude"); if (lat != null && lon != null) params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, LatLon.fromDegrees(lat, lon)); Double minLat = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MinLatitude"); Double minLon = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MinLongitude"); Double maxLat = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MaxLatitude"); Double maxLon = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MaxLongitude"); if (minLat != null && minLon != null && maxLat != null && maxLon != null) params.setValue(AVKey.SECTOR, Sector.fromDegrees(minLat, maxLat, minLon, maxLon)); }