예제 #1
0
        public virtual void draw(DrawContext cntxt, System.Drawing.Drawing2D.Matrix transform)
        {
            Console.WriteLine("Tesselator >>> begin draw");
            context = cntxt;

            begin(path.Convex, context.context);
            path.walk(new Walker(this), transform, context.pathError);
            end(context.context);

            draw(context.context);
            Console.WriteLine("Tesselator >>> end draw");
        }
예제 #2
0
 public DrawContext(DrawContext context, int surfaceType)
 {
     this.device = context.device;
     this.root = context.root;
     this.renderingInstance = context.renderingInstance;
     this.context = context.context;
     this.width = context.width;
     this.height = context.height;
     this.renderer = context.renderer;
     this.surfaceType = surfaceType;
     this.AAFilter = context.AAFilter;
     this.pathError = context.pathError;
 }
예제 #3
0
        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
        internal override void draw(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ref System.Drawing.Rectangle visibleArea)
        {
            int surfaceType = 0; // TODO PENDING getSurfaceType(getDrawType(context, transform, color));

            if (surfaceType == Renderer.SURFACE_TYPE_COLOR || (surfaceType == context.surfaceType && color.White))
            {
                draw(context, transform, color);
            }
            else
            {
                System.Drawing.Rectangle bounds = getBounds(context, transform);

                if (bounds.Width <= 0 || bounds.Height <= 0)
                    return;
                System.Drawing.Rectangle tempAux = addSafetyMargin(bounds);
                if (context.renderer.beginSurface(context.context, ref tempAux, surfaceType) != 0)
                    return;
                //draw(context, transform, white);
                draw(context, transform, color);
                context.renderer.color(context.context, color);
                context.renderer.drawSurface(context.context);
            }
        }
예제 #4
0
 internal override int getDrawType(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ScenicColor color)
 {
     if (color.alpha != 1.0f)
         return SceneShape.DRAW_SURFACE;
     return SceneShape.DRAW_SIMPLE;
 }
예제 #5
0
        internal override void draw(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ScenicColor color)
        {
            if (font == null)
                return;

            if (usePolygon(context, transform))
                drawUsingPolygon(context, transform, color);
            else
                drawUsingTexture(context, transform, color);
        }
예제 #6
0
        internal override System.Drawing.Rectangle getBounds(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
        {
            System.Drawing.Rectangle result = base.getBounds(context, transform);

            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            System.Drawing.Rectangle tempAux = clip.getBounds(context, transform);
            Util.common(ref result, ref tempAux);
            return result;
        }
예제 #7
0
        internal override int getDrawType(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
        {
            DrawContext newContext = (DrawContext)context.Clone();

            newContext.AAFilter = antialiasingFilter;
            return base.getDrawType(newContext, transform);
        }
예제 #8
0
        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
        internal override void draw(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ref System.Drawing.Rectangle visibleArea)
        {
            DrawContext newContext = (DrawContext)context.Clone();

            newContext.AAFilter = antialiasingFilter;
            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            base.draw(newContext, transform, ref visibleArea);
        }
예제 #9
0
 internal override int getDrawType(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
 {
     #if PENDING
     if (children.Count == 1)
         return ((SceneNode) children.get_Renamed(0)).getDrawType(context, transform);
     return SceneNode.DRAW_SIMPLE;
     #endif
     return 0;
 }
예제 #10
0
 //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
 internal override void draw(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ref System.Drawing.Rectangle visibleArea)
 {
     foreach (SceneNode node in children)
         node.draw(context, transform, ref visibleArea);
 }
예제 #11
0
 internal virtual int getDrawType(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ScenicColor color)
 {
     return DRAW_SIMPLE;
 }
예제 #12
0
 internal override int getDrawType(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
 {
     return getDrawType(context, transform, color);
 }
예제 #13
0
 private bool usePolygon(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
 {
     transform.Elements.GetValue(0);
     transform.Elements.GetValue(3);
     transform.Elements.GetValue(2);
     return context.usesCustomAAFilter() || !isStraight(transform) || System.Math.Sqrt((float)transform.Elements.GetValue(1)) * (int)font.Size > polygonSizeLimit;
 }
예제 #14
0
        private void drawUsingTexture(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ScenicColor color)
        {
            #if PENDING
            System.Drawing.Drawing2D.Matrix at = Util.linearTransform(transform);

            GlyphCache.CachedFont drawFont = new GlyphCache.CachedFont(font, at);
            GlyphCache cache = Device.GlyphCache;
            Image img = (Image)cache.Image;
            double texm = 1.0 / img.getWidth();

            context.renderer.color(context.context, color);
            context.renderer.beginText(context.context);
            context.renderer.setTextTexture(context.context, img.Id);

            for (int i = 0; i < glyphCodes.Length; i++)
            {
                GlyphImage g = cache.getGlyph(drawFont, glyphCodes[i]);

                if (g == null)
                {
                    context.renderer.endText(context.context);
                    g = cache.renderGlyph(drawFont, glyphCodes[i]);
                    context.renderer.beginText(context.context);
                    context.renderer.setTextTexture(context.context, img.Id);
                }
                if (g != null && !g.cache.IsEmpty && g.width > 0 && g.height > 0)
                {
                    System.Drawing.Rectangle r = g.cache;
                    double px = positions[i * 2];
                    double py = positions[i * 2 + 1];
                    double tpx = (float)transform.Elements.GetValue(0) * px + (float)transform.Elements.GetValue(2) * py + (System.Single)transform.OffsetX;
                    double tpy = (float)transform.Elements.GetValue(1) * px + (float)transform.Elements.GetValue(3) * py + (System.Single)transform.OffsetY;
                    double ix = System.Math.Floor(tpx + 0.5001) - g.x;
                    double iy = System.Math.Floor(tpy + 0.5001) - g.y;

                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042_3"'
                    context.renderer.drawGlyph(context.context, (float)(r.X * texm), (float)(r.Y * texm), (float)(r.Width * texm), (float)(r.Height * texm), (int)ix, (int)iy, g.width, g.height);
                }
            }
            context.renderer.endText(context.context);
            #endif
        }
예제 #15
0
        private void drawUsingPolygon(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ScenicColor color)
        {
            #if PENDING
            if (glyphPolygons == null)
            {
                glyphPolygons = new FilledPath[glyphCodes.Length];
                for (int i = 0; i < glyphCodes.Length; i++)
                {
                    System.Drawing.Drawing2D.Matrix temp_Matrix;
                    temp_Matrix = new System.Drawing.Drawing2D.Matrix();
                    temp_Matrix.Translate((float) positions[i * 2], (float) positions[i * 2 + 1]);
                    System.Drawing.Drawing2D.Matrix at = temp_Matrix;
                    //UPGRADE_TODO: Interface 'java.awt.Shape' was converted to 'System.Drawing.Drawing2D.GraphicsPath' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_3"'
                    System.Drawing.Drawing2D.GraphicsPath shape = TextRenderer.getGlyphOutline(font, at, glyphCodes[i]);
                    Path path = new AWTShapePath(shape);

                    glyphPolygons[i] = new FilledPath(path);
                }
            }

            System.Drawing.Drawing2D.Matrix temp = new System.Drawing.Drawing2D.Matrix();

            for (int i = 0; i < glyphPolygons.Length; i++)
            {
                System.Drawing.Drawing2D.Matrix temp_Matrix2;
                temp_Matrix2 = new System.Drawing.Drawing2D.Matrix();
                temp_Matrix2.Translate((float) positions[i * 2], (float) positions[i * 2 + 1]);
                System.Drawing.Drawing2D.Matrix at = temp_Matrix2;

                //UPGRADE_ISSUE: Method 'java.awt.geom.AffineTransform.setTransform' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomAffineTransformsetTransform_javaawtgeomAffineTransform_3"'
                temp.setTransform(transform);
                //UPGRADE_TODO: Method 'java.awt.geom.AffineTransform.concatenate' was converted to 'System.Drawing.Drawing2D.Matrix.Multiply' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javaawtgeomAffineTransformconcatenate_javaawtgeomAffineTransform_3"'
                temp.Multiply(at, System.Drawing.Drawing2D.MatrixOrder.Append);
                glyphPolygons[i].draw(context, temp, color);
            }
            #endif
        }
예제 #16
0
 internal override int getDrawType(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ScenicColor color)
 {
     if (usePolygon(context, transform))
         return DRAW_SURFACE4X;
     else
         return DRAW_SIMPLE;
 }
예제 #17
0
        internal override System.Drawing.Rectangle getBounds(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
        {
            #if PENDING
            System.Drawing.Rectangle r = System.Drawing.Rectangle.Empty;

            //UPGRADE_TODO: Class 'java.awt.font.FontRenderContext' was converted to 'System.Windows.Forms.Control' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_3"'
            //UPGRADE_ISSUE: Constructor 'java.awt.font.FontRenderContext.FontRenderContext' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtfontFontRenderContextFontRenderContext_javaawtgeomAffineTransform_boolean_boolean_3"'
            System.Drawing.Text.TextRenderingHint frc = new FontRenderContext(transform, false, true);
            for (int i = 0; i < glyphCodes.Length; i++)
            {

                //UPGRADE_ISSUE: Class 'java.awt.font.GlyphVector' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtfontGlyphVector_3"'
                //UPGRADE_TODO: Method 'java.awt.Font.createGlyphVector' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1095_3"'
                GlyphVector gv = font.createGlyphVector(frc, new int[] { glyphCodes[i] });
                System.Drawing.Rectangle gr = gv.getPixelBounds(frc, positions[i * 2], positions[i * 2 + 1]);

                if (r.IsEmpty)
                    r = gr;
                else
                    r = System.Drawing.Rectangle.Union(r, gr);
            }
            if (r.IsEmpty)
                return new System.Drawing.Rectangle();

            Filter filter = context.AAFilter;

            // Compensate for the antialiasing filter
            if (filter != null)
            {
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042_3"'
                //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
                r = addMargin(ref r, (int)System.Math.Ceiling(filter.Width), (int)System.Math.Ceiling(filter.Height));
            }
            return r;
            #endif
            return new System.Drawing.Rectangle();
        }
예제 #18
0
 public Walker(StrokedPath enclosingInstance, DrawContext context)
 {
     InitBlock(enclosingInstance);
     this.context = context;
 }
예제 #19
0
 public Walker(StrokedPath enclosingInstance, DrawContext context)
 {
     InitBlock(enclosingInstance);
     this.context = context;
 }
예제 #20
0
 internal override void prepareDraw(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
 {
 }
예제 #21
0
        internal override System.Drawing.Rectangle getBounds(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
        {
            #if PENDING
            System.Drawing.Rectangle result = new System.Drawing.Rectangle();
            //UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1156_3"'
            Iterator < SceneNode > itr = children.iterator();

            while (itr.hasNext())
            {
                SceneNode node = itr.next();
                System.Drawing.Rectangle nodeRect = node.getBounds(context, transform);

                //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
                Util.combine(ref result, ref nodeRect);
            }

            return result;
            #endif
            return new System.Drawing.Rectangle();
        }
예제 #22
0
 internal abstract void draw(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ScenicColor color);
예제 #23
0
 internal override void prepareDraw(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
 {
     foreach (SceneNode node in children)
         node.prepareDraw(context, transform);
 }
예제 #24
0
 internal abstract override System.Drawing.Rectangle getBounds(DrawContext context, System.Drawing.Drawing2D.Matrix transform);
예제 #25
0
        internal override System.Drawing.Rectangle getBounds(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
        {
            DrawContext newContext = (DrawContext)context.Clone();

            newContext.AAFilter = antialiasingFilter;
            return base.getBounds(newContext, transform);
        }
예제 #26
0
        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
        internal override void draw(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ref System.Drawing.Rectangle visibleArea)
        {
            #if PENDING
            if (image == null || image.getWidth() == 0 || image.getHeight() == 0)
                return ;

            context.renderer.color(context.context, new Color(1.0f, 1.0f, 1.0f, 1.0f));
            context.renderer.setTransform(context.context, transform);
            if (!sourceRect.IsEmpty)
                context.renderer.drawImage(context.context, image.Id, (double) sourceRect.X, (double) sourceRect.Y, (double) sourceRect.Width, (double) sourceRect.Height);
            else
                context.renderer.drawImage(context.context, image.Id, 0, 0, image.getWidth(), image.getHeight());
            #endif
        }
예제 #27
0
        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
        internal override void draw(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ref System.Drawing.Rectangle visibleArea)
        {
            #if PENDING
            System.Drawing.Rectangle bounds = getBounds(context, transform);
            int clipDrawType = clip.getDrawType(context, transform);

            if (bounds.Width <= 0 || bounds.Height <= 0)
                return ;
            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            bounds = addSafetyMargin(ref bounds);
            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            if (context.renderer.beginSurface(context.context, ref bounds, Renderer.SURFACE_TYPE_COLOR) == 0)
                return ;
            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            base.draw(context, transform, ref bounds);
            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            if (context.renderer.beginSurface(context.context, ref bounds, getSurfaceType(clipDrawType)) == 0)
                return ;
            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            clip.draw(new DrawContext(context, clipDrawType), transform, ref bounds);
            context.renderer.color(context.context, 1.0f, 1.0f, 1.0f, 1.0f);
            context.renderer.drawSurfaceAndClip(context.context);
            #endif
        }
예제 #28
0
        internal override System.Drawing.Rectangle getBounds(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
        {
            System.Drawing.Rectangle r = path.getBounds(transform);
            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042_3"'
            System.Drawing.Rectangle tempAux = new System.Drawing.Rectangle(0, 0, (int)System.Math.Ceiling(lineWidth / 2.0 * 4.0), (int)System.Math.Ceiling(lineWidth / 2.0 * 4.0));
            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            System.Drawing.Rectangle wr = Util.transform(transform, ref tempAux);

            r.X -= wr.Width;
            r.Y -= wr.Width;
            r.Width += wr.Width * 2;
            r.Height += wr.Height * 2;

            return r;
        }
예제 #29
0
 internal override void draw(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ScenicColor color)
 {
     context.renderer.color(context.context, color);
     context.renderer.setTransform(context.context, transform);
     context.renderer.polylineSetStyle(context.context, (float)lineWidth, endCap, lineJoin, (float)miterLimit, dashArray, dashPhase);
     path.walk(new Walker(this, context), transform, context.pathError);
 }
예제 #30
0
 internal override System.Drawing.Rectangle getBounds(DrawContext context, System.Drawing.Drawing2D.Matrix transform)
 {
     if (!sourceRect.IsEmpty)
     {
         //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042_3"'
         System.Drawing.Rectangle tempAux = new System.Drawing.Rectangle(0, 0, (int)sourceRect.Width, (int)sourceRect.Height);
         //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
         return Util.transform(transform, ref tempAux);
     }
     else
     {
         System.Drawing.Rectangle tempAux2 = new System.Drawing.Rectangle(0, 0, image.getWidth(), image.getHeight());
         //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
         return Util.transform(transform, ref tempAux2);
     }
 }