/*
* 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 );
}
}
}