Example #1
0
        /**
         * @brief 복제
         * @author 불명(김민규 담당)
         * @date 불명(2017-1-17 확인)
         * @return object 똑같은 값을 가지는 새로운 Figure를 생성해 반환한다. 사실상 팩토리 역할을 한다.
         */
        public virtual object Clone()
        {
            Figure figure = null;

            if (this.GetType() == typeof(LineFigure))
            {
                figure = new LineFigure();
            }
            else if (this.GetType() == typeof(PolyLineFigure))
            {
                figure = new PolyLineFigure();
            }
            else if (this.GetType() == typeof(FreeLineFigure))
            {
                figure = new FreeLineFigure();
            }
            else if (this.GetType() == typeof(RectFigure))
            {
                figure = new RectFigure();
            }
            else if (this.GetType() == typeof(OvalFigure))
            {
                figure = new OvalFigure();
            }
            else if (this.GetType() == typeof(ImageFigure))
            {
                figure = new ImageFigure(((ImageFigure)this).getImage());
            }
            else if (this.GetType() == typeof(MergedFigure))
            {
                FigureList figureListToClone = ((MergedFigure)this).getFigList();
                figure = new MergedFigure((FigureList)figureListToClone.Clone());
            }
            else
            {
                throw new System.NotImplementedException();
            }

            figure.coordinates = (RectList)this.coordinates.Clone();
            figure.filledColor = this.filledColor;
            figure.bFilled     = this.bFilled;
            figure.groupName   = this.groupName;
            return(figure);
        }
Example #2
0
        /**
         * @brief 복제 뒤 상대좌표 반영
         * @author 김민규
         * @date 2017-02-07
         * @param magnificationRatio 확대 비율
         * @param screenPos 화면의 현재 위치
         */
        public virtual Figure RelativeClone(int magnificationRatio, Pos screenPos)
        {
            Figure figure = null;

            if (this.GetType() == typeof(LineFigure))
            {
                figure = new LineFigure();
            }
            else if (this.GetType() == typeof(PolyLineFigure))
            {
                figure = new PolyLineFigure();
            }
            else if (this.GetType() == typeof(FreeLineFigure))
            {
                figure = new FreeLineFigure();
            }
            else if (this.GetType() == typeof(RectFigure))
            {
                figure = new RectFigure();
            }
            else if (this.GetType() == typeof(OvalFigure))
            {
                figure = new OvalFigure();
            }
            else if (this.GetType() == typeof(ImageFigure))
            {
                figure = new ImageFigure(((ImageFigure)this).getImage());
            }
            else if (this.GetType() == typeof(MergedFigure))
            {
                FigureList figureListToClone = ((MergedFigure)this).getFigList();
                figure = new MergedFigure((FigureList)figureListToClone.RelativeClone(magnificationRatio, screenPos));
            }
            else
            {
                throw new System.NotImplementedException();
            }

            figure.coordinates = (RectList)this.coordinates.RelativeClone(magnificationRatio, screenPos);
            figure.filledColor = this.filledColor;
            return(figure);
        }