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); }
public TagCloudElementsPreparer( ITagCloudLayouter tagCloudLayouter, IWordPainter wordPainter, PictureConfig config) { this.tagCloudLayouter = tagCloudLayouter; this.wordPainter = wordPainter; this.config = config; }
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); }
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); } }
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)); }
public PictureConfigurator SetWordPainter(IWordPainter painter) { Painter = painter; return(this); }