Ejemplo n.º 1
0
        public void Chart(Chart c, Row row, ChartBase cb)
        {
            System.Drawing.Image im = cb.Image(r);

            PutImage(im, im.Width, im.Height);

            if (InTable(c))
            {
                tw.Write(@"\cell");
            }
        }
Ejemplo n.º 2
0
        ChartBase RunChartBuild(Report rpt, Row row)
        {
            // Get the matrix that defines the data;
            _ChartMatrix.SetMyData(rpt, GetMyData(rpt));                // set the data in the matrix
            int maxColumns;
            int maxRows;

            MatrixCellEntry[,] matrix = _ChartMatrix.RunBuild(rpt, out maxRows, out maxColumns);

            // Build the Chart bitmap, along with data regions
            ChartBase cb = null;

            switch (_Type)
            {
            case ChartTypeEnum.Column:
                cb = new ChartColumn(rpt, row, this, matrix, _showTooltips, _showTooltipsX, _ToolTipYFormat, _ToolTipXFormat);
                break;

            case ChartTypeEnum.Line:
            case ChartTypeEnum.Area:                                            // handled by line
                cb = new ChartLine(rpt, row, this, matrix, _showTooltips, _showTooltipsX, _ToolTipYFormat, _ToolTipXFormat);
                break;

            case ChartTypeEnum.Bar:
                cb = new ChartBar(rpt, row, this, matrix, _showTooltips, _showTooltipsX, _ToolTipYFormat, _ToolTipXFormat);
                break;

            case ChartTypeEnum.Pie:
            case ChartTypeEnum.Doughnut:                                // handled by pie
                cb = new ChartPie(rpt, row, this, matrix, _showTooltips, _showTooltipsX, _ToolTipYFormat, _ToolTipXFormat);
                break;

            case ChartTypeEnum.Bubble:
            case ChartTypeEnum.Scatter:
                cb = new ChartBubble(rpt, row, this, matrix, _showTooltips, _showTooltipsX, _ToolTipYFormat, _ToolTipXFormat);
                break;

            case ChartTypeEnum.Map:
                cb = new ChartMap(rpt, row, this, matrix, _showTooltips, _showTooltipsX, _ToolTipYFormat, _ToolTipXFormat);
                break;

            case ChartTypeEnum.Stock:
            default:
                cb = new ChartColumn(rpt, row, this, matrix, _showTooltips, _showTooltipsX, _ToolTipYFormat, _ToolTipXFormat);
                break;
            }

            return(cb);
        }
Ejemplo n.º 3
0
        ChartBase RunChartBuild(Report rpt, Row row)
        {
            // Get the matrix that defines the data;
            //   some graph types don't require this (XY(scatter), Bubble, Stock
            _ChartMatrix.SetMyData(rpt, GetMyData(rpt));                // set the data in the matrix
            int maxColumns;
            int maxRows;

            MatrixCellEntry[,] matrix = _ChartMatrix.RunBuild(rpt, out maxRows, out maxColumns);

            // Build the Chart bitmap, along with data regions
            ChartBase cb = null;

            switch (_Type)
            {
            case ChartTypeEnum.Column:
                cb = new ChartColumn(rpt, row, this, matrix);
                break;

            case ChartTypeEnum.Line:
            case ChartTypeEnum.Area:                                            // handled by line
                cb = new ChartLine(rpt, row, this, matrix);
                break;

            case ChartTypeEnum.Bar:
                cb = new ChartBar(rpt, row, this, matrix);
                break;

            case ChartTypeEnum.Pie:
            case ChartTypeEnum.Doughnut:                                // handled by pie
                cb = new ChartPie(rpt, row, this, matrix);
                break;

            case ChartTypeEnum.Scatter:
            case ChartTypeEnum.Bubble:
            case ChartTypeEnum.Stock:
            default:
                cb = new ChartColumn(rpt, row, this, matrix);
                break;
            }

            return(cb);
        }
Ejemplo n.º 4
0
        override internal void Run(IPresent ip, Row row)
        {
            Report rpt = ip.Report();

            _ChartMatrix.RunReset(rpt);
            Rows _Data = GetFilteredData(ip.Report(), row);

            SetMyData(ip.Report(), _Data);

            if (!AnyRows(ip, _Data))                            // if no rows, return
            {
                return;
            }

            // Build the Chart bitmap, along with data regions
            ChartBase cb = null;

            try
            {
                cb = RunChartBuild(rpt, row);

                ip.Chart(this, row, cb);
            }
            catch (Exception ex)
            {
                rpt.rl.LogError(8, string.Format("Exception in Chart handling.\n{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                if (cb != null)
                {
                    cb.Dispose();
                }
            }
            return;
        }
Ejemplo n.º 5
0
 public void Chart(Chart c, Row r, ChartBase cb)
 {
 }
Ejemplo n.º 6
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report rpt = pgs.Report;

            if (IsHidden(pgs.Report, row))
            {
                return;
            }

            _ChartMatrix.RunReset(rpt);
            Rows _Data = GetFilteredData(rpt, row);

            SetMyData(rpt, _Data);

            SetPagePositionBegin(pgs);

            if (!AnyRowsPage(pgs, _Data))                       // if no rows return
            {
                return;                                         //   nothing left to do
            }
            // Build the Chart bitmap, along with data regions
            Page      p  = pgs.CurrentPage;
            ChartBase cb = null;

            try
            {
                cb = RunChartBuild(rpt, row);                                   // Build the chart
                System.Drawing.Image im = cb.Image(rpt);                        // Grab the image
                int height = im.Height;                                         // save height and width
                int width  = im.Width;

                MemoryStream ostrm = new MemoryStream();

                /* The following is a new image saving logic which will allow for higher
                 * quality images using JPEG with 100% quality
                 * 06122007AJM */
                System.Drawing.Imaging.ImageCodecInfo[] info;
                info = ImageCodecInfo.GetImageEncoders();
                EncoderParameters encoderParameters;
                encoderParameters = new EncoderParameters(1);
                // 20022008 AJM GJL - Centralised class with global encoder settings
                encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, ImageQualityManager.ChartImageQuality);
                System.Drawing.Imaging.ImageCodecInfo codec = null;
                for (int i = 0; i < info.Length; i++)
                {
                    if (info[i].FormatDescription == "JPEG")
                    {
                        codec = info[i];
                        break;
                    }
                }

                im.Save(ostrm, codec, encoderParameters);
                // 06122007AJM The follow has been replaced with the code above
                //im.Save(ostrm, info);	// generate a jpeg   TODO: get png to work with pdf

                byte[] ba = ostrm.ToArray();
                ostrm.Close();
                PageImage pi = new PageImage(IMAGEFORMAT, ba, width, height);                   // Create an image

                RunPageRegionBegin(pgs);

                SetPagePositionAndStyle(rpt, pi, row);
                pi.SI.BackgroundImage = null;                   // chart already has the background image

                if (pgs.CurrentPage.YOffset + pi.Y + pi.H >= pgs.BottomOfPage && !pgs.CurrentPage.IsEmpty())
                {                       // force page break if it doesn't fit on the page
                    pgs.NextOrNew();
                    pgs.CurrentPage.YOffset = OwnerReport.TopOfPage;
                    if (this.YParents != null)
                    {
                        pi.Y = 0;
                    }
                }

                p = pgs.CurrentPage;

                p.AddObject(pi);                        // Put image onto the current page

                RunPageRegionEnd(pgs);

                if (!this.PageBreakAtEnd && !IsTableOrMatrixCell(rpt))
                {
                    float newY = pi.Y + pi.H;
                    p.YOffset += newY;                          // bump the y location
                }
                SetPagePositionEnd(pgs, pi.Y + pi.H);
            }
            catch (Exception ex)
            {
                rpt.rl.LogError(8, string.Format("Exception in Chart handling.\n{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                if (cb != null)
                {
                    cb.Dispose();
                }
            }

            return;
        }
Ejemplo n.º 7
0
 public void Chart(Chart c, Row r, ChartBase cb)
 {
 }
Ejemplo n.º 8
0
        public void Chart(Chart c, Row row, ChartBase cb)
        {
            System.Drawing.Image im = cb.Image(r);

            PutImage(im, im.Width, im.Height);

            if (InTable(c))
                tw.Write(@"\cell");
        }
Ejemplo n.º 9
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report rpt = pgs.Report;

            if (IsHidden(pgs.Report, row))
            {
                return;
            }

            _ChartMatrix.RunReset(rpt);
            Rows _Data = GetFilteredData(rpt, row);

            SetMyData(rpt, _Data);

            SetPagePositionBegin(pgs);

            if (!AnyRowsPage(pgs, _Data))                       // if no rows return
            {
                return;                                         //   nothing left to do
            }
            // Build the Chart bitmap, along with data regions
            Page      p  = pgs.CurrentPage;
            ChartBase cb = null;

            try
            {
                cb = RunChartBuild(rpt, row);                           // Build the chart
                if (!_isHYNEsWonderfulVector.EvaluateBoolean(rpt, row)) //AJM GJL 14082008 'Classic' Rendering
                {
                    System.Drawing.Image im = cb.Image(rpt);            // Grab the image
                    int height = im.Height;                             // save height and width
                    int width  = im.Width;

                    MemoryStream ostrm = new MemoryStream();

                    /* The following is a new image saving logic which will allow for higher
                     * quality images using JPEG with 100% quality
                     * 06122007AJM */
                    System.Drawing.Imaging.ImageCodecInfo[] info;
                    info = ImageCodecInfo.GetImageEncoders();
                    EncoderParameters encoderParameters;
                    encoderParameters = new EncoderParameters(1);
                    // 20022008 AJM GJL - Centralised class with global encoder settings
                    encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, ImageQualityManager.ChartImageQuality);
                    System.Drawing.Imaging.ImageCodecInfo codec = null;
                    for (int i = 0; i < info.Length; i++)
                    {
                        if (info[i].FormatDescription == "JPEG")
                        {
                            codec = info[i];
                            break;
                        }
                    }
                    im.Save(ostrm, codec, encoderParameters);
                    // 06122007AJM The follow has been replaced with the code above
                    //im.Save(ostrm, info);	// generate a jpeg   TODO: get png to work with pdf

                    byte[] ba = ostrm.ToArray();
                    ostrm.Close();
                    PageImage pi = new PageImage(IMAGEFORMAT, ba, width, height);       // Create an image

                    RunPageRegionBegin(pgs);

                    SetPagePositionAndStyle(rpt, pi, row);
                    pi.SI.BackgroundImage = null;       // chart already has the background image

                    if (pgs.CurrentPage.YOffset + pi.Y + pi.H >= pgs.BottomOfPage && !pgs.CurrentPage.IsEmpty())
                    {   // force page break if it doesn't fit on the page
                        pgs.NextOrNew();
                        pgs.CurrentPage.YOffset = OwnerReport.TopOfPage;
                        if (this.YParents != null)
                        {
                            pi.Y = 0;
                        }
                    }

                    p = pgs.CurrentPage;

                    p.AddObject(pi);    // Put image onto the current page

                    RunPageRegionEnd(pgs);

                    if (!this.PageBreakAtEnd && !IsTableOrMatrixCell(rpt))
                    {
                        float newY = pi.Y + pi.H;
                        p.YOffset += newY;      // bump the y location
                    }
                    SetPagePositionEnd(pgs, pi.Y + pi.H);
                }
                else //Ultimate Rendering - Vector //AJM GJL 14082008
                {
                    System.Drawing.Imaging.Metafile im = cb.Image(rpt); // Grab the image
                    //im could still be saved to a bitmap at this point
                    //if we were to offer a choice of raster or vector, it would probably
                    //be easiest to draw the chart to the EMF and then save as bitmap if needed
                    int    height = im.Height;                                                  // save height and width
                    int    width  = im.Width;
                    byte[] ba     = cb._aStream.ToArray();
                    cb._aStream.Close();

                    PageImage pi = new PageImage(ImageFormat.Wmf, ba, width, height);
                    RunPageRegionBegin(pgs);

                    SetPagePositionAndStyle(rpt, pi, row);
                    pi.SI.BackgroundImage = null;       // chart already has the background image

                    if (pgs.CurrentPage.YOffset + pi.Y + pi.H >= pgs.BottomOfPage && !pgs.CurrentPage.IsEmpty())
                    {   // force page break if it doesn't fit on the page
                        pgs.NextOrNew();
                        pgs.CurrentPage.YOffset = OwnerReport.TopOfPage;
                        if (this.YParents != null)
                        {
                            pi.Y = 0;
                        }
                    }

                    p = pgs.CurrentPage;

                    //GJL 25072008 - Charts now draw in EMFplus format and not in bitmap. Still using the "PageImage" for the positioning
                    //paging etc, but we don't add it to the page.
                    // ******************************************************************************************************************
                    // New EMF Processing... we want to add the EMF Components to the page and not the actual EMF...
                    EMF emf = new EMF(pi.X, pi.Y, width, height);
                    emf.ProcessEMF(ba); //Process takes the bytearray of EMFplus data and breaks it down into lines,ellipses,text,rectangles
                    //etc... There are still a lot of GDI+ functions I haven't got to (and some I have no intention of getting to!).
                    foreach (PageItem emfItem in emf.PageItems)
                    {
                        p.AddObject(emfItem);
                    }
                    // ******************************************************************************************************************

                    //p.AddObject(pi);
                    RunPageRegionEnd(pgs);
                    pi.Y += p.YOffset;
                    if (!this.PageBreakAtEnd && !IsTableOrMatrixCell(rpt))
                    {
                        float newY = pi.Y + pi.H;
                        p.YOffset += newY;                // bump the y location
                    }
                    SetPagePositionEnd(pgs, pi.Y + pi.H); //our emf size seems to be bigger than the jpeg...
                }
            }
            catch (Exception ex)
            {
                rpt.rl.LogError(8, string.Format("Exception in Chart handling.\n{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                if (cb != null)
                {
                    cb.Dispose();
                }
            }

            return;
        }
Ejemplo n.º 10
0
		public void Chart(Chart c, Row r, ChartBase cb)
		{
			string relativeName;

			Stream io = _sg.GetIOStream(out relativeName, "png");
			try
			{
				cb.Save(this.r, io, ImageFormat.Png);
			}
			finally
			{
				io.Flush();
				io.Close();
			}
			
			relativeName = FixupRelativeName(relativeName);

			// Create syntax in a string buffer
			StringWriter sw = new StringWriter();

			string bookmark = c.BookmarkValue(this.r, r);
			if (bookmark != null)
				sw.WriteLine("<div id=\"{0}\">", bookmark);		// can't use the table id since we're using for css style

			string cssName = CssAdd(c.Style, c, null);	// get the style name for this item

			sw.Write("<img src=\"{0}\" class='{1}'", relativeName, cssName);
			string tooltip = c.ToolTipValue(this.r, r);
			if (tooltip != null)
				sw.Write(" alt=\"{0}\"", tooltip);
			if (c.Height != null)
				sw.Write(" height=\"{0}\"", c.Height.PixelsY.ToString());
			if (c.Width != null)
				sw.Write(" width=\"{0}\"", c.Width.PixelsX.ToString());
			sw.Write(">");
			if (bookmark != null)
				sw.Write("</div>");

			tw.Write(Action(c.Action, r, sw.ToString(), tooltip));
			
			return;
		}
Ejemplo n.º 11
0
        override internal void RunPage(Pages pgs, Row row)
        {
            Report rpt = pgs.Report;

            if (IsHidden(pgs.Report, row))
            {
                return;
            }

            _ChartMatrix.RunReset(rpt);
            Rows _Data = GetFilteredData(rpt, row);

            SetMyData(rpt, _Data);

            SetPagePositionBegin(pgs);

            if (!AnyRowsPage(pgs, _Data))                       // if no rows return
            {
                return;                                         //   nothing left to do
            }
            // Build the Chart bitmap, along with data regions
            Page      p  = pgs.CurrentPage;
            ChartBase cb = null;

            try
            {
                cb = RunChartBuild(rpt, row);                                   // Build the chart
                System.Drawing.Image im = cb.Image(rpt);                        // Grab the image
                int height = im.Height;                                         // save height and width
                int width  = im.Width;

                MemoryStream ostrm = new MemoryStream();
                im.Save(ostrm, IMAGEFORMAT);                    // generate a jpeg   TODO: get png to work with pdf

                byte[] ba = ostrm.ToArray();
                ostrm.Close();
                PageImage pi = new PageImage(IMAGEFORMAT, ba, width, height);                   // Create an image

                RunPageRegionBegin(pgs);

                SetPagePositionAndStyle(rpt, pi, row);
                pi.SI.BackgroundImage = null;                   // chart already has the background image

                if (pgs.CurrentPage.YOffset + pi.Y + pi.H >= pgs.BottomOfPage && !pgs.CurrentPage.IsEmpty())
                {                       // force page break if it doesn't fit on the page
                    pgs.NextOrNew();
                    pgs.CurrentPage.YOffset = OwnerReport.TopOfPage;
                    if (this.YParents != null)
                    {
                        pi.Y = 0;
                    }
                }

                p = pgs.CurrentPage;

                p.AddObject(pi);                        // Put image onto the current page

                RunPageRegionEnd(pgs);

                if (!this.PageBreakAtEnd && !IsTableOrMatrixCell(rpt))
                {
                    float newY = pi.Y + pi.H;
                    p.YOffset += newY;                          // bump the y location
                }
                SetPagePositionEnd(pgs, pi.Y + pi.H);
            }
            catch (Exception ex)
            {
                rpt.rl.LogError(8, string.Format("Exception in Chart handling.\n{0}\n{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                if (cb != null)
                {
                    cb.Dispose();
                }
            }

            return;
        }
Ejemplo n.º 12
0
 public virtual void Chart(Chart c, Row r, ChartBase cb)
 {
 }