Ejemplo n.º 1
0
        private static void PlotOut(PlotWindow plotWindow, IEnumerable <double> list, double minPoint, double maxPoint, DrawType drawType, SolidColorBrush solidColorBrush)
        {
            IList <double> _list = new List <double>(list);

            ICollection <double> _listWithMaxMin = new List <double>(list);

            _listWithMaxMin.Add(minPoint);
            _listWithMaxMin.Add(maxPoint);

            _listWithMaxMin = StatisticsLib.NormalizeWidthOfValue(_listWithMaxMin);
            _listWithMaxMin = StatisticsLib.NormalizeAbsWidthOfValue(_listWithMaxMin);
            IList <double> listWithMaxMin = new List <double>(_listWithMaxMin);

            double count = listWithMaxMin.Count - 3;

            for (int i = 0; i < listWithMaxMin.Count - 2; i++)
            {
                double node = listWithMaxMin[i];
                Pair   pair = new Pair(i / count, 1 - node);
                if (drawType == DrawType.NormalPlot || i == 0)
                {
                    plotWindow.AddPlot(pair, _list[i], drawType, solidColorBrush);
                }
                else if (drawType == DrawType.BarGraph)
                {
                    plotWindow.AddPlot(pair, _list[i], drawType, solidColorBrush, new Pair(i / count, 1));
                }
                else
                {
                    plotWindow.AddPlot(pair, _list[i], drawType, solidColorBrush, new Pair((i - 1) / count, 1 - listWithMaxMin[i - 1]));
                }
            }
        }
Ejemplo n.º 2
0
        private static void DrawGuideLine(PlotWindow plotWindow, IEnumerable <double> baseLines, double minPoint, double maxPoint)
        {
            double dis     = Math.Abs(maxPoint - minPoint);
            double addLine = 0;

            if (minPoint - minPoint > 0)
            {
                addLine             = Math.Abs(minPoint - minPoint);
                plotWindow.baseLine = addLine / dis;
            }
            plotWindow.ResetBaseLine(0, minPoint);

            foreach (var node in baseLines)
            {
                if (node == minPoint)
                {
                    continue;
                }

                plotWindow.ResetBaseLine((node - minPoint + addLine) * (1 / dis), node);
            }
        }
Ejemplo n.º 3
0
        public static Task Create(string msg, IEnumerable <PlotInfo> plotInfos, IEnumerable <double> baseLines)
        {
            if (plotInfos is null)
            {
                return(null);
            }

            if (baseLines is null)
            {
                baseLines = new List <double>()
                {
                    0
                };
            }

            var allList       = new List <double>(baseLines);
            int baseLineCount = allList.Count;

            foreach (var plotInfo in plotInfos)
            {
                if (plotInfo is null)
                {
                    continue;
                }

                if (plotInfo.list.Count < 2)
                {
                    continue;
                }

                allList.AddRange(plotInfo.list);
            }

            if (allList.Count == baseLineCount)
            {
                return(null);
            }

#if false   // あまり意味が無さそう
            var tasks2 = new List <Task <double> >();
            tasks2.Add(Task.Run(() => StatisticsLib.MinInTheList(allList)));
            tasks2.Add(Task.Run(() => StatisticsLib.MaxInTheList(allList)));
            var    aaaa     = Task.WhenAll(tasks2).Result;
            double minPoint = aaaa[0];
            double maxPoint = aaaa[1];
#else
            double minPoint = StatisticsLib.Min(allList);
            double maxPoint = StatisticsLib.Max(allList);
#endif
            allList.Clear();
            allList = null;

            var _baseLines = new List <double>(baseLines);
            if (_baseLines.Count == 0)
            {
                _baseLines.Add(minPoint);
                _baseLines.Add(maxPoint);
                _baseLines.Add(0);
            }
            baseLines = null;

            PlotWindow plotWindow = new PlotWindow();
            plotWindow.Owner = CommandCanvasList.OwnerWindow;

            plotWindow.Dispatcher.BeginInvoke(new Action(() =>
            {
                ControlTools.SetWindowPos(plotWindow, null);
            }), DispatcherPriority.Loaded);

            plotWindow.Title = "Plot";
            if (msg != null && msg.Trim() != "")
            {
                plotWindow.Title += ": " + msg;
            }
            plotWindow.Show();

            DrawGuideLine(plotWindow, _baseLines, minPoint, maxPoint);

            var tasks = new List <Task>();
            foreach (var plotInfo in plotInfos)
            {
                if (plotInfo is null)
                {
                    continue;
                }

                var task = Task.Run(() => PlotOut(plotWindow, plotInfo.list, minPoint, maxPoint, plotInfo.drawType, plotInfo.solidColorBrush));
                tasks.Add(task);
            }
            return(Task.WhenAll(tasks));
        }