Пример #1
0
        public static void reflectionTransform(Shape shape, TypeReflectionTransform type)
        {
            Line Ox = new Line(new Point(0, 200), new Point(400, 200));

            Ox.setTransformPoint(new Point(0, 0));
            translationTransform(Ox);
            Line Oy = new Line(new Point(200, 200), new Point(400, 400));

            Oy.setTransformPoint(new Point(0, 0));
            translationTransform(Oy);

            switch (shape.getTypeDraw())
            {
            case TypeDraw.Line:
                Line line = (Line)shape;
                line.setStartPoint(reflect(line.getStartPoint(), type));
                line.setEndPoint(reflect(line.getEndPoint(), type));
                break;

            case TypeDraw.Circle:
                Circle circle = (Circle)shape;
                circle.setCenterPoint(reflect(circle.getCenterPoint(), type));
                circle.setEndPoint(reflect(circle.getEndPoint(), type));
                break;

            case TypeDraw.Ellipse:
                Ellipse ellipse = (Ellipse)shape;
                ellipse.setStartPoint(reflect(ellipse.getStartPoint(), type));
                ellipse.setEndHightPoint(reflect(ellipse.getEndHightPoint(), type));
                ellipse.setEndWidthPoint(reflect(ellipse.getEndWidthPoint(), type));
                break;

            case TypeDraw.Parallelogram:
                Parallelogram parallelogram = (Parallelogram)shape;
                parallelogram.setPoint1(reflect(parallelogram.getPoint1(), type));
                parallelogram.setPoint2(reflect(parallelogram.getPoint2(), type));
                parallelogram.setPoint3(reflect(parallelogram.getPoint3(), type));
                break;

            case TypeDraw.Rectangle:
                Rectangle rectangle = (Rectangle)shape;
                rectangle.setStartPoint(reflect(rectangle.getStartPoint(), type));
                rectangle.setEndPoint(reflect(rectangle.getEndPoint(), type));
                break;

            case TypeDraw.Triangle:
                Triangle triangle = (Triangle)shape;
                triangle.setPoint1(reflect(triangle.getPoint1(), type));
                triangle.setPoint2(reflect(triangle.getPoint2(), type));
                triangle.setPoint3(reflect(triangle.getPoint3(), type));
                break;

            case TypeDraw.Square:
                Square square = (Square)shape;
                square.setPoint1(reflect(square.getPoint1(), type));
                square.setPoint2(reflect(square.getPoint2(), type));
                break;
            }
            shape.setTransformFlag(false);
        }