X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosMag.java;h=c350ae46392f4ddd637b58fe8f34c0c825a9faf1;hp=3e82f49911299c69b568711630232f781d575303;hb=b1a90adac9f6e2a609ce1ccd6749462bb5c9adbe;hpb=b13037fad0905c5933d1ff579122ba1357b02eea diff --git a/altoslib/AltosMag.java b/altoslib/AltosMag.java index 3e82f499..c350ae46 100644 --- a/altoslib/AltosMag.java +++ b/altoslib/AltosMag.java @@ -20,12 +20,12 @@ package org.altusmetrum.altoslib_11; import java.util.concurrent.*; import java.io.*; -public class AltosMag implements Cloneable, Serializable { +public class AltosMag implements Cloneable, AltosHashable { public int along; public int across; public int through; - public static double counts_per_gauss = 1090; + public static final double counts_per_gauss = 1090; public static double convert_gauss(double counts) { return counts / counts_per_gauss; @@ -93,4 +93,28 @@ public class AltosMag implements Cloneable, Serializable { break; } } + + public AltosHashSet hashSet() { + AltosHashSet h = new AltosHashSet(); + + h.putInt("along", along); + h.putInt("across", across); + h.putInt("through", through); + return h; + } + + public AltosMag(AltosHashSet h) { + this(); + + along = h.getInt("along", along); + across = h.getInt("across", across); + through = h.getInt("through", through); + } + + public static AltosMag fromHashSet(AltosHashSet h, AltosMag def) { + if (h == null) + return def; + + return new AltosMag(h); + } }