Esempio n. 1
0
 public override void fill(java.awt.Shape shape)
 {
     using (Region region = new Region(J2C.ConvertShape(shape)))
     {
         g.FillRegion(brush, region);
     }
 }
Esempio n. 2
0
 public override void draw(java.awt.Shape shape)
 {
     using (GraphicsPath gp = J2C.ConvertShape(shape))
     {
         g.DrawPath(pen, gp);
     }
 }
Esempio n. 3
0
 public override bool hit(java.awt.Rectangle rect, java.awt.Shape s, bool onStroke)
 {
     if (onStroke)
     {
         //TODO use stroke
         //s = stroke.createStrokedShape(s);
     }
     return(s.intersects(rect));
 }
Esempio n. 4
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);
        }
Esempio n. 5
0
 public override void setClip(java.awt.Shape shape)
 {
     if (shape == null)
     {
         Region clip = g.Clip;
         clip.MakeInfinite();
         g.Clip = clip;
     }
     else
     {
         g.Clip = new Region(J2C.ConvertShape(shape));
     }
 }
Esempio n. 6
0
 public override void clip(java.awt.Shape shape)
 {
     if (shape == null)
     {
         // the API specification says that this will clear
         // the clip, but in fact the reference implementation throws a
         // NullPointerException - see the following entry in the bug parade:
         // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6206189
         throw new java.lang.NullPointerException();
     }
     else
     {
         g.IntersectClip(new Region(J2C.ConvertShape(shape)));
     }
 }
Esempio n. 7
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);
        }