001/*
002 * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
003 * Copyright (C) 2006 - JScience (http://jscience.org/)
004 * All rights reserved.
005 * 
006 * Permission to use, copy, modify, and distribute this software is
007 * freely granted, provided that this notice is preserved.
008 */
009package org.jscience.physics.model;
010
011import javax.measure.converter.RationalConverter;
012import javax.measure.converter.UnitConverter;
013import javax.measure.unit.BaseUnit;
014import javax.measure.unit.Dimension;
015import javax.measure.unit.SI;
016
017/**
018 * This class represents the relativistic model.
019 *
020 * @author  <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
021 * @version 3.1, April 22, 2006
022 */
023public class RelativisticModel extends PhysicalModel {
024
025    
026    /**
027     * Holds the meter to time transform.
028     */
029    private static RationalConverter METRE_TO_TIME 
030        = new RationalConverter(1, 299792458);
031    
032    /**
033     * Holds the single instance of this class.
034     */
035    private final static RelativisticModel INSTANCE = new RelativisticModel();
036
037    /**
038     * Selects the relativistic model as the current model.
039     */
040    public static void select() {
041        PhysicalModel.setCurrent(INSTANCE);
042    }
043
044    // Implements Dimension.Model
045    public Dimension getDimension(BaseUnit<?> unit) {
046        if (unit.equals(SI.METRE)) return Dimension.TIME;
047        return Dimension.Model.STANDARD.getDimension(unit);
048    }
049
050    // Implements Dimension.Model
051    public UnitConverter getTransform(BaseUnit<?> unit) {
052        if (unit.equals(SI.METRE)) return METRE_TO_TIME;
053        return Dimension.Model.STANDARD.getTransform(unit);
054    }
055}