summaryrefslogtreecommitdiff
path: root/altoslib/AltosDistance.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-09-10 09:14:03 -0700
committerKeith Packard <keithp@keithp.com>2012-09-10 09:14:03 -0700
commit66a1e07efcac9324d33a1eca0dfb58a2724b667a (patch)
tree83b87bb910dc906e65f739499ae6f8e1d44e6d4f /altoslib/AltosDistance.java
parent51836cedce41d8b36eac34c69370489162aaa2b5 (diff)
altoslib: Add imperial units conversion support
"Redneck" mode support Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosDistance.java')
-rw-r--r--altoslib/AltosDistance.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/altoslib/AltosDistance.java b/altoslib/AltosDistance.java
new file mode 100644
index 00000000..a5e7331c
--- /dev/null
+++ b/altoslib/AltosDistance.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+public class AltosDistance extends AltosUnits {
+
+ public double value(double v) {
+ if (AltosConvert.imperial_units)
+ return AltosConvert.meters_to_miles(v);
+ return v;
+ }
+
+ public String show_units() {
+ if (AltosConvert.imperial_units)
+ return "miles";
+ return "m";
+ }
+
+ public String say_units() {
+ if (AltosConvert.imperial_units)
+ return "miles";
+ return "meters";
+ }
+
+ int show_fraction(int width) {
+ if (AltosConvert.imperial_units)
+ return width / 3;
+ return width / 9;
+ }
+
+ int say_fraction() {
+ return 1;
+ }
+} \ No newline at end of file