diff options
Diffstat (limited to 'altoslib')
| -rw-r--r-- | altoslib/AltosConvert.java | 6 | ||||
| -rw-r--r-- | altoslib/AltosHeight.java | 2 | ||||
| -rw-r--r-- | altoslib/AltosTemperature.java | 43 | ||||
| -rw-r--r-- | altoslib/AltosUnits.java | 2 | ||||
| -rw-r--r-- | altoslib/Makefile.am | 1 | 
5 files changed, 52 insertions, 2 deletions
diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 8adec068..a42b36c4 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -258,6 +258,10 @@ public class AltosConvert {  		return meters / 9.80665;  	} +	public static double c_to_f(double c) { +		return c * 9/5 + 32; +	} +  	public static boolean imperial_units = false;  	public static AltosDistance distance = new AltosDistance(); @@ -268,6 +272,8 @@ public class AltosConvert {  	public static AltosAccel accel = new AltosAccel(); +	public static AltosTemperature temperature = new AltosTemperature(); +  	public static String show_gs(String format, double a) {  		a = meters_to_g(a);  		format = format.concat(" g"); diff --git a/altoslib/AltosHeight.java b/altoslib/AltosHeight.java index e0fef5f6..ed590812 100644 --- a/altoslib/AltosHeight.java +++ b/altoslib/AltosHeight.java @@ -37,7 +37,7 @@ public class AltosHeight extends AltosUnits {  		return "meters";  	} -	int show_fraction(int width) { +	public int show_fraction(int width) {  		return width / 9;  	}  }
\ No newline at end of file diff --git a/altoslib/AltosTemperature.java b/altoslib/AltosTemperature.java new file mode 100644 index 00000000..2749eac0 --- /dev/null +++ b/altoslib/AltosTemperature.java @@ -0,0 +1,43 @@ +/* + * 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_1; + +public class AltosTemperature extends AltosUnits { + +	public double value(double v) { +		if (AltosConvert.imperial_units) +			return AltosConvert.c_to_f(v); +		return v; +	} + +	public String show_units() { +		if (AltosConvert.imperial_units) +			return "°F"; +		return "°C"; +	} + +	public String say_units() { +		if (AltosConvert.imperial_units) +			return "degrees farenheit"; +		return "degrees celsius"; +	} + +	public int show_fraction(int width) { +		return width / 3; +	} +} diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index 4f4278b8..b8b3254c 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -25,7 +25,7 @@ public abstract class AltosUnits {  	public abstract String say_units(); -	abstract int show_fraction(int width); +	public abstract int show_fraction(int width);  	int say_fraction() {  		return 0; diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 74c642d6..8e5701ad 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -78,6 +78,7 @@ altoslib_JAVA = \  	AltosDistance.java \  	AltosHeight.java \  	AltosSpeed.java \ +	AltosTemperature.java \  	AltosAccel.java \  	AltosPyro.java  | 
