Пример #1
0
        /// <summary>
        /// Implementation for <see cref="SaveCommand" />.
        /// Creates the project.
        /// </summary>
        private void SaveImpl()
        {
            // Path verification
            var file = new FileInfo(Path);

            if (!Directory.Exists(file.DirectoryName))
            {
                Directory.CreateDirectory(file.DirectoryName);
            }

            // TODO: Save plot, according to settings - QuadTree stuff...
            //if (this.ShowAllData)

            var encoder = new PngPlotModelEncoder();
            var size    = new Size(Width, Height);

            if (DPI.Equals(96))
            {
                encoder.SaveImage(this.plot, Path, size);
            }
            else
            {
                encoder.SaveImageHighRes(this.plot, Path, size, dpi);
            }

            if (this.Complete != null)
            {
                this.Complete(this, EventArgs.Empty);
            }
        }
Пример #2
0
        /// <summary>
        ///     Save the plots to the specified path, with a specified width, height, and dpi
        /// </summary>
        /// <remarks>If the DPI is not 96, the width and height will be scaled so that the image
        /// provides the needed pixel size for the specified size and DPI</remarks>
        /// <param name="pathAndPrefix">Path to save the images to, with a trailing '\' or name prefix</param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="dpi"></param>
        public void SavePlots(string pathAndPrefix, double width, double height, double dpi)
        {
            var encoder = new PngPlotModelEncoder();
            var size    = new Size(width, height);

            if (dpi.Equals(96))
            {
                encoder.SaveImage(this.Heatmap.Model, pathAndPrefix + "Heatmap.png", size);
                encoder.SaveImage(this.NetResidual.Model, pathAndPrefix + "NetScan.png", size);
                encoder.SaveImage(this.MassHistogram.Model, pathAndPrefix + "MassHistogram.png", size);
                encoder.SaveImage(this.NetHistogram.Model, pathAndPrefix + "NetHistogram.png", size);
                encoder.SaveImage(this.MassMzResidual.Model, pathAndPrefix + "MassMz.png", size);
                encoder.SaveImage(this.MassScanResidual.Model, pathAndPrefix + "MassScan.png", size);
            }
            else
            {
                encoder.SaveImageHighRes(this.Heatmap.Model, pathAndPrefix + "Heatmap.png", size, dpi);
                encoder.SaveImageHighRes(this.NetResidual.Model, pathAndPrefix + "NetScan.png", size, dpi);
                encoder.SaveImageHighRes(this.MassHistogram.Model, pathAndPrefix + "MassHistogram.png", size, dpi);
                encoder.SaveImageHighRes(this.NetHistogram.Model, pathAndPrefix + "NetHistogram.png", size, dpi);
                encoder.SaveImageHighRes(this.MassMzResidual.Model, pathAndPrefix + "MassMz.png", size, dpi);
                encoder.SaveImageHighRes(this.MassScanResidual.Model, pathAndPrefix + "MassScan.png", size, dpi);
            }
        }
Пример #3
0
        public void TestSimpleCreation()
        {
            var plotModel1 = new PlotModel
            {
                PlotType = PlotType.Cartesian,
                Subtitle = "Interpolated, cartesian axes",
                Title    = "HeatMapSeries"
            };

            var palette          = OxyPalettes.Hot(200);
            var linearColorAxis1 = new LinearColorAxis
            {
                InvalidNumberColor = OxyColors.Gray,
                Position           = AxisPosition.Right,
                Palette            = palette
            };

            plotModel1.Axes.Add(linearColorAxis1);

            var linearAxis1 = new LinearAxis {
                Position = AxisPosition.Bottom
            };

            plotModel1.Axes.Add(linearAxis1);
            var linearAxis2 = new LinearAxis();

            plotModel1.Axes.Add(linearAxis2);
            var heatMapSeries1 = new HeatMapSeries
            {
                X0       = 0.0,
                X1       = 1.0,
                Y0       = 0.0,
                Y1       = 1.0,
                FontSize = .2,
                Data     = new Double[2, 3]
            };

            //heatMapSeries1.LabelFontSize = 0.2;
            heatMapSeries1.Data[0, 0] = 0;
            heatMapSeries1.Data[0, 1] = 10.2;
            heatMapSeries1.Data[0, 2] = 20.4;
            heatMapSeries1.Data[1, 0] = 0.1;
            heatMapSeries1.Data[1, 1] = 0.3;
            heatMapSeries1.Data[1, 2] = 0.2;
            plotModel1.Series.Add(heatMapSeries1);

            var svg       = new SvgExporter();
            var svgString = svg.ExportToString(plotModel1);

            var xml = new XmlDocument();

            xml.LoadXml(svgString);
            var x   = SvgDocument.Open(xml); // Svg.SvgDocument();
            var bmp = x.Draw();

            bmp.Save(GetPath(HEATMAP_RESULTS_FOLDER_BASE + "testbmp.jpg"));

            var encoder = new PngPlotModelEncoder();

            encoder.SaveImage(plotModel1, GetPath(HEATMAP_RESULTS_FOLDER_BASE + "mine.png"));
        }
Пример #4
0
        public void TestSimpleCreation()
        {
            var plotModel1 = new PlotModel
            {
                PlotType = PlotType.Cartesian,
                Subtitle = "Interpolated, cartesian axes",
                Title = "HeatMapSeries"
            };

            var palette = OxyPalettes.Hot(200);
            var linearColorAxis1 = new LinearColorAxis
            {
                InvalidNumberColor = OxyColors.Gray,
                Position = AxisPosition.Right,
                Palette = palette
            };

            plotModel1.Axes.Add(linearColorAxis1);

            var linearAxis1 = new LinearAxis {Position = AxisPosition.Bottom};
            plotModel1.Axes.Add(linearAxis1);
            var linearAxis2 = new LinearAxis();
            plotModel1.Axes.Add(linearAxis2);
            var heatMapSeries1 = new HeatMapSeries
            {
                X0 = 0.0,
                X1 = 1.0,
                Y0 = 0.0,
                Y1 = 1.0,
                FontSize = .2,
                Data = new Double[2, 3]
            };
            //heatMapSeries1.LabelFontSize = 0.2;
            heatMapSeries1.Data[0, 0] = 0;
            heatMapSeries1.Data[0, 1] = 10.2;
            heatMapSeries1.Data[0, 2] = 20.4;
            heatMapSeries1.Data[1, 0] = 0.1;
            heatMapSeries1.Data[1, 1] = 0.3;
            heatMapSeries1.Data[1, 2] = 0.2;
            plotModel1.Series.Add(heatMapSeries1);

            var svg = new SvgExporter();
            var svgString = svg.ExportToString(plotModel1);

            var xml = new XmlDocument();
            xml.LoadXml(svgString);
            var x = SvgDocument.Open(xml); // Svg.SvgDocument();
            var bmp = x.Draw();
            bmp.Save(GetPath(HEATMAP_RESULTS_FOLDER_BASE + "testbmp.jpg"));

            var encoder = new PngPlotModelEncoder();
            encoder.SaveImage(plotModel1, GetPath(HEATMAP_RESULTS_FOLDER_BASE + "mine.png"));
        }