package factories;
import graphics.common.Point;
import graphics.common.Point2D;
import graphics.common.Point3D;
import utils.GlobalData;
public class Points {
private static final GetPoint[] getters = new GetPoint[] { new Points.Get2D(), new Points.Get3D() };
public static Point get( double x, double y, double z ) {
return getters[ GlobalData.GRAPHICS_DIMENSIONS.getValue() ].get( x, y, z );
}
public static Point get( double x, double y ) {
return getters[ GlobalData.GRAPHICS_DIMENSIONS.getValue() ].get( x, y, 0 );
}
public static Point get( Point p ) {
return get( p.getRealX(), p.getRealY(), p.getRealZ() );
}
private interface GetPoint {
public Point get( double x, double y, double z );
}
private static class Get2D implements GetPoint {
@Override
public Point get( double x, double y, double z ) {
return new Point2D( x, y );
}
}
private static class Get3D implements GetPoint {
@Override
public Point get( double x, double y, double z ) {
return new Point3D( x, y, z );
}
}
}