protected void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context) { // Restore the property limits and collision detection flags before restoring the view's position and // orientation. This has the effect of ensuring that the view's position and orientation are consistent with the // current property limits and the current surface collision state. RestorableSupport.StateObject so = rs.getStateObject(context, "viewPropertyLimits"); if (so != null) { this.getViewPropertyLimits().restoreState(rs, so); } Boolean b = rs.getStateValueAsBoolean(context, "detectCollisions"); if (b != null) { this.setDetectCollisions(b); } Double d = rs.getStateValueAsDouble(context, "fieldOfView"); if (d != null) { this.setFieldOfView(Angle.fromDegrees(d)); } d = rs.getStateValueAsDouble(context, "nearClipDistance"); if (d != null) { this.setNearClipDistance(d); } d = rs.getStateValueAsDouble(context, "farClipDistance"); if (d != null) { this.setFarClipDistance(d); } Position p = rs.getStateValueAsPosition(context, "eyePosition"); if (p != null) { this.setEyePosition(p); } d = rs.getStateValueAsDouble(context, "heading"); if (d != null) { this.setHeading(Angle.fromDegrees(d)); } d = rs.getStateValueAsDouble(context, "pitch"); if (d != null) { this.setPitch(Angle.fromDegrees(d)); } }
//**************************************************************// //******************** Restorable State ***********************// //**************************************************************// protected void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context) { super.doGetRestorableState(rs, context); rs.addStateValueAsLatLon(context, "center", this.getCenter()); rs.addStateValueAsDouble(context, "width", this.getWidth()); rs.addStateValueAsDouble(context, "height", this.getHeight()); rs.addStateValueAsDouble(context, "headingDegrees", this.getHeading().degrees); }
//**************************************************************// //******************** Restorable State ***********************// //**************************************************************// public void getRestorableState(RestorableSupport rs, RestorableSupport.StateObject context) { rs.addStateValueAsSector(context, "eyeLocationLimits", this.eyeLocationLimits); rs.addStateValueAsDouble(context, "minEyeElevation", this.minEyeElevation); rs.addStateValueAsDouble(context, "maxEyeElevation", this.maxEyeElevation); rs.addStateValueAsDouble(context, "minHeadingDegrees", this.minHeading.degrees); rs.addStateValueAsDouble(context, "maxHeadingDegrees", this.maxHeading.degrees); rs.addStateValueAsDouble(context, "minPitchDegrees", this.minPitch.degrees); rs.addStateValueAsDouble(context, "maxPitchDegrees", this.maxPitch.degrees); }
//**************************************************************// //******************** Restorable State ***********************// //**************************************************************// public void getRestorableState(RestorableSupport rs, RestorableSupport.StateObject context) { base.getRestorableState(rs, context); rs.addStateValueAsSector(context, "centerLocationLimits", this.centerLocationLimits); rs.addStateValueAsDouble(context, "minCenterElevation", this.minCenterElevation); rs.addStateValueAsDouble(context, "maxCenterElevation", this.maxCenterElevation); rs.addStateValueAsDouble(context, "minZoom", this.minZoom); rs.addStateValueAsDouble(context, "maxZoom", this.maxZoom); }
//**************************************************************// //******************** Restorable Support ********************// //**************************************************************// public void getRestorableStateForAVPair(String key, Object value, RestorableSupport rs, RestorableSupport.StateObject context) { if (value is URLBuilder) { rs.addStateValueAsString(context, "wms.Version", ((URLBuilder)value).wmsVersion); rs.addStateValueAsString(context, "wms.Crs", ((URLBuilder)value).crs); } else { super.getRestorableStateForAVPair(key, value, rs, context); } }
public void restoreState(RestorableSupport rs, RestorableSupport.StateObject context) { base.restoreState(rs, context); Sector sector = rs.getStateValueAsSector(context, "centerLocationLimits"); if (sector != null) { this.setCenterLocationLimits(sector); } // Min and max center elevation. double[] minAndMaxValue = this.getCenterElevationLimits(); Double min = rs.getStateValueAsDouble(context, "minCenterElevation"); if (min != null) { minAndMaxValue[0] = min; } Double max = rs.getStateValueAsDouble(context, "maxCenterElevation"); if (max != null) { minAndMaxValue[1] = max; } if (min != null || max != null) { this.setCenterElevationLimits(minAndMaxValue[0], minAndMaxValue[1]); } // Min and max zoom value. minAndMaxValue = this.getZoomLimits(); min = rs.getStateValueAsDouble(context, "minZoom"); if (min != null) { minAndMaxValue[0] = min; } max = rs.getStateValueAsDouble(context, "maxZoom"); if (max != null) { minAndMaxValue[1] = max; } if (min != null || max != null) { this.setZoomLimits(minAndMaxValue[0], minAndMaxValue[1]); } }
//**************************************************************// //******************** Restorable Support ********************// //**************************************************************// public override void getRestorableStateForAVPair(String key, Object value, RestorableSupport rs, RestorableSupport.StateObject context) { if (value is URLBuilder) { rs.addStateValueAsString(context, AVKey.WCS_VERSION, ((URLBuilder)value).serviceVersion); } else if (!(value is WCS100DescribeCoverage)) { // Don't pass DescribeCoverage to superclass. The DescribeCoverage parameters will already be present in the // parameter list, so do nothing here. super.getRestorableStateForAVPair(key, value, rs, context); } }
public String getRestorableState() { RestorableSupport rs = RestorableSupport.newRestorableSupport(); // Creating a new RestorableSupport failed. RestorableSupport logged the problem, so just return null. if (rs == null) { return(null); } this.doGetRestorableState(rs, null); return(rs.getStateAsXml()); }
protected static void wmsRestoreStateToParams(RestorableSupport rs, RestorableSupport.StateObject context, AVList parameters) { // Invoke the BasicTiledImageLayer functionality. restoreStateForParams(rs, context, parameters); // Parse any legacy WMSTiledImageLayer state values. legacyWmsRestoreStateToParams(rs, context, parameters); String s = rs.getStateValueAsString(context, AVKey.IMAGE_FORMAT); if (s != null) { parameters.setValue(AVKey.IMAGE_FORMAT, s); } s = rs.getStateValueAsString(context, AVKey.TITLE); if (s != null) { parameters.setValue(AVKey.TITLE, s); } s = rs.getStateValueAsString(context, AVKey.DISPLAY_NAME); if (s != null) { parameters.setValue(AVKey.DISPLAY_NAME, s); } RestorableSupport.adjustTitleAndDisplayName(params); s = rs.getStateValueAsString(context, AVKey.LAYER_NAMES); if (s != null) { parameters.setValue(AVKey.LAYER_NAMES, s); } s = rs.getStateValueAsString(context, AVKey.STYLE_NAMES); if (s != null) { parameters.setValue(AVKey.STYLE_NAMES, s); } s = rs.getStateValueAsString(context, "wms.Version"); if (s != null) { parameters.setValue(AVKey.WMS_VERSION, s); } parameters.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(parameters)); }
//**************************************************************// //******************** Restorable State ***********************// //**************************************************************// protected void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context) { base.doGetRestorableState(rs, context); if (this.getCenterPosition() != null) { RestorableSupport.StateObject so = rs.addStateObject(context, "center"); if (so != null) { rs.addStateValueAsDouble(so, "latitude", this.getCenterPosition().getLatitude().degrees); rs.addStateValueAsDouble(so, "longitude", this.getCenterPosition().getLongitude().degrees); rs.addStateValueAsDouble(so, "elevation", this.getCenterPosition().getElevation()); } } rs.addStateValueAsDouble(context, "zoom", this.getZoom()); }
public Material restoreState(RestorableSupport rs, RestorableSupport.StateObject so) { double shininess = this.getShininess(); Double d = rs.getStateValueAsDouble(so, "shininess"); if (d != null) { shininess = d; } String as = rs.getStateValueAsString(so, "ambient"); Color ambient = RestorableSupport.decodeColor(as); if (ambient == null) { ambient = this.getAmbient(); } String ds = rs.getStateValueAsString(so, "diffuse"); Color diffuse = RestorableSupport.decodeColor(ds); if (diffuse == null) { diffuse = this.getDiffuse(); } String ss = rs.getStateValueAsString(so, "specular"); Color specular = RestorableSupport.decodeColor(ss); if (specular == null) { specular = this.getSpecular(); } String es = rs.getStateValueAsString(so, "emission"); Color emission = RestorableSupport.decodeColor(es); if (emission == null) { emission = this.getEmission(); } return(new Material(specular, diffuse, ambient, emission, (float)shininess)); }
public WMSBasicElevationModel(String restorableStateInXml) : base(wmsRestorableStateToParams(restorableStateInXml)) { RestorableSupport rs; try { rs = RestorableSupport.parse(restorableStateInXml); } catch (Exception e) { // Parsing the document specified by stateInXml failed. String message = Logging.getMessage("generic.ExceptionAttemptingToParseStateXml", restorableStateInXml); Logging.logger().severe(message); throw new ArgumentException(message, e); } this.doRestoreState(rs, null); }
protected static void wmsRestoreStateForParams(RestorableSupport rs, RestorableSupport.StateObject context, AVList parameters) { // Invoke the BasicElevationModel functionality. restoreStateForParams(rs, null, parameters); String s = rs.getStateValueAsString(context, AVKey.IMAGE_FORMAT); if (s != null) { parameters.setValue(AVKey.IMAGE_FORMAT, s); } s = rs.getStateValueAsString(context, AVKey.TITLE); if (s != null) { parameters.setValue(AVKey.TITLE, s); } s = rs.getStateValueAsString(context, AVKey.DISPLAY_NAME); if (s != null) { parameters.setValue(AVKey.DISPLAY_NAME, s); } RestorableSupport.adjustTitleAndDisplayName(parameters); s = rs.getStateValueAsString(context, AVKey.LAYER_NAMES); if (s != null) { parameters.setValue(AVKey.LAYER_NAMES, s); } s = rs.getStateValueAsString(context, AVKey.STYLE_NAMES); if (s != null) { parameters.setValue(AVKey.STYLE_NAMES, s); } s = rs.getStateValueAsString(context, "wms.Version"); parameters.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(s, parameters)); }
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 ArgumentException(message, e); } this.doRestoreState(rs, null); }
/** * Restores the state of any size parameters contained in the specified <code>RestorableSupport</code>. If the * <code>StateObject</code> is not <code>null</code> it's searched for state values, otherwise the * <code>RestorableSupport</code> root is searched. * * @param restorableSupport the <code>RestorableSupport</code> that contains the size's state. * @param context the <code>StateObject</code> to search for state values, if not <code>null</code>. * * @throws ArgumentException if <code>restorableSupport</code> is <code>null</code>. */ public void restoreState(RestorableSupport restorableSupport, RestorableSupport.StateObject context) { if (restorableSupport == null) { String message = Logging.getMessage("nullValue.RestorableSupportIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } RestorableSupport.StateObject so = restorableSupport.getStateObject(context, "width"); if (so != null) { String mode = restorableSupport.getStateValueAsString(so, "mode"); mode = convertLegacyModeString(mode); Double param = restorableSupport.getStateValueAsDouble(so, "param"); String units = restorableSupport.getStateValueAsString(so, "units"); // Restore the width only when the mode and param are specified. null is an acceptable value for units. if (mode != null && param != null) { this.setWidth(mode, param, units); } } so = restorableSupport.getStateObject(context, "height"); if (so != null) { String mode = restorableSupport.getStateValueAsString(so, "mode"); mode = convertLegacyModeString(mode); Double param = restorableSupport.getStateValueAsDouble(so, "param"); String units = restorableSupport.getStateValueAsString(so, "units"); // Restore the height only when the mode and param are specified. null is an acceptable value for units. if (mode != null && param != null) { this.setHeight(mode, param, units); } } }
public void getRestorableStateForAVPair(string key, object value, RestorableSupport rs, RestorableSupport.StateObject context) { if (value == null) { return; } if (key.Equals(PROPERTY_CHANGE_SUPPORT)) { return; } if (rs == null) { String message = Logging.getMessage("nullValue.RestorableStateIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } rs.addStateValueAsString(context, key, value.ToString()); }
/** {@inheritDoc} */ public void getRestorableState(RestorableSupport rs, RestorableSupport.StateObject so) { if (rs == null) { String message = Logging.getMessage("nullValue.RestorableSupportIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } rs.addStateValueAsBoolean(so, "drawInterior", this.isDrawInterior()); rs.addStateValueAsBoolean(so, "drawOutline", this.isDrawOutline()); rs.addStateValueAsBoolean(so, "enableAntialiasing", this.isEnableAntialiasing()); rs.addStateValueAsBoolean(so, "enableLighting", this.isEnableLighting()); this.getInteriorMaterial().getRestorableState(rs, rs.addStateObject(so, "interiorMaterial")); this.getOutlineMaterial().getRestorableState(rs, rs.addStateObject(so, "outlineMaterial")); rs.addStateValueAsDouble(so, "interiorOpacity", this.getInteriorOpacity()); rs.addStateValueAsDouble(so, "outlineOpacity", this.getOutlineOpacity()); rs.addStateValueAsDouble(so, "outlineWidth", this.getOutlineWidth()); rs.addStateValueAsInteger(so, "outlineStippleFactor", this.getOutlineStippleFactor()); rs.addStateValueAsInteger(so, "outlineStipplePattern", this.getOutlineStipplePattern()); if (this.getImageSource() != null && this.getImageSource() is String) { rs.addStateValueAsString(so, "interiorImagePath", (String)this.getImageSource()); } rs.addStateValueAsDouble(so, "interiorImageScale", this.getImageScale()); }
protected static void legacyWmsRestoreStateToParams(RestorableSupport rs, RestorableSupport.StateObject context, AVList parameters) { // 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) { parameters.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) { parameters.setValue(AVKey.SECTOR, Sector.fromDegrees(minLat, maxLat, minLon, maxLon)); } }
public void restoreState(RestorableSupport rs, RestorableSupport.StateObject context) { Sector sector = rs.getStateValueAsSector(context, "eyeLocationLimits"); if (sector != null) { this.setEyeLocationLimits(sector); } // Min and max center elevation. double[] minAndMaxValue = this.getEyeElevationLimits(); Double min = rs.getStateValueAsDouble(context, "minEyeElevation"); if (min != null) { minAndMaxValue[0] = min; } Double max = rs.getStateValueAsDouble(context, "maxEyeElevation"); if (max != null) { minAndMaxValue[1] = max; } if (min != null || max != null) { this.setEyeElevationLimits(minAndMaxValue[0], minAndMaxValue[1]); } // Min and max heading angle. Angle[] minAndMaxAngle = this.getHeadingLimits(); min = rs.getStateValueAsDouble(context, "minHeadingDegrees"); if (min != null) { minAndMaxAngle[0] = Angle.fromDegrees(min); } max = rs.getStateValueAsDouble(context, "maxHeadingDegrees"); if (max != null) { minAndMaxAngle[1] = Angle.fromDegrees(max); } if (min != null || max != null) { this.setHeadingLimits(minAndMaxAngle[0], minAndMaxAngle[1]); } // Min and max pitch angle. minAndMaxAngle = this.getPitchLimits(); min = rs.getStateValueAsDouble(context, "minPitchDegrees"); if (min != null) { minAndMaxAngle[0] = Angle.fromDegrees(min); } max = rs.getStateValueAsDouble(context, "maxPitchDegrees"); if (max != null) { minAndMaxAngle[1] = Angle.fromDegrees(max); } if (min != null || max != null) { this.setPitchLimits(minAndMaxAngle[0], minAndMaxAngle[1]); } }
/** {@inheritDoc} */ public void restoreState(RestorableSupport rs, RestorableSupport.StateObject so) { if (rs == null) { String message = Logging.getMessage("nullValue.RestorableSupportIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } Boolean b = rs.getStateValueAsBoolean(so, "drawInterior"); if (b != null) { this.setDrawInterior(b); } b = rs.getStateValueAsBoolean(so, "drawOutline"); if (b != null) { this.setDrawOutline(b); } b = rs.getStateValueAsBoolean(so, "enableAntialiasing"); if (b != null) { this.setEnableAntialiasing(b); } b = rs.getStateValueAsBoolean(so, "enableLighting"); if (b != null) { this.setEnableLighting(b); } RestorableSupport.StateObject mo = rs.getStateObject(so, "interiorMaterial"); if (mo != null) { this.setInteriorMaterial(this.getInteriorMaterial().restoreState(rs, mo)); } mo = rs.getStateObject(so, "outlineMaterial"); if (mo != null) { this.setOutlineMaterial(this.getOutlineMaterial().restoreState(rs, mo)); } Double d = rs.getStateValueAsDouble(so, "interiorOpacity"); if (d != null) { this.setInteriorOpacity(d); } d = rs.getStateValueAsDouble(so, "outlineOpacity"); if (d != null) { this.setOutlineOpacity(d); } d = rs.getStateValueAsDouble(so, "outlineWidth"); if (d != null) { this.setOutlineWidth(d); } Integer i = rs.getStateValueAsInteger(so, "outlineStippleFactor"); if (i != null) { this.setOutlineStippleFactor(i); } i = rs.getStateValueAsInteger(so, "outlineStipplePattern"); if (i != null) { this.setOutlineStipplePattern(i.shortValue()); } String s = rs.getStateValueAsString(so, "interiorImagePath"); if (s != null) { this.setImageSource(s); } d = rs.getStateValueAsDouble(so, "interiorImageScale"); if (d != null) { this.setImageScale(d); } }