Merge commit '42b2e5ca519766e37ce6941ba4faecc9691cc403' into upstream
[debian/openrocket] / core / src / net / sf / openrocket / gui / print / PrintUnit.java
index c603f2f970c3dd4520bff50b99d5d7c8f7382d2a..734e433bd3c6e8bfd84a6edaf90e97cc4bbe335a 100644 (file)
@@ -7,12 +7,20 @@ package net.sf.openrocket.gui.print;
  * Utilities for print units.
  */
 public enum PrintUnit {
+    FOOT {
+        public double toInches(double d) { return d*12; }
+        public double toMillis(double d) { return d/FEET_PER_MM; }
+        public double toCentis(double d) { return d/(FEET_PER_MM*TEN); }
+        public double toMeters(double d) { return d/(FEET_PER_MM*TEN*TEN*TEN); }
+        public double toPoints(double d) { return (d * POINTS_PER_INCH * 12); }
+        public double convert(double d, PrintUnit u) { return u.toInches(d)/12; }
+    },
     INCHES {
         public double toInches(double d) { return d; }
         public double toMillis(double d) { return d/INCHES_PER_MM; }
         public double toCentis(double d) { return d/(INCHES_PER_MM*TEN); }
         public double toMeters(double d) { return d/(INCHES_PER_MM*TEN*TEN*TEN); }
-        public long   toPoints(double d) { return (long)(d * POINTS_PER_INCH); }
+        public double toPoints(double d) { return (d * POINTS_PER_INCH); }
         public double convert(double d, PrintUnit u) { return u.toInches(d); }
     },
     MILLIMETERS {
@@ -20,7 +28,7 @@ public enum PrintUnit {
         public double toMillis(double d) { return d; }
         public double toCentis(double d) { return d/TEN; }
         public double toMeters(double d) { return d/(TEN*TEN*TEN); }
-        public long   toPoints(double d) { return INCHES.toPoints(toInches(d)); }
+        public double toPoints(double d) { return INCHES.toPoints(toInches(d)); }
         public double convert(double d, PrintUnit u) { return u.toMillis(d); }
     },
     CENTIMETERS {
@@ -28,7 +36,7 @@ public enum PrintUnit {
         public double toMillis(double d) { return d * TEN; }
         public double toCentis(double d) { return d; }
         public double toMeters(double d) { return d/(TEN*TEN); }
-        public long   toPoints(double d) { return INCHES.toPoints(toInches(d)); }
+        public double toPoints(double d) { return INCHES.toPoints(toInches(d)); }
         public double convert(double d, PrintUnit u) { return u.toCentis(d); }
     },
     METERS {
@@ -36,7 +44,7 @@ public enum PrintUnit {
         public double toMillis(double d) { return d * TEN * TEN * TEN; }
         public double toCentis(double d) { return d * TEN * TEN; }
         public double toMeters(double d) { return d; }
-        public long   toPoints(double d) { return INCHES.toPoints(toInches(d)); }
+        public double toPoints(double d) { return INCHES.toPoints(toInches(d)); }
         public double convert(double d, PrintUnit u) { return u.toMeters(d); }
     },
     POINTS {
@@ -44,19 +52,20 @@ public enum PrintUnit {
         public double toMillis(double d) { return d/(POINTS_PER_INCH * INCHES_PER_MM); }
         public double toCentis(double d) { return toMillis(d)/TEN; }
         public double toMeters(double d) { return toMillis(d)/(TEN*TEN*TEN); }
-        public long   toPoints(double d) { return (long)d; }
+        public double toPoints(double d) { return d; }
         public double convert(double d, PrintUnit u) { return u.toPoints(d); }
     };
 
     // Handy constants for conversion methods
     public static final double INCHES_PER_MM = 0.0393700787d;
+    public static final double FEET_PER_MM = INCHES_PER_MM /12;
     public static final double MM_PER_INCH = 1.0d/INCHES_PER_MM;
     public static final long TEN = 10;
     /**
      * PPI is Postscript Point and is a standard of 72.  Java2D also uses this internally as a pixel-per-inch, so pixels
      * and points are for the most part interchangeable (unless the defaults are changed), which makes translating
      * between the screen and a print job easier.
-     * 
+     *
      * Not to be confused with Dots-Per-Inch, which is printer and print mode dependent.
      */
     public static final int POINTS_PER_INCH = 72;
@@ -151,7 +160,7 @@ public enum PrintUnit {
      * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
      * @see #convert
      */
-    public long toPoints(double length) {
+    public double toPoints(double length) {
         throw new AbstractMethodError();
     }