Example #1
0
        /// <summary>
        /// Creates an image for the given arguments.
        /// </summary>
        public static Image CreateImage(mxGraph graph, Object[] cells, double scale, Color?background,
                                        bool antiAlias, mxRectangle clip, mxGdiCanvas graphicsCanvas)
        {
            mxImageCanvas canvas = (mxImageCanvas)DrawCells(graph, cells, scale, clip,
                                                            new ImageCanvasFactory(graphicsCanvas, background, antiAlias));

            return(canvas.Destroy());
        }
Example #2
0
        /* (non-Dotnetdoc)
         * see com.mxgraph.mxGraphViewReader.CreateCanvas()
         */
        override public mxICanvas CreateCanvas(Dictionary <string, Object> attrs)
        {
            int width  = 0;
            int height = 0;
            int dx     = 0;
            int dy     = 0;

            mxRectangle tmp = Clip;

            if (tmp != null)
            {
                dx    -= (int)tmp.X;
                dy    -= (int)tmp.Y;
                width  = (int)tmp.Width;
                height = (int)tmp.Height;
            }
            else
            {
                int x = (int)Math.Round(mxUtils.GetDouble(attrs, "x"));
                int y = (int)Math.Round(mxUtils.GetDouble(attrs, "y"));
                width = (int)(Math.Round(mxUtils.GetDouble(attrs, "width")))
                        + border + 3;
                height = (int)(Math.Round(mxUtils.GetDouble(attrs, "height")))
                         + border + 3;

                if (cropping)
                {
                    dx = -x + 3;
                    dy = -y + 3;
                }
                else
                {
                    width  += x;
                    height += y;
                }
            }

            mxImageCanvas canvas = new mxImageCanvas(new mxGdiCanvas(),
                                                     width, height, Background, AntiAlias);

            canvas.Translate = new Point(dx, dy);

            return(canvas);
        }
        /* (non-Dotnetdoc)
         * see com.mxgraph.mxGraphViewReader.CreateCanvas()
         */
        public override mxICanvas CreateCanvas(Dictionary<string, Object> attrs)
        {
            int width = 0;
            int height = 0;
            int dx = 0;
            int dy = 0;

            mxRectangle tmp = Clip;

            if (tmp != null)
            {
                dx -= (int)tmp.X;
                dy -= (int)tmp.Y;
                width = (int)tmp.Width;
                height = (int)tmp.Height;
            }
            else
            {
                int x = (int)Math.Round(mxUtils.GetDouble(attrs, "x"));
                int y = (int)Math.Round(mxUtils.GetDouble(attrs, "y"));
                width = (int)(Math.Round(mxUtils.GetDouble(attrs, "width")))
                    + border + 3;
                height = (int)(Math.Round(mxUtils.GetDouble(attrs, "height")))
                    + border + 3;

                if (cropping)
                {
                    dx = -x + 3;
                    dy = -y + 3;
                }
                else
                {
                    width += x;
                    height += y;
                }
            }

            mxImageCanvas canvas = new mxImageCanvas(new mxGdiCanvas(),
                    width, height, Background, AntiAlias);
            canvas.Translate = new Point(dx, dy);

            return canvas;
        }