KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jscience > physics > quantities > Length


1 /*
2  * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
3  * Copyright (C) 2005 - JScience (http://jscience.org/)
4  * All rights reserved.
5  *
6  * Permission to use, copy, modify, and distribute this software is
7  * freely granted, provided that this notice is preserved.
8  */

9 package org.jscience.physics.quantities;
10
11 import org.jscience.physics.units.SI;
12 import org.jscience.physics.units.Unit;
13
14 /**
15  * This class represents the extent of something along its greatest dimension
16  * or the extent of space between two objects or places. The system unit for
17  * this quantity is "m" (Système International d'Unités).
18  *
19  * @author <a HREF="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
20  * @version 1.0, October 24, 2004
21  */

22 public class Length extends Quantity {
23
24     /**
25      * Holds the associated unit.
26      */

27     private final static Unit<Length> UNIT = SI.METER;
28
29     /**
30      * Holds the factory for this class.
31      */

32     private final static Factory<Length> FACTORY = new Factory<Length>(UNIT) {
33         protected Length create() {
34             return new Length();
35         }
36     };
37
38     /**
39      * Represents a {@link Length} amounting to nothing.
40      */

41     public final static Length ZERO = Quantity.valueOf(0, UNIT);
42
43     /**
44      * Default constructor (allows for derivation).
45      */

46     protected Length() {
47     }
48
49     /**
50      * Shows {@link Length} instances in the specified unit.
51      *
52      * @param unit the display unit for {@link Length} instances.
53      */

54     public static void showAs(Unit unit) {
55         QuantityFormat.show(Length.class, unit);
56     }
57
58     /////////////////////
59
// LENGTH SPECIFIC //
60
/////////////////////
61

62     /**
63      * Returns the length of a circular arc.
64      *
65      * @param radius the circle radius.
66      * @param theta the central angle.
67      * @return the length of the specified circular arc.
68      */

69     public static Length valueOf(Length radius, Angle theta) {
70         return theta.times(radius).to(UNIT);
71     }
72
73     private static final long serialVersionUID = 1L;
74 }
75
Popular Tags