Ejemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 15JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Strokes the outline of a IShape using the settings of the current
         * Graphics2D context.
         * @param brush the brush used to fill the shape.
         * @param shape the IShape to be rendered.
         */
        public void Fill(Brush brush, IShape shape)
        {
            if (brush != null)
            {
                _graphicsFP.SetBrush(brush._wrappedBrushFP);
                _defaultBrush = brush;
            }

            PathIterator pathIterator = shape.GetPathIterator(null);

            int[]          coords         = new int[6];
            GraphicsPathFP graphicsPathFP = new GraphicsPathFP();
            PointFP        pointFP1       = new PointFP();
            PointFP        pointFPCtl1    = new PointFP();
            PointFP        pointFPCtl2    = new PointFP();

            while (!pathIterator.IsDone())
            {
                int type = pathIterator.CurrentSegment(coords);
                switch (type)
                {
                case PathIterator.SEG_MOVETO:
                    pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                   coords[1] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddMoveTo(pointFP1);
                    break;

                case PathIterator.SEG_CLOSE:
                    graphicsPathFP.AddClose();
                    break;

                case PathIterator.SEG_LINETO:
                    pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                   coords[1] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddLineTo(pointFP1);
                    break;

                case PathIterator.SEG_QUADTO:
                    pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                      coords[1] << SingleFP.DECIMAL_BITS);
                    pointFP1.Reset(coords[2] << SingleFP.DECIMAL_BITS,
                                   coords[3] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddQuadTo(pointFPCtl1, pointFP1);
                    break;

                case PathIterator.SEG_CUBICTO:
                    pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                      coords[1] << SingleFP.DECIMAL_BITS);
                    pointFPCtl2.Reset(coords[2] << SingleFP.DECIMAL_BITS,
                                      coords[3] << SingleFP.DECIMAL_BITS);
                    pointFP1.Reset(coords[4] << SingleFP.DECIMAL_BITS,
                                   coords[5] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddCurveTo(pointFPCtl1, pointFPCtl2, pointFP1);
                    break;
                }
                pathIterator.Next();
            }
            _graphicsFP.FillPath(graphicsPathFP);
        }
Ejemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 15JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Strokes the outline of a IShape using the settings of the current
         * Graphics2D context.
         * @param pen the pen used to stroke the shape.
         * @param shape the IShape to be rendered.
         */
        public void Draw(Pen pen, IShape shape)
        {
            SetGraphicsFPPenAttribute(pen);
            PathIterator pathIterator = shape.GetPathIterator(null);

            int[]          coords         = new int[6];
            GraphicsPathFP graphicsPathFP = new GraphicsPathFP();
            PointFP        pointFP1       = new PointFP();
            PointFP        pointFPCtl1    = new PointFP();
            PointFP        pointFPCtl2    = new PointFP();

            while (!pathIterator.IsDone())
            {
                int type = pathIterator.CurrentSegment(coords);
                switch (type)
                {
                case PathIterator.SEG_MOVETO:
                    pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                   coords[1] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddMoveTo(pointFP1);
                    break;

                case PathIterator.SEG_CLOSE:
                    graphicsPathFP.AddClose();
                    break;

                case PathIterator.SEG_LINETO:
                    pointFP1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                   coords[1] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddLineTo(pointFP1);
                    break;

                case PathIterator.SEG_QUADTO:
                    pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                      coords[1] << SingleFP.DECIMAL_BITS);
                    pointFP1.Reset(coords[2] << SingleFP.DECIMAL_BITS,
                                   coords[3] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddQuadTo(pointFPCtl1, pointFP1);
                    break;

                case PathIterator.SEG_CUBICTO:
                    pointFPCtl1.Reset(coords[0] << SingleFP.DECIMAL_BITS,
                                      coords[1] << SingleFP.DECIMAL_BITS);
                    pointFPCtl2.Reset(coords[2] << SingleFP.DECIMAL_BITS,
                                      coords[3] << SingleFP.DECIMAL_BITS);
                    pointFP1.Reset(coords[4] << SingleFP.DECIMAL_BITS,
                                   coords[5] << SingleFP.DECIMAL_BITS);
                    graphicsPathFP.AddCurveTo(pointFPCtl1, pointFPCtl2, pointFP1);
                    break;
                }
                pathIterator.Next();
            }
            _graphicsFP.DrawPath(graphicsPathFP);
        }