Exemple #1
0
        private static void ProcessArguments(Options options)
        {
            var rectangles = options.Rectangles.Select(s => s.Split(',')).Select(x =>
                                                                                 new Size(int.Parse(x[0]), int.Parse(x[1])));
            var layouter   = new CircularCloudLayouter(new Point());
            var visualizer = new CloudVisualizer();

            new RectangleVisualizer(rectangles, layouter, visualizer).CreateCloudImage(options.ImagePath);
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            var maxSize    = new Size(80, 40);
            var minSize    = new Size(40, 20);
            var rectangles = RectanglesGenerator.GenerateRectangles(10, maxSize, minSize);
            var image      = CloudVisualizer.Visualize(rectangles.ToArray());

            image.Save("../../layout4.png");
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var width      = 1;
            var intesity   = double.Parse(args[0]);
            var visualiser = new CloudVisualizer();
            var layouter   = new CircularCloudLayouter(new Point(500, 500), intesity, new Size(1000, 1000));
            var testData   = MakeData(layouter, 150, width);

            visualiser.Visualise(testData, $"test{intesity}.png");
        }
Exemple #4
0
        static void Main(string[] args)
        {
            var testNumber = double.Parse(args[0]);
            var layouter   = new CircularCloudLayouter(new Point(500, 500));
            var testData   = CreateLayout(layouter, 500);
            var visualiser = new CloudVisualizer(layouter.CloudBorder.Size);

            visualiser.Visualise(testData, $"test{testNumber}.png");
            Process.Start($"test{testNumber}.png");
        }
Exemple #5
0
 public void TearDown()
 {
     if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
     {
         var visualizer = new CloudVisualizer(cloudLayouter);
         var path       = Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Tests")).FullName;
         path = Path.Combine(path, $"ID-{TestContext.CurrentContext.Test.ID}.png");
         visualizer.GetAndSaveImage(path);
         Console.WriteLine($"Tag cloud visualization saved to file {path}");
     }
 }
Exemple #6
0
        static void Main(string[] args)
        {
            var cloud      = new CircularCloudLayouter(new Point(0, 0));
            var visualizer = new CloudVisualizer(cloud);
            var random     = new Random();

            for (var i = 0; i < 500; i++)
            {
                cloud.PutNextRectangle(new Size(random.Next(1, 100), random.Next(1, 100)));
            }

            visualizer.GetAndSaveImage("haha.png");
        }
        public void TearDown()
        {
            if (!Equals(TestContext.CurrentContext.Result.Outcome, ResultState.Failure))
            {
                return;
            }
            var visualiser = new CloudVisualizer(cloudLayouter.CloudBorder.Size);
            var data       = cloudLayouter.GetRectangles();
            var name       = TestContext.CurrentContext.Test.Name + ".png";
            var path       = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, name);

            visualiser.Visualise(data, path);
            Console.WriteLine($"Tag cloud visualization saved to file {name}");
        }
Exemple #8
0
        public void MoveToImageCenter_ReturnsCorrectValue(int locationX,
                                                          int locationY,
                                                          int imageWidth,
                                                          int imageHeight,
                                                          int expectedX,
                                                          int expectedY)
        {
            var rectangle        = new Rectangle(locationX, locationY, 10, 10);
            var imageSize        = new Size(imageWidth, imageHeight);
            var expectedLocation = new Point(expectedX, expectedY);

            rectangle = CloudVisualizer.MoveToImageCenter(rectangle, imageSize);
            rectangle.Location.Should().Be(expectedLocation);
        }
Exemple #9
0
        public void TearDown()
        {
            if (TestContext.CurrentContext.Result.Outcome.Status != TestStatus.Failed)
            {
                return;
            }
            var test        = TestContext.CurrentContext.Test;
            var layoutImage = CloudVisualizer.Visualize(_circularCloudLayouter.Rectangles.ToArray(), true);

            var pathToImage     = $@"FallenTests\{test.MethodName}.{test.Name}.png";
            var pathToDirectory = TestContext.CurrentContext.TestDirectory + @"\..\..\";

            layoutImage.Save(pathToDirectory + pathToImage);
            TestContext.Write($"Layout saved to {pathToImage}");
        }
Exemple #10
0
        public void CalculateImageSize_ReturnsCorrectSize()
        {
            var rectangleSize = new Size(10, 10);
            var locations     = new[]
            {
                new Point(-10, 10),
                new Point(0, 10),
                new Point(0, 0),
                new Point(-10, 0),
            };
            var       rectangles        = locations.Select(location => new Rectangle(location, rectangleSize));
            const int imagePadding      = CloudVisualizer.RectangleBorderWidth;
            var       expectedImageSize = new Size(20 + imagePadding, 20 + imagePadding);

            var actualImageSize = CloudVisualizer.CalculateImageSize(rectangles);

            actualImageSize.Should().Be(expectedImageSize);
        }
Exemple #11
0
        public void GetAbsoluteMax_ReturnsCorrectValue(int number1, int number2, int number3, int expectedValue)
        {
            var actualValue = CloudVisualizer.GetAbsoluteMax(number1, number2, number3);

            actualValue.Should().Be(expectedValue);
        }