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); }
public void InitializeTests() { center = new Point(1000, 1000); var spiral = new ArchimedesSpiral(center); cloudLayouter = new CloudLayouter(spiral); }
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)); }
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; } }
public void Constructor_ShouldCreateLayouterWithCenter() { var layouter = new CloudLayouter(strategies); layouter.Center.Should().Be(new Point(0, 0)); }
public void SetUp() { var point = new Point(0, 0); layouter = new CloudLayouter(strategies); }
public void CreateNewLayouter_WhenPointIsPassed() { layouter = new CloudLayouter(new Point(20, 20), 1); }
public void SetUp() { layouter = new CloudLayouter(new Point(20, 20), 1); }