private void FillLayouter(ILayouter layouter, IEnumerable <GraphicString> words) { using var gForMeasure = Graphics.FromImage(new Bitmap(1, 1)); foreach (var word in words) { var font = new Font(fontFamily, word.FontSize); var size = gForMeasure.MeasureString(word.Value, font); layouter.PutNextRectangle(size); } }
private Tuple <string, Rectangle> GetTag(KeyValuePair <string, double> pair, int canvasHeight, int tagsCount) { var frequency = pair.Value; var tagString = pair.Key; var height = (int)Math.Round(canvasHeight * Math.Sqrt(frequency / heightCoefficient)); var width = (int)Math.Round((double)height * (tagString.Length) * widthCoefficient); var rectangle = layouter.PutNextRectangle(new Size(width, height)); return(new Tuple <string, Rectangle>(tagString, rectangle)); }
private IEnumerable <Tag> PlaceTags(IEnumerable <Tag> tags) { foreach (var tag in tags) { var tagSize = GetTagSize(tag); tag.Rectangle = layouter.PutNextRectangle(tagSize); } return(tags); }
public void PlaceWords(Dictionary <string, int> words) { layouter.SetCenter(new Point(imageOptions.Width / 2, imageOptions.Height / 2)); foreach (var(word, count) in words) { var fontSize = CalculateFontSize(count); var rectangle = layouter.PutNextRectangle(GetWordSize(word, fontSize, fontOptions.FontFamily)); drawer.AddRectangle(new WordRectangle(rectangle, word, fontSize, fontOptions.FontFamily, fontOptions.FontColor)); } }
public void PutNextWord(Word word, Size size, int fontSize, Brush wordColor, string fontName) { var foundRect = Rectangle.Empty; while (foundRect == Rectangle.Empty || CheckIntersectionWithExistigRectangles(foundRect)) { foundRect = layouter.PutNextRectangle(size); } foundRect = MoveRectangleToCenter(foundRect); LayouterComponents.Add(new LayouterComponent(word, foundRect, fontSize, wordColor, fontName)); UpdateBordersAndSize(foundRect); }
public void Draw(Dictionary <string, int> words) { var wordsRectangles = new Dictionary <string, Rectangle>(); foreach (var wordInfo in words) { var size = imageSettings.TextRenderer.GetRectangleSize(imageSettings, wordInfo); var rectangle = circularCloudLayouter.PutNextRectangle(size); wordsRectangles.Add(wordInfo.Key, rectangle); } var width = imageSettings.ImageSize.Width == 0 ? wordsRectangles.Max(elem => elem.Value.X) : imageSettings.ImageSize.Width; var height = imageSettings.ImageSize.Height == 0 ? wordsRectangles.Max(elem => elem.Value.Y) : imageSettings.ImageSize.Height; imageSettings.TextRenderer.PrintWords((int)width, (int)height, wordsRectangles, imageSettings); }