protected void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context) { // Invoke the legacy restore functionality. This will enable the shape to recognize state XML elements // from previous versions of BasicOrbitView. this.legacyRestoreState(rs, context); base.doRestoreState(rs, context); // Restore the center property only if all parts are available. // We will not restore a partial center (for example, just latitude). RestorableSupport.StateObject so = rs.getStateObject(context, "center"); if (so != null) { Double lat = rs.getStateValueAsDouble(so, "latitude"); Double lon = rs.getStateValueAsDouble(so, "longitude"); Double ele = rs.getStateValueAsDouble(so, "elevation"); if (lat != null && lon != null) { this.setCenterPosition(Position.fromDegrees(lat, lon, (ele != null ? ele : 0))); } } Double d = rs.getStateValueAsDouble(context, "zoom"); if (d != null) { this.setZoom(d); } }
/** * Restores state values from previous versions of the BasicObitView state XML. These values are stored or named * differently than the current implementation. Those values which have not changed are ignored here, and are * restored in {@link #doRestoreState(gov.nasa.worldwind.util.RestorableSupport, * SharpEarth.util.RestorableSupport.StateObject)}. * * @param rs RestorableSupport object which contains the state value properties. * @param context active context in the RestorableSupport to read state from. */ protected void legacyRestoreState(RestorableSupport rs, RestorableSupport.StateObject context) { RestorableSupport.StateObject so = rs.getStateObject(context, "orbitViewLimits"); if (so != null) { this.getViewPropertyLimits().restoreState(rs, so); } }
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)); } }
/** * 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); } } }
/** {@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); } }