Exemple #1
0
        internal static GraphicsPath ConvertShape(java.awt.Shape shape)
        {
            java.awt.geom.GeneralPath  path     = new java.awt.geom.GeneralPath(shape);
            java.awt.geom.PathIterator iterator = path.getPathIterator(new java.awt.geom.AffineTransform());
            GraphicsPath gp = new GraphicsPath();

            switch (iterator.getWindingRule())
            {
            case java.awt.geom.PathIterator.__Fields.WIND_EVEN_ODD:
                gp.FillMode = System.Drawing.Drawing2D.FillMode.Alternate;
                break;

            case java.awt.geom.PathIterator.__Fields.WIND_NON_ZERO:
                gp.FillMode = System.Drawing.Drawing2D.FillMode.Winding;
                break;
            }
            float[] coords = new float[6];
            float   x      = 0;
            float   y      = 0;

            while (!iterator.isDone())
            {
                int type = iterator.currentSegment(coords);
                switch (type)
                {
                case java.awt.geom.PathIterator.__Fields.SEG_MOVETO:
                    x = coords[0];
                    y = coords[1];
                    gp.StartFigure();
                    break;

                case java.awt.geom.PathIterator.__Fields.SEG_LINETO:
                    gp.AddLine(x, y, coords[0], coords[1]);
                    x = coords[0];
                    y = coords[1];
                    break;

                case java.awt.geom.PathIterator.__Fields.SEG_QUADTO:
                    gp.AddBezier(x, y, coords[0], coords[1], coords[0], coords[1], coords[2], coords[3]);
                    x = coords[2];
                    y = coords[3];
                    break;

                case java.awt.geom.PathIterator.__Fields.SEG_CUBICTO:
                    gp.AddBezier(x, y, coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
                    x = coords[4];
                    y = coords[5];
                    break;

                case java.awt.geom.PathIterator.__Fields.SEG_CLOSE:
                    gp.CloseFigure();
                    break;
                }
                iterator.next();
            }
            return(gp);
        }
Exemple #2
0
        internal static GraphicsPath ConvertShape(java.awt.Shape shape)
        {
            java.awt.geom.PathIterator iterator = shape.getPathIterator(null);
            GraphicsPath gp = new GraphicsPath();

            gp.FillMode = (FillMode)iterator.getWindingRule();
            float[] coords = new float[6];
            float   x      = 0;
            float   y      = 0;

            while (!iterator.isDone())
            {
                int type = iterator.currentSegment(coords);
                switch (type)
                {
                case java.awt.geom.PathIterator.__Fields.SEG_MOVETO:
                    x = coords[0];
                    y = coords[1];
                    gp.StartFigure();
                    break;

                case java.awt.geom.PathIterator.__Fields.SEG_LINETO:
                    gp.AddLine(x, y, coords[0], coords[1]);
                    x = coords[0];
                    y = coords[1];
                    break;

                case java.awt.geom.PathIterator.__Fields.SEG_QUADTO:
                    gp.AddBezier(x, y, coords[0], coords[1], coords[0], coords[1], coords[2], coords[3]);
                    x = coords[2];
                    y = coords[3];
                    break;

                case java.awt.geom.PathIterator.__Fields.SEG_CUBICTO:
                    gp.AddBezier(x, y, coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
                    x = coords[4];
                    y = coords[5];
                    break;

                case java.awt.geom.PathIterator.__Fields.SEG_CLOSE:
                    gp.CloseFigure();
                    break;
                }
                iterator.next();
            }
            return(gp);
        }