コード例 #1
0
        public Result <IEnumerable <Tag> > GetCloudTags(Dictionary <string, int> weightedWords)
        {
            layouter.Clear();
            if (weightedWords.Count == 0)
            {
                return(Result.Ok(Enumerable.Empty <Tag>()));
            }

            minFrequency = weightedWords.Values.Min();
            maxFrequency = weightedWords.Values.Max();

            return(Result.Of(() => weightedWords.Select(GenerateTag)));
        }
コード例 #2
0
        public List <Tag> GetCloudTags(Dictionary <String, int> weightedWords)
        {
            layouter.Clear();
            var tags = new List <Tag>();

            if (weightedWords.Count == 0)
            {
                return(tags);
            }
            minFrequency = weightedWords.Values.Min();
            maxFrequency = weightedWords.Values.Max();

            foreach (var weightedWord in weightedWords)
            {
                var fontSize  = GetFontSize(weightedWord.Value);
                var font      = new Font(fontSettings.FontFamily, fontSize);
                var frameSize = TextRenderer.MeasureText(weightedWord.Key, font);
                var frame     = layouter.PutNextRectangle(frameSize);
                tags.Add(new Tag(weightedWord.Key, font, frame));
            }
            return(tags);
        }