示例#1
0
        private Result <IEnumerable <Tag> > CheckTagsFitOnImage(IRectanglesLayouter layouter, IEnumerable <Tag> tags)
        {
            tags = tags.ToList();
            var layoutSize  = layouter.GetLayoutSize();
            var subtraction = imageConfig.ImageSize - layoutSize;

            if (subtraction.Width < 0 || subtraction.Height < 0)
            {
                return(Result.Fail <IEnumerable <Tag> >(
                           $"Cloud out of size image:\n Cloud size: {layoutSize}\n Image size: {imageConfig.ImageSize}"));
            }
            return(Result.Ok(tags));
        }
示例#2
0
        private Result <IEnumerable <Tag> > GetTagsFormWords(IRectanglesLayouter layouter, IEnumerable <WordInfo> words)
        {
            var count = 30;

            return(Result.Ok(words.OrderByDescending(info => info.Frequence)
                             .Take(count)
                             .Select((wordInfo, index) =>
            {
                using var font = new Font(wordsConfig.Font.FontFamily, count - index / 2);
                var size = TextRenderer.MeasureText(wordInfo.Word, font);
                return new Tag(wordInfo.Word,
                               layouter.PutNextRectangle(size),
                               new FontConfig(font.FontFamily, font.Size));
            }))
                   .Then(tags => CheckTagsFitOnImage(layouter, tags)));
        }
示例#3
0
 public void SetNewLayouter(IRectanglesLayouter newLayouter)
 {
     layouter = newLayouter;
 }
示例#4
0
 public TagsCloudDrawer(IRectanglesLayouter layouter, TagsCloudSettings tagsCloudSettings)
 {
     this.layouter          = layouter;
     this.tagsCloudSettings = tagsCloudSettings;
 }