public Image DrawTagCloudImage(Statistic statistic, ITagCloudGenerator tagCloudGenerator)
 {
     var image = new Bitmap(tagCloudGenerator.ImageWidth, tagCloudGenerator.ImageHeight);
     var graphics = Graphics.FromImage(image);
     var cloud = tagCloudGenerator.GenerateCloud(statistic, (s, f) => graphics.MeasureString(s, f).ToSize());
     graphics.SmoothingMode = SmoothingMode.HighQuality;
     foreach (var wordRectangle in cloud.Elements)
     {
         //graphics.DrawRectangle(new Pen(Color.Black), wordRectangle.Border);
         graphics.DrawString(wordRectangle.Text, wordRectangle.Font, new SolidBrush(wordRectangle.Color), wordRectangle.Location.Location);
     }
     return image;
 }
Beispiel #2
0
 public Application(
     ISettingsProvider settingsProvider,
     IFileInfoProvider fileInfoProvider,
     ITextReaderSelector textReaderSelector,
     IWordProcessor wordProcessor,
     IWordSizeSetter wordSizeSetter,
     ITagCloudGenerator tagCloudGenerator,
     IImageFormat imageFormat)
 {
     this.settingsProvider   = settingsProvider;
     this.fileInfoProvider   = fileInfoProvider;
     this.textReaderSelector = textReaderSelector;
     this.wordProcessor      = wordProcessor;
     this.wordSizeSetter     = wordSizeSetter;
     this.tagCloudGenerator  = tagCloudGenerator;
     this.imageFormat        = imageFormat;
 }
 public TagCloudImageGenerator(IEnumerable<IWordReader> readers, IWordsStatisticsBuilder statisticsBuilder,
     IEnumerable<ITagCloudGenerator> imageGenerators, ITagCloudImageDrawer tagCloudDrawer)
 {
     if (readers == null)
         throw new ArgumentNullException(nameof(readers));
     if (statisticsBuilder == null)
         throw new ArgumentNullException(nameof(statisticsBuilder));
     if (imageGenerators == null)
         throw new ArgumentNullException(nameof(imageGenerators));
     if (tagCloudDrawer == null)
         throw new ArgumentNullException(nameof(tagCloudDrawer));
     _readers = readers.ToDictionary(x => x.FileExtension.ToLower(), x => x);
     _imageGenerators = imageGenerators.ToDictionary(x => x.Name.ToLower(), x => x);
     _statisticsBuilder = statisticsBuilder;
     _tagCloudDrawer = tagCloudDrawer;
     _currentTagCloudGenerator = _imageGenerators.First().Value;
 }
 public ITagCloudImageGenerator SetImageGenerator(string generatorName)
 {
     generatorName = generatorName.ToLower();
     if (!_imageGenerators.ContainsKey(generatorName))
         throw new TagCloudImageGeneratorTuningException(generatorName + " generator doesn't exist");
     _currentTagCloudGenerator = _imageGenerators[generatorName.ToLower()];
     return this;
 }