Package factories

Source Code of factories.Boxes$Get2D

package factories;

import graphics.common.Box;
import graphics.common.Cube;
import graphics.common.Point;
import graphics.common.Rect;
import graphics.common.Size;
import utils.GlobalData;

public class Boxes {

    private static BoundingGet[] getters;

    public Boxes() {
        getters = new BoundingGet[] { new Get2D(), new Get3D() };
    }

    public static Box get( double x, double y, double z,
                            double width, double height, double depth ) {
        return getters[ GlobalData.GRAPHICS_DIMENSIONS.getValue() ].get( x, y, z, width, height, depth );
    }

    public static Box get( double x, double y, double width, double height ) {
        return getters[ GlobalData.GRAPHICS_DIMENSIONS.getValue() ].get( x, y, 0, width, height, 0 );
    }

    public static Box get( Point p, Size s ) {
        return getters[ GlobalData.GRAPHICS_DIMENSIONS.getValue() ].get( p, s );
    }

    private interface BoundingGet {
        public Box get( double x, double y, double z,
                            double width, double height, double depth );
        public Box get( Point p, Size s );
    }

    private class Get2D implements BoundingGet {
        @Override
        public Box get( double x, double y, double z,
                        double width, double height, double depth ) {
            return new Rect( x, y, width, height );
        }
        @Override
        public Box get( Point p, Size s ) {
             return new Rect( p, s );
        }
    }

    private class Get3D implements BoundingGet {
        @Override
        public Box get( double x, double y, double z,
                        double width, double height, double depth ) {
            return new Cube( x, y, z, width, height, depth );
        }
        @Override
        public Box get( Point p, Size s ) {
            return new Cube( p, s );
        }
    }
}
TOP

Related Classes of factories.Boxes$Get2D

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.