Advertisement
Guest User

JUCL - Android

a guest
Jan 8th, 2013
710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 15.39 KB | None | 0 0
  1.  
  2. /**
  3.  * Java Unit Conversion  Library (jucl)
  4.  * Copyright (c) 2000-2003 jucl team
  5.  *
  6.  * jucl is free software; you can distribute itself under the
  7.  * terms of the BSD-style license received along with the jucl
  8.  * distribution.
  9.  */
  10.  
  11. /**
  12.  * Utility class containing class operations for converting
  13.  * between SI (or SI derived standard units) and other known
  14.  * units of Length.
  15.  *
  16.  * <br>Note that this class is machine generated, using conversion factors
  17.  * from a text file (in standard Properties format).
  18.  *
  19.  * @author Dieter Wimberger
  20.  * @version 1.0
  21.  */
  22. public class LengthConversions {
  23.  
  24.   /**
  25.    * Utility method converting a double value
  26.    * from cm to the SI or SI derived unit.
  27.    *
  28.    * @param d double value to be converted.
  29.    * @return double containing the converted value.
  30.    */
  31.   public static final double cm2SI(double d) {
  32.     return d*SI_CM;
  33.   }//cm2SI
  34.  
  35.  
  36.   /**
  37.    * Utility method converting a double value
  38.    * from SI or SI derived to cm.
  39.    *
  40.    * @param d double value to be converted.
  41.    * @return double containing the converted value.
  42.    */
  43.   public static final double SI2cm(double d) {
  44.     return d/SI_CM;
  45.   }//SI2cm
  46.  
  47.  
  48.   /**
  49.    * Utility method converting an array of double values
  50.    * from cm to the SI or SI derived unit.
  51.    * <br>Note that the array passed in as parameter is the target.
  52.    * The reference to this array is only returned for convenience reasons.
  53.    *
  54.    * @param da Array of double values to be converted.
  55.    * @return Reference to the same array now containing converted values.
  56.    */
  57.   public static final double[] cm2SI(double[] da) {
  58.     for (int n = 0; n < da.length; n++) {
  59.       da[n] *= SI_CM;
  60.     }
  61.     return da;
  62.   }//cm2SI
  63.  
  64.  
  65.   /**
  66.    * Utility method converting an array of double values
  67.    * from SI or SI derived to cm.
  68.    * <br>Note that the array passed in as parameter is the target.
  69.    * The reference to this array is only returned for convenience reasons.
  70.    *
  71.    * @param da Array of double values to be converted.
  72.    * @return Reference to the same array now containing converted values.
  73.    */
  74.   public static final double[] SI2cm(double[] da) {
  75.     for (int n = 0; n < da.length; n++) {
  76.       da[n] /= SI_CM;
  77.     }
  78.     return da;
  79.   }//SI2cm
  80.  
  81.  
  82.   /**
  83.    * Utility method converting a double value
  84.    * from in to the SI or SI derived unit.
  85.    *
  86.    * @param d double value to be converted.
  87.    * @return double containing the converted value.
  88.    */
  89.   public static final double in2SI(double d) {
  90.     return d*SI_IN;
  91.   }//in2SI
  92.  
  93.  
  94.   /**
  95.    * Utility method converting a double value
  96.    * from SI or SI derived to in.
  97.    *
  98.    * @param d double value to be converted.
  99.    * @return double containing the converted value.
  100.    */
  101.   public static final double SI2in(double d) {
  102.     return d/SI_IN;
  103.   }//SI2in
  104.  
  105.  
  106.   /**
  107.    * Utility method converting an array of double values
  108.    * from in to the SI or SI derived unit.
  109.    * <br>Note that the array passed in as parameter is the target.
  110.    * The reference to this array is only returned for convenience reasons.
  111.    *
  112.    * @param da Array of double values to be converted.
  113.    * @return Reference to the same array now containing converted values.
  114.    */
  115.   public static final double[] in2SI(double[] da) {
  116.     for (int n = 0; n < da.length; n++) {
  117.       da[n] *= SI_IN;
  118.     }
  119.     return da;
  120.   }//in2SI
  121.  
  122.  
  123.   /**
  124.    * Utility method converting an array of double values
  125.    * from SI or SI derived to in.
  126.    * <br>Note that the array passed in as parameter is the target.
  127.    * The reference to this array is only returned for convenience reasons.
  128.    *
  129.    * @param da Array of double values to be converted.
  130.    * @return Reference to the same array now containing converted values.
  131.    */
  132.   public static final double[] SI2in(double[] da) {
  133.     for (int n = 0; n < da.length; n++) {
  134.       da[n] /= SI_IN;
  135.     }
  136.     return da;
  137.   }//SI2in
  138.  
  139.  
  140.   /**
  141.    * Utility method converting a double value
  142.    * from nautmile to the SI or SI derived unit.
  143.    *
  144.    * @param d double value to be converted.
  145.    * @return double containing the converted value.
  146.    */
  147.   public static final double nautmile2SI(double d) {
  148.     return d*SI_NAUTMILE;
  149.   }//nautmile2SI
  150.  
  151.  
  152.   /**
  153.    * Utility method converting a double value
  154.    * from SI or SI derived to nautmile.
  155.    *
  156.    * @param d double value to be converted.
  157.    * @return double containing the converted value.
  158.    */
  159.   public static final double SI2nautmile(double d) {
  160.     return d/SI_NAUTMILE;
  161.   }//SI2nautmile
  162.  
  163.  
  164.   /**
  165.    * Utility method converting an array of double values
  166.    * from nautmile to the SI or SI derived unit.
  167.    * <br>Note that the array passed in as parameter is the target.
  168.    * The reference to this array is only returned for convenience reasons.
  169.    *
  170.    * @param da Array of double values to be converted.
  171.    * @return Reference to the same array now containing converted values.
  172.    */
  173.   public static final double[] nautmile2SI(double[] da) {
  174.     for (int n = 0; n < da.length; n++) {
  175.       da[n] *= SI_NAUTMILE;
  176.     }
  177.     return da;
  178.   }//nautmile2SI
  179.  
  180.  
  181.   /**
  182.    * Utility method converting an array of double values
  183.    * from SI or SI derived to nautmile.
  184.    * <br>Note that the array passed in as parameter is the target.
  185.    * The reference to this array is only returned for convenience reasons.
  186.    *
  187.    * @param da Array of double values to be converted.
  188.    * @return Reference to the same array now containing converted values.
  189.    */
  190.   public static final double[] SI2nautmile(double[] da) {
  191.     for (int n = 0; n < da.length; n++) {
  192.       da[n] /= SI_NAUTMILE;
  193.     }
  194.     return da;
  195.   }//SI2nautmile
  196.  
  197.  
  198.   /**
  199.    * Utility method converting a double value
  200.    * from km to the SI or SI derived unit.
  201.    *
  202.    * @param d double value to be converted.
  203.    * @return double containing the converted value.
  204.    */
  205.   public static final double km2SI(double d) {
  206.     return d*SI_KM;
  207.   }//km2SI
  208.  
  209.  
  210.   /**
  211.    * Utility method converting a double value
  212.    * from SI or SI derived to km.
  213.    *
  214.    * @param d double value to be converted.
  215.    * @return double containing the converted value.
  216.    */
  217.   public static final double SI2km(double d) {
  218.     return d/SI_KM;
  219.   }//SI2km
  220.  
  221.  
  222.   /**
  223.    * Utility method converting an array of double values
  224.    * from km to the SI or SI derived unit.
  225.    * <br>Note that the array passed in as parameter is the target.
  226.    * The reference to this array is only returned for convenience reasons.
  227.    *
  228.    * @param da Array of double values to be converted.
  229.    * @return Reference to the same array now containing converted values.
  230.    */
  231.   public static final double[] km2SI(double[] da) {
  232.     for (int n = 0; n < da.length; n++) {
  233.       da[n] *= SI_KM;
  234.     }
  235.     return da;
  236.   }//km2SI
  237.  
  238.  
  239.   /**
  240.    * Utility method converting an array of double values
  241.    * from SI or SI derived to km.
  242.    * <br>Note that the array passed in as parameter is the target.
  243.    * The reference to this array is only returned for convenience reasons.
  244.    *
  245.    * @param da Array of double values to be converted.
  246.    * @return Reference to the same array now containing converted values.
  247.    */
  248.   public static final double[] SI2km(double[] da) {
  249.     for (int n = 0; n < da.length; n++) {
  250.       da[n] /= SI_KM;
  251.     }
  252.     return da;
  253.   }//SI2km
  254.  
  255.  
  256.   /**
  257.    * Utility method converting a double value
  258.    * from mile to the SI or SI derived unit.
  259.    *
  260.    * @param d double value to be converted.
  261.    * @return double containing the converted value.
  262.    */
  263.   public static final double mile2SI(double d) {
  264.     return d*SI_MILE;
  265.   }//mile2SI
  266.  
  267.  
  268.   /**
  269.    * Utility method converting a double value
  270.    * from SI or SI derived to mile.
  271.    *
  272.    * @param d double value to be converted.
  273.    * @return double containing the converted value.
  274.    */
  275.   public static final double SI2mile(double d) {
  276.     return d/SI_MILE;
  277.   }//SI2mile
  278.  
  279.  
  280.   /**
  281.    * Utility method converting an array of double values
  282.    * from mile to the SI or SI derived unit.
  283.    * <br>Note that the array passed in as parameter is the target.
  284.    * The reference to this array is only returned for convenience reasons.
  285.    *
  286.    * @param da Array of double values to be converted.
  287.    * @return Reference to the same array now containing converted values.
  288.    */
  289.   public static final double[] mile2SI(double[] da) {
  290.     for (int n = 0; n < da.length; n++) {
  291.       da[n] *= SI_MILE;
  292.     }
  293.     return da;
  294.   }//mile2SI
  295.  
  296.  
  297.   /**
  298.    * Utility method converting an array of double values
  299.    * from SI or SI derived to mile.
  300.    * <br>Note that the array passed in as parameter is the target.
  301.    * The reference to this array is only returned for convenience reasons.
  302.    *
  303.    * @param da Array of double values to be converted.
  304.    * @return Reference to the same array now containing converted values.
  305.    */
  306.   public static final double[] SI2mile(double[] da) {
  307.     for (int n = 0; n < da.length; n++) {
  308.       da[n] /= SI_MILE;
  309.     }
  310.     return da;
  311.   }//SI2mile
  312.  
  313.  
  314.   /**
  315.    * Utility method converting a double value
  316.    * from one32in to the SI or SI derived unit.
  317.    *
  318.    * @param d double value to be converted.
  319.    * @return double containing the converted value.
  320.    */
  321.   public static final double one32in2SI(double d) {
  322.     return d*SI_ONE32IN;
  323.   }//one32in2SI
  324.  
  325.  
  326.   /**
  327.    * Utility method converting a double value
  328.    * from SI or SI derived to one32in.
  329.    *
  330.    * @param d double value to be converted.
  331.    * @return double containing the converted value.
  332.    */
  333.   public static final double SI2one32in(double d) {
  334.     return d/SI_ONE32IN;
  335.   }//SI2one32in
  336.  
  337.  
  338.   /**
  339.    * Utility method converting an array of double values
  340.    * from one32in to the SI or SI derived unit.
  341.    * <br>Note that the array passed in as parameter is the target.
  342.    * The reference to this array is only returned for convenience reasons.
  343.    *
  344.    * @param da Array of double values to be converted.
  345.    * @return Reference to the same array now containing converted values.
  346.    */
  347.   public static final double[] one32in2SI(double[] da) {
  348.     for (int n = 0; n < da.length; n++) {
  349.       da[n] *= SI_ONE32IN;
  350.     }
  351.     return da;
  352.   }//one32in2SI
  353.  
  354.  
  355.   /**
  356.    * Utility method converting an array of double values
  357.    * from SI or SI derived to one32in.
  358.    * <br>Note that the array passed in as parameter is the target.
  359.    * The reference to this array is only returned for convenience reasons.
  360.    *
  361.    * @param da Array of double values to be converted.
  362.    * @return Reference to the same array now containing converted values.
  363.    */
  364.   public static final double[] SI2one32in(double[] da) {
  365.     for (int n = 0; n < da.length; n++) {
  366.       da[n] /= SI_ONE32IN;
  367.     }
  368.     return da;
  369.   }//SI2one32in
  370.  
  371.  
  372.   /**
  373.    * Utility method converting a double value
  374.    * from mm to the SI or SI derived unit.
  375.    *
  376.    * @param d double value to be converted.
  377.    * @return double containing the converted value.
  378.    */
  379.   public static final double mm2SI(double d) {
  380.     return d*SI_MM;
  381.   }//mm2SI
  382.  
  383.  
  384.   /**
  385.    * Utility method converting a double value
  386.    * from SI or SI derived to mm.
  387.    *
  388.    * @param d double value to be converted.
  389.    * @return double containing the converted value.
  390.    */
  391.   public static final double SI2mm(double d) {
  392.     return d/SI_MM;
  393.   }//SI2mm
  394.  
  395.  
  396.   /**
  397.    * Utility method converting an array of double values
  398.    * from mm to the SI or SI derived unit.
  399.    * <br>Note that the array passed in as parameter is the target.
  400.    * The reference to this array is only returned for convenience reasons.
  401.    *
  402.    * @param da Array of double values to be converted.
  403.    * @return Reference to the same array now containing converted values.
  404.    */
  405.   public static final double[] mm2SI(double[] da) {
  406.     for (int n = 0; n < da.length; n++) {
  407.       da[n] *= SI_MM;
  408.     }
  409.     return da;
  410.   }//mm2SI
  411.  
  412.  
  413.   /**
  414.    * Utility method converting an array of double values
  415.    * from SI or SI derived to mm.
  416.    * <br>Note that the array passed in as parameter is the target.
  417.    * The reference to this array is only returned for convenience reasons.
  418.    *
  419.    * @param da Array of double values to be converted.
  420.    * @return Reference to the same array now containing converted values.
  421.    */
  422.   public static final double[] SI2mm(double[] da) {
  423.     for (int n = 0; n < da.length; n++) {
  424.       da[n] /= SI_MM;
  425.     }
  426.     return da;
  427.   }//SI2mm
  428.  
  429.  
  430.   /**
  431.    * Utility method converting a double value
  432.    * from ft to the SI or SI derived unit.
  433.    *
  434.    * @param d double value to be converted.
  435.    * @return double containing the converted value.
  436.    */
  437.   public static final double ft2SI(double d) {
  438.     return d*SI_FT;
  439.   }//ft2SI
  440.  
  441.  
  442.   /**
  443.    * Utility method converting a double value
  444.    * from SI or SI derived to ft.
  445.    *
  446.    * @param d double value to be converted.
  447.    * @return double containing the converted value.
  448.    */
  449.   public static final double SI2ft(double d) {
  450.     return d/SI_FT;
  451.   }//SI2ft
  452.  
  453.  
  454.   /**
  455.    * Utility method converting an array of double values
  456.    * from ft to the SI or SI derived unit.
  457.    * <br>Note that the array passed in as parameter is the target.
  458.    * The reference to this array is only returned for convenience reasons.
  459.    *
  460.    * @param da Array of double values to be converted.
  461.    * @return Reference to the same array now containing converted values.
  462.    */
  463.   public static final double[] ft2SI(double[] da) {
  464.     for (int n = 0; n < da.length; n++) {
  465.       da[n] *= SI_FT;
  466.     }
  467.     return da;
  468.   }//ft2SI
  469.  
  470.  
  471.   /**
  472.    * Utility method converting an array of double values
  473.    * from SI or SI derived to ft.
  474.    * <br>Note that the array passed in as parameter is the target.
  475.    * The reference to this array is only returned for convenience reasons.
  476.    *
  477.    * @param da Array of double values to be converted.
  478.    * @return Reference to the same array now containing converted values.
  479.    */
  480.   public static final double[] SI2ft(double[] da) {
  481.     for (int n = 0; n < da.length; n++) {
  482.       da[n] /= SI_FT;
  483.     }
  484.     return da;
  485.   }//SI2ft
  486.  
  487. //  public static final double dpi722SI(double d) {
  488. //    return d * SI_IN * DPI72_IN;
  489. //  }
  490.  
  491. //  public static final double SI2dpi72(double d) {
  492. //    return d/(SI_IN / DPI72_SI);
  493. //  }
  494.  
  495. //  public static final float SI2dpi72f(double d) {
  496. //    return (float) ((float) (d/SI_IN) / DPI72_IN);
  497. //  }
  498. //  
  499.   public static final float Pixel2SIf(float pixels) {
  500.       return (float) ((float) pixels * SI_PIXEL);
  501.   }
  502.  
  503.   public static final float SI2Pixelf(float si) {
  504.       return (float) (si/SI_PIXEL);
  505.   }
  506.  
  507.  
  508.  
  509.   /**
  510.    *  Constant conversion factor
  511.    */
  512.    public static final double SI_CM=0.01;
  513.   /**
  514.    *  Constant conversion factor
  515.    */
  516.    public static final double SI_IN=0.0254;
  517.   /**
  518.    *  Constant conversion factor
  519.    */
  520.    public static final double SI_NAUTMILE=1852;
  521.   /**
  522.    *  Constant conversion factor
  523.    */
  524.  
  525.    public static final double SI_KM=1000;
  526.   /**
  527.    *  Constant conversion factor
  528.    */
  529.    public static final double SI_MILE=1609.344;
  530.    
  531.    //public static final double DPI72_IN = 0.0138888;
  532.   /**
  533.    *  Constant conversion factor
  534.    */
  535.    public static final double SI_ONE32IN=0.00079375;
  536.   /**
  537.    *  Constant conversion factor
  538.    */
  539.    public static final double SI_MM=0.001;
  540.   /**
  541.    *  Constant conversion factor
  542.    */
  543.    public static final double SI_FT=0.3048;
  544.  
  545.    public static final double SI_PIXEL = 0.0333;
  546.    
  547.    //public static final double DPI72_SI = DPI72_IN * SI_IN;
  548.    
  549.  }//class LengthConversions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement