Exemple #1
0
 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);
     }
 }
Exemple #2
0
        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));
        }
Exemple #3
0
        private IEnumerable <Tag> PlaceTags(IEnumerable <Tag> tags)
        {
            foreach (var tag in tags)
            {
                var tagSize = GetTagSize(tag);
                tag.Rectangle = layouter.PutNextRectangle(tagSize);
            }

            return(tags);
        }
Exemple #4
0
 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));
     }
 }
Exemple #5
0
        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);
        }
Exemple #6
0
        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);
        }