Exemplo n.º 1
0
        public void TearDown()
        {
            var context = TestContext.CurrentContext;

            if (context.Result.Outcome.Status != TestStatus.Failed)
            {
                return;
            }

            var dir = Path.Combine(context.TestDirectory, "Failed layouts");

            Directory.CreateDirectory(dir);
            var file = Path.ChangeExtension(context.Test.Name, "png");
            var path = Path.Combine(dir, file);

            var layouter   = GetTestProperty <CircularCloudLayouter>(LayouterKey);
            var visualizer = new CircularCloudVisualizer();

            using (var bitmap = visualizer.Visualize(layouter.Rectangles))
            {
                bitmap.Save(path);
            }

            TestContext.WriteLine($"Tag cloud visualization saved to file {path}");
        }
Exemplo n.º 2
0
        private static Bitmap CreateBitmap(int count, Func <int, Tag> fabric)
        {
            var layouter   = new CircularCloudLayouter(Center);
            var tags       = Enumerable.Range(0, count).Select(fabric).ToArray();
            var visualizer = new CircularCloudVisualizer();

            return(visualizer.Visualize(layouter, tags));
        }
Exemplo n.º 3
0
        private static void DrawTagCloudWithEqualRectangles()
        {
            var sizes      = Enumerable.Repeat(new Size(50, 50), 100).ToArray();
            var layouter   = new CircularCloudLayouter(Center);
            var visualizer = new CircularCloudVisualizer();
            var bitmap     = visualizer.Visualize(layouter, sizes);

            bitmap.Save("equal_rectangles.png");
        }
Exemplo n.º 4
0
        public static void DrawDefaultRectangleCloud()
        {
            var random     = new Random();
            var rectangles = new List <Rectangle>();
            var layout     = new CircularCloudLayouter();

            rectangles.Add(layout.PutNextRectangle(new Size(800, 200)));
            for (var i = 0; i < 100; i++)
            {
                var randomSize   = new Size(random.Next(150, 200), random.Next(75, 100));
                var newRectangle = layout.PutNextRectangle(randomSize);
                rectangles.Add(newRectangle);
            }
            var visualizer = new CircularCloudVisualizer(rectangles);
            var bitmap     = visualizer.GetTagCloudImage();

            bitmap.Save("100_rectangles.png");
        }
Exemplo n.º 5
0
        private static Bitmap GetCloudImageFromRandomRectangles(int rectanglesCount)
        {
            var visualizer = new CircularCloudVisualizer(new CircularCloudLayouter());
            var random     = new Random();

            for (int i = 0; i < rectanglesCount; i++)
            {
                Size nextRectSize;

                do
                {
                    nextRectSize = new Size(random.Next(200) + 100, random.Next(100) + 100);
                } while (nextRectSize.Width < nextRectSize.Height * 2);

                visualizer.Layouter.PutNextRectangle(nextRectSize);
            }

            return(visualizer.GetCloudImage());
        }
Exemplo n.º 6
0
 public void SetUp()
 {
     layouter   = new CircularCloudLayouter();
     rectangles = new List <Rectangle>();
     visualizer = new CircularCloudVisualizer(layouter);
 }