コード例 #1
0
        public static CarboProject CreateIntensityHeatMap(CarboProject carboProject,
                                                          System.Drawing.Color minOutColour, System.Drawing.Color maxOutColour, System.Drawing.Color minRangeColour, System.Drawing.Color midRangeColour, System.Drawing.Color maxRangeColour,
                                                          double standardNr = 2)
        {
            carboProject.clearHeatmapAndValues();
            carboProject.CalculateProject();

            List <CarboElement> bufferList = carboProject.getTemporaryElementListWithTotals();
            List <double>       valuelist  = new List <double>();

            //List<double> valueRangelist = new List<double>();

            //Get a List<double> for only the calculated values.
            foreach (CarboElement carboElement in bufferList)
            {
                valuelist.Add(carboElement.ECI_Total);
            }

            double mean        = valuelist.Average();
            double standardDev = CalculateStandardDeviation(valuelist);
            double max         = mean + (standardDev * standardNr);
            double min         = mean - (standardDev * standardNr);

            double maxRange = 0;
            double minRange = 0;

            bool first = true;

            foreach (double value in valuelist)
            {
                if (value >= min && value <= max)
                {
                    if (first == true)
                    {
                        maxRange = value;
                        minRange = value;
                        first    = false;
                    }

                    //valueRangelist.Add(value);

                    if (value > maxRange)
                    {
                        maxRange = value;
                    }
                    if (value < minRange)
                    {
                        minRange = value;
                    }
                }
                else
                {
                    double v = value;
                }
            }
            string text = "Setting Values:" + Environment.NewLine
                          + "mean: " + mean + Environment.NewLine
                          + "standard dev: " + standardDev + Environment.NewLine
                          + "max: " + max + Environment.NewLine
                          + "min: " + min + Environment.NewLine + Environment.NewLine
                          + "maxRange: " + maxRange + Environment.NewLine
                          + "minRange: " + minRange + Environment.NewLine;

            //MessageBox.Show(text);
            //This should be embedded in a single iteration
            //maxRange = valueRangelist.Max();
            // minRange = valueRangelist.Min();

            //Possibly split the range to min and maxes.
            //See how big the extreems are...
            //
            foreach (CarboGroup grp in carboProject.getGroupList)
            {
                List <CarboElement> elements = grp.AllElements;
                foreach (CarboElement cel in elements)
                {
                    //See if this elements falls within the range.
                    double ECI = cel.ECI_Total;

                    if (ECI > maxRange)
                    //Over the max
                    {
                        // Apply Max Colour (Purple for now)
                        cel.r = maxOutColour.R;
                        cel.g = maxOutColour.G;
                        cel.b = maxOutColour.B;
                    }
                    else if (ECI < minRange)
                    {
                        // Apply Min Colour
                        cel.r = minOutColour.R;
                        cel.g = minOutColour.G;
                        cel.b = minOutColour.B;
                    }
                    else
                    {
                        //Within range, calculate value.
                        System.Drawing.Color groupColour = Utils.GetBlendedColor(maxRange, minRange, ECI, minRangeColour, midRangeColour, maxRangeColour);
                        cel.r = groupColour.R;
                        cel.g = groupColour.G;
                        cel.b = groupColour.B;
                    }
                }
            }

            return(carboProject);
        }