public ColorMapPlateMap(double[] DataForColors)
        {
            cData  = DataForColors;
            Colors = new Color[DataForColors.Length];
            var    Data     = from x in cData where SimpleFunctions.IsARealNumber(x) select x;
            var    realData = Data.ToArray();
            double min      = SimpleFunctions.MinNotZero(realData);
            double max      = realData.Max();

            //Cmap = new ColorMap(SimpleFunctions.MinNotZero(realData), SimpleFunctions.Max(realData), true);
            for (int i = 0; i < DataForColors.Length; i++)
            {
                if (!SimpleFunctions.IsARealNumber(DataForColors[i]))
                {
                    DataForColors[i] = 0.0;
                }
                Colors[i] = ColorMaps.SpringColorFn(DataForColors[i], min, max);
            }
            makeSquares();
            this.Refresh();
        }
Example #2
0
        public void makeSquares(double[] DataToSquare)
        {
            Graphics g = Graphics.FromImage(TheColoredSquaresBM);

            g.Clear(System.Drawing.Color.White);
            //ColorMap Cmap = new ColorMap(0,1);

            //ColorMap Cmap = new ColorMap(SimpleFunctions.Min(DataToSquare), SimpleFunctions.Max(DataToSquare),false);
            //USE THE ONE UNDERNEATH
            //now going to make data so it excludes NaN
            var    Data     = from x in DataToSquare where SimpleFunctions.IsARealNumber(x) select x;
            var    realData = Data.ToArray();
            double min      = SimpleFunctions.MinNotZero(realData);
            double max      = realData.Max();
            //ColorMap Cmap = new ColorMap(SimpleFunctions.MinNotZero(realData), SimpleFunctions.Max(realData),true);
            //ColorMap Cmap = new ColorMap(0, 1, true);

            //Color[] ColorNums =new Color[96];
            //for(int i=0;i<96;i++)
            //{ ColorNums[i]=Cmap.GetColor(i);}
            SolidBrush BlackBrush = new SolidBrush(Color.Black);
            Pen        P          = new Pen(Color.Black, 5);
            SolidBrush sb         = new SolidBrush(Color.Blue);

            try
            {
                int YPos = RoomForText;
                int XPos = RoomForText;

                for (int i = 1; i <= NumCols; i++)
                {
                    g.DrawString(i.ToString(), FontofControl, BlackBrush, ((float)(RoomForText + (SideLength * .25) + SideLength * (i - 1))), 0);
                }
                string Rows = "ABCDEFGH";
                Rows = Rows.Substring(0, NumRows);
                for (int i = 0; i < NumRows; i++)
                {
                    g.DrawString(Rows[i].ToString(), FontofControl, BlackBrush, 0, ((float)(RoomForText + (SideLength * .35) + SideLength * i)));
                }

                int[,] TextPos = new int[NumWells, 2];
                Rectangle[] PlateWells = new Rectangle[NumWells];

                for (int i = 0; i < NumWells; i++)
                {
                    double colToSquare = DataToSquare[i];
                    if (!SimpleFunctions.IsARealNumber(colToSquare))
                    {
                        colToSquare = 0.0;
                    }
                    sb = new SolidBrush(ColorMaps.SpringColorFn(colToSquare, min, max));
                    if (UseBinaryColorScheme)
                    {
                        sb = new SolidBrush(ColorMaps.BinaryColorFunGetColor(colToSquare));
                    }
                    int ColPos  = i % NumCols;
                    int rowPos  = Convert.ToInt32((i / NumCols));
                    int RecYPos = YPos + SideLength * rowPos;
                    int RecXPos = XPos + SideLength * ColPos;
                    TextPos[i, 0] = (int)(RecXPos + SideLength * .15);
                    TextPos[i, 1] = (int)(RecYPos + (SideLength / 2) - (FontofControl.Height / 2));
                    PlateWells[i] = new Rectangle(RecXPos, RecYPos, SideLength, SideLength);
                    g.FillRectangle(sb, PlateWells[i]);
                }
                g.DrawRectangles(P, PlateWells);
                //now to add text over it
                if (AddText)
                {
                    for (int i = 0; i < NumWells; i++)
                    {
                        string toWrite = DataToSquare[i].ToString("n4");
                        if (DataToSquare[i] > 100)
                        {
                            int Value = (int)DataToSquare[i];
                            toWrite = Value.ToString();
                        }
                        g.DrawString(toWrite, FontofControl, BlackBrush, TextPos[i, 0], TextPos[i, 1]);
                    }
                }
            }
            finally { g.Dispose(); BlackBrush.Dispose(); P.Dispose(); sb.Dispose(); }
        }