diff options
author | Keith Packard <keithp@keithp.com> | 2016-06-15 22:40:27 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2016-06-15 22:40:27 -0700 |
commit | 1b5ea911049a8afae6af475a4a2bf62a6e3aa57b (patch) | |
tree | 7f896e587da5e7911b7b5a42aade1b7692670200 /altoslib/AltosRotation.java | |
parent | 1de8b6c340cec0b5a327392686c5a4e00f201e98 (diff) |
altoslib: Switch preserved state format to JSON
This is much easier to debug than the icky strings with backslashes everywhere.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosRotation.java')
-rw-r--r-- | altoslib/AltosRotation.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/altoslib/AltosRotation.java b/altoslib/AltosRotation.java index e9c447ad..4b7ab407 100644 --- a/altoslib/AltosRotation.java +++ b/altoslib/AltosRotation.java @@ -17,7 +17,7 @@ package org.altusmetrum.altoslib_11; -public class AltosRotation implements AltosHashable { +public class AltosRotation implements AltosHashable, AltosJsonable { private AltosQuaternion rotation; public double tilt() { @@ -55,6 +55,10 @@ public class AltosRotation implements AltosHashable { return h; } + public AltosJson json() { + return rotation.json(); + } + public AltosRotation(AltosHashSet h) { rotation = new AltosQuaternion(h.getHash("rotation")); } @@ -65,4 +69,15 @@ public class AltosRotation implements AltosHashable { return new AltosRotation(h); } + + public AltosRotation(AltosJson j) { + rotation = new AltosQuaternion(j); + } + + public static AltosRotation fromJson(AltosJson j, AltosRotation def) { + if (j == null) + return def; + + return new AltosRotation(j); + } } |