Package factories

Source Code of factories.Accelerations$Get3D

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package factories;

import graphics.common.Acceleration;
import graphics.common.Acceleration2D;
import graphics.common.Acceleration3D;
import utils.GlobalData;

/**
*
* @author frozen
*/
public class Accelerations {

    private static AccelGet[] getters;

    public Accelerations() {
        getters = new AccelGet[] { new Get2D(), new Get3D() };
    }

    public static Acceleration get( double xAccel, double yAccel, double zAccel ) {
        return getters[ GlobalData.GRAPHICS_DIMENSIONS.getValue() ].get( xAccel, yAccel, zAccel );
    }

    public static Acceleration get( double xAccel, double yAccel ) {
        return getters[ GlobalData.GRAPHICS_DIMENSIONS.getValue() ].get(xAccel, yAccel, 0.0 );
    }

    private interface AccelGet {
        public Acceleration get( double xAccel, double yAccel, double zAccel );
    }

    private class Get2D implements AccelGet {
        @Override
        public Acceleration get( double xAccel, double yAccel, double zAccel ) {
            return new Acceleration2D( xAccel, yAccel );
        }
    }

    private class Get3D implements AccelGet {
        @Override
        public Acceleration get( double xAccel, double yAccel, double zAccel ) {
            return new Acceleration3D( xAccel, yAccel, zAccel );
        }
    }
}
TOP

Related Classes of factories.Accelerations$Get3D

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.