Пример #1
0
 public PictureConfigurator(int width, int height, Color color,
                            float maxSize = 120, float minSize = 3, FontStyle fontStyle = FontStyle.Regular)
 {
     CheckCorrectArgumentConstructor(width, height, color);
     Width   = width;
     Height  = height;
     Painter = new DefaultWordPainter(color, maxSize, minSize, fontStyle);
 }
Пример #2
0
 public TagCloudElementsPreparer(
     ITagCloudLayouter tagCloudLayouter,
     IWordPainter wordPainter,
     PictureConfig config)
 {
     this.tagCloudLayouter = tagCloudLayouter;
     this.wordPainter      = wordPainter;
     this.config           = config;
 }
Пример #3
0
        private static Bitmap DrawCloud(IEnumerable <DrawingWord> words, Size imageSize, IColorSelector colorSelector,
                                        IWordPainter wordPainter)
        {
            var cloud    = new Bitmap(imageSize.Width, imageSize.Height);
            var graphics = Graphics.FromImage(cloud);

            foreach (var word in words)
            {
                graphics.DrawString(word.Word, word.Font,
                                    new SolidBrush(colorSelector.GetColor(word)),
                                    word.Location);
            }
            return(cloud);
        }
Пример #4
0
        internal static IEnumerable <DrawingWord> GetReadyWords(IEnumerable <WordStatistic> wordsStatistic,
                                                                BaseCloudLayouter layouter, FontFamily fontFamily, IWordPainter wordPainter)
        {
            var statistics = wordsStatistic.ToList();

            if (statistics.Count == 0)
            {
                yield break;
            }
            var maxCount = statistics.Max(x => x.Count);
            var fonts    = new Font[MaximalFontSize - MininalFontSize + 1];
            var graphics = Graphics.FromImage(new Bitmap(1, 1));

            foreach (var statistic in statistics)
            {
                var fontSize = (int)((MaximalFontSize - MininalFontSize) * ((double)statistic.Count / maxCount) +
                                     MininalFontSize);
                // ReSharper disable once ConstantNullCoalescingCondition
                fonts[fontSize - MininalFontSize] ??= new Font(fontFamily, fontSize);
                var font = fonts[fontSize - MininalFontSize];
                var size = wordPainter.GetWordSize(statistic.Word, font);
                var word = new DrawingWord(statistic.Word, font, layouter.PutNextRectangle(size).Location);
                yield return(word);
            }
        }
Пример #5
0
        public static Font GetFont(IWordPainter pictureConfiguratorPainter, float maxWeight, float minWeight, float weightWord, string word)
        {
            var fontSize = pictureConfiguratorPainter.GetFontSize(word, maxWeight, minWeight, weightWord) + 1;

            return(pictureConfiguratorPainter.GetFontWord(word, fontSize));
        }
Пример #6
0
 public PictureConfigurator SetWordPainter(IWordPainter painter)
 {
     Painter = painter;
     return(this);
 }