Ejemplo n.º 1
0
        public void CreateBitmapWithWords(IEnumerable <string> text, string path)
        {
            var stats = Preprocessor.Processing(text);

            DeterminatorOfWordSize.SetParameters(stats);
            CloudLayouter.SetCloudSetting(Settings.Width, Settings.Height, Settings.CenterPoint);
            var words = stats.Select(tuple => new WordInformation(tuple.Key, tuple.Value)).OrderByDescending(x => x.Frequency);

            Bitmap   bitmap = new Bitmap(Settings.Width, Settings.Height);
            Graphics g      = Graphics.FromImage(bitmap);

            g.Clear(Settings.BackgroundColor);
            foreach (var wordInformation in words)
            {
                var font    = DeterminatorOfWordSize.GetFont(wordInformation, Settings.Fontname);
                var size    = g.MeasureString(wordInformation.Content, font);
                var bigSize = new Size((int)Math.Ceiling(size.Width), (int)Math.Ceiling(size.Height));
                if (!CloudLayouter.TryPutNextRectangle(bigSize))
                {
                    break;
                }
                var rectangle = CloudLayouter.LastPlacedRectangle;
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
                g.DrawString(wordInformation.Content, font,
                             new SolidBrush(Settings.AlgorithmOfColoringWords.GetColor(wordInformation, Settings.Colors)), rectangle);
            }

            CloudLayouter.RemovePlacedRectangles();
            bitmap.Save(path, Settings.ImageFormat);
        }
Ejemplo n.º 2
0
        public void InitializeTests()
        {
            center = new Point(1000, 1000);
            var spiral = new ArchimedesSpiral(center);

            cloudLayouter = new CloudLayouter(spiral);
        }
Ejemplo n.º 3
0
        public void SetUp()
        {
            const double distanceBetweenLoops = 0.2;
            const double angleDelta           = 1;

            RectangleVisualizer = new RectangleVisualizer();
            Center = new Point(300, 300);
            Sut    = new CloudLayouter(new ArchimedeanSpiral(Center, distanceBetweenLoops, angleDelta));
        }
Ejemplo n.º 4
0
        public void NextRectangleMustByFartherFromCenter(IEnumerable <Size> rectanglesSizes)
        {
            var center       = new Point(0, 0);
            var cloud        = new CloudLayouter(new ArchimedesSpiral(center));
            var lastDistance = 0.0;

            foreach (var rectangleSize in rectanglesSizes)
            {
                var rectangle = cloud.PutNextRectangle(rectangleSize).GetValueOrThrow();
                var distance  = rectangle.GetDistanceToPoint(center);
                distance.Should().BeGreaterOrEqualTo(lastDistance);

                lastDistance = distance;
            }
        }
Ejemplo n.º 5
0
        public void Constructor_ShouldCreateLayouterWithCenter()
        {
            var layouter = new CloudLayouter(strategies);

            layouter.Center.Should().Be(new Point(0, 0));
        }
Ejemplo n.º 6
0
        public void SetUp()
        {
            var point = new Point(0, 0);

            layouter = new CloudLayouter(strategies);
        }
Ejemplo n.º 7
0
 public void CreateNewLayouter_WhenPointIsPassed()
 {
     layouter = new CloudLayouter(new Point(20, 20), 1);
 }
Ejemplo n.º 8
0
 public void SetUp()
 {
     layouter = new CloudLayouter(new Point(20, 20), 1);
 }