KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jscience > physics > models > RelativisticModel


1 /*
2  * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
3  * Copyright (C) 2006 - 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.models;
10
11 import javax.measure.converters.RationalConverter;
12 import javax.measure.converters.UnitConverter;
13 import javax.measure.units.BaseUnit;
14 import javax.measure.units.Dimension;
15 import javax.measure.units.SI;
16
17 /**
18  * This class represents the relativistic model.
19  *
20  * @author <a HREF="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
21  * @version 3.1, April 22, 2006
22  */

23 public class RelativisticModel extends PhysicalModel {
24
25     
26     /**
27      * Holds the meter to time transform.
28      */

29     private static RationalConverter METER_TO_TIME
30         = new RationalConverter(1, 299792458);
31     
32     /**
33      * Holds the single instance of this class.
34      */

35     private final static RelativisticModel INSTANCE = new RelativisticModel();
36
37     /**
38      * Selects the relativistic model as the current model.
39      */

40     public static void select() {
41         PhysicalModel.setCurrent(INSTANCE);
42     }
43
44     // Implements Dimension.Model
45
public Dimension getDimension(BaseUnit unit) {
46         if (unit.equals(SI.METER)) return Dimension.TIME;
47         return Dimension.Model.STANDARD.getDimension(unit);
48     }
49
50     // Implements Dimension.Model
51
public UnitConverter getTransform(BaseUnit unit) {
52         if (unit.equals(SI.METER)) return METER_TO_TIME;
53         return Dimension.Model.STANDARD.getTransform(unit);
54     }
55 }
Popular Tags