Exemple #1
0
        /// <summary>
        /// Metoda wypełniająca komórki o secie X wartością funkcji s(X)
        /// </summary>
        /// <param name="s">Funkcja transformująca</param>
        /// <param name="stateCount">Ilość możliwych wartości</param>
        internal void Transform(StateTransformation s, int stateCount = SPDAssets.MAX)
        {
            for (int i = 0; i < stateCount; i++)
            {
                Fill(i, s(i));
            }
            List <List <InitialConditionCell> > cells = new List <List <InitialConditionCell> >();

            while (cells.Count < stateCount)
            {
                cells.Add(new List <InitialConditionCell>());
            }
            for (int i = 0; i < CellGrid.GetLength(0); i++)
            {
                for (int j = 0; j < CellGrid.GetLength(1); j++)
                {
                    CellGrid[i, j].Set = CellGrid[i, j].Value;
                    while (cells.Count < CellGrid[i, j].Set + 1)
                    {
                        cells.Add(new List <InitialConditionCell>());
                    }
                    cells[CellGrid[i, j].Set].Add(CellGrid[i, j]);
                }
            }
            CellSets = cells.Select(x => x.ToArray()).ToArray();
        }
Exemple #2
0
        /// <summary>
        /// Metoda generuje obrazek legendy
        /// </summary>
        /// <param name="height">Wysokość canvasa dla legendy</param>
        /// <param name="stateCount">Ilość kolorów</param>
        /// <param name="SF">Predykat wyboru kolorów</param>
        /// <returns>Obrazek legendy</returns>
        public static Image GenerateLegend(double height, int stateCount, StateTransformation SF)
        {
            var dg   = new DrawingGroup();
            var text = new FormattedText(GetDescription(SF(0), stateCount),
                                         CultureInfo.CurrentCulture,
                                         FlowDirection.LeftToRight,
                                         new Typeface(_font),
                                         (-3.0 * stateCount + 810) / 52,
                                         Brushes.Black);
            var gd2 = new GeometryDrawing
            {
                Pen      = new Pen(Brushes.Black, 1),
                Brush    = Brushes.Black,
                Geometry = text.BuildGeometry(new Point(22, 0))
            };

            dg.Children.Add(gd2);
            text = new FormattedText(GetDescription(SF(stateCount - 1), stateCount),
                                     CultureInfo.CurrentCulture,
                                     FlowDirection.LeftToRight,
                                     new Typeface(_font),
                                     (-3.0 * stateCount + 810) / 52,
                                     Brushes.Black);
            gd2 = new GeometryDrawing
            {
                Pen      = new Pen(Brushes.Black, 1),
                Brush    = Brushes.Black,
                Geometry = text.BuildGeometry(new Point(22, (stateCount - 1) * (height / stateCount)))
            };
            dg.Children.Add(gd2);
            for (var i = 0; i < stateCount; i++)
            {
                var rg = new RectangleGeometry(new Rect(new Point(0, i * (height / stateCount)), new Point(20, (i + 1) * (height / stateCount))));

                var gd = new GeometryDrawing
                {
                    Brush    = GetBrush(SF(i)),
                    Geometry = rg,
                    Pen      = new Pen(Brushes.Black, 0)
                };

                dg.Children.Add(gd);
            }
            var d = new DrawingImage(dg);

            d.Freeze();
            return(new Image()
            {
                Source = d,
            });
        }
Exemple #3
0
        /// <summary>
        /// Metoda zwraca prostokąty zawierające kolory wykresu
        /// </summary>
        /// <param name="stateCount"> Ilość kolorów </param>
        /// <param name="SF">Predykat wyboru kolorów</param>"
        /// <returns>Lista prostokątów</returns>
        public static List <Image> GetBrushRectangles(int stateCount, StateTransformation SF)
        {
            List <Brush> brushes = new List <Brush>();

            for (int i = 0; i < stateCount; i++)
            {
                brushes.Add(_brushArray[SF(i)]);
            }
            return(brushes.Select(s =>
            {
                var rg = new RectangleGeometry(new Rect(new Point(0, 0), new Point(30, 15)));
                var gd = new GeometryDrawing(s, new Pen(s, 1), rg);
                var di = new DrawingImage(gd);
                return new Image {
                    Source = di
                };
            }).ToList());
        }
 /// <summary>
 /// Metoda wypełniająca komórki o secie X wartością funkcji s(X)
 /// </summary>
 /// <param name="s">Funkcja transformująca</param>
 /// <param name="stateCount">Ilość możliwych wartości</param>
 internal void Transform(StateTransformation s,int stateCount=SPDAssets.MAX)
 {
     for(int i=0;i<stateCount;i++) Fill(i,s(i));
     List<List<InitialConditionCell>> cells = new List<List<InitialConditionCell>>();
     while (cells.Count < stateCount)
     {
         cells.Add(new List<InitialConditionCell>());
     }
     for(int i =0;i<CellGrid.GetLength(0);i++)
         for (int j = 0; j < CellGrid.GetLength(1); j++)
         {
             CellGrid[i, j].Set = CellGrid[i, j].Value;
             while (cells.Count < CellGrid[i, j].Set+1)
             {
                 cells.Add(new List<InitialConditionCell>());
             }
             cells[CellGrid[i, j].Set].Add(CellGrid[i, j]);
         }
     CellSets = cells.Select(x => x.ToArray()).ToArray();
 }