From 1b5ea911049a8afae6af475a4a2bf62a6e3aa57b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 15 Jun 2016 22:40:27 -0700 Subject: 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 --- altoslib/AltosRotation.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'altoslib/AltosRotation.java') 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); + } } -- cgit v1.2.3