01: /*
02: * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
03: * Copyright (C) 2006 - JScience (http://jscience.org/)
04: * All rights reserved.
05: *
06: * Permission to use, copy, modify, and distribute this software is
07: * freely granted, provided that this notice is preserved.
08: */
09: package org.jscience.physics.model;
10:
11: import javax.measure.converter.RationalConverter;
12: import javax.measure.converter.UnitConverter;
13: import javax.measure.unit.BaseUnit;
14: import javax.measure.unit.Dimension;
15: import javax.measure.unit.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: * Holds the meter to time transform.
27: */
28: private static RationalConverter METRE_TO_TIME = new RationalConverter(
29: 1, 299792458);
30:
31: /**
32: * Holds the single instance of this class.
33: */
34: private final static RelativisticModel INSTANCE = new RelativisticModel();
35:
36: /**
37: * Selects the relativistic model as the current model.
38: */
39: public static void select() {
40: PhysicalModel.setCurrent(INSTANCE);
41: }
42:
43: // Implements Dimension.Model
44: public Dimension getDimension(BaseUnit<?> unit) {
45: if (unit.equals(SI.METRE))
46: 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.METRE))
53: return METRE_TO_TIME;
54: return Dimension.Model.STANDARD.getTransform(unit);
55: }
56: }
|