public Bitmap DrawTagCloud(string text, ICloudSetting setting) { var strTokens = tokensParser.GetTokens(text); strTokens = filter.Filtering(strTokens); var tokens = CreateTokens(strTokens).OrderByDescending(token => token.Count).ToArray(); visualizer.Clear(); var font = setting.Font; if (tokens.Length == 0) { return(visualizer.Save()); } var maxCount = tokens[0].Count; foreach (var token in tokens) { font = new Font(font.FontFamily, (int)Math.Max(((double)token.Count / maxCount) * setting.Font.Size, 9f)); var rect = rectangleGenerator.PutNextRectangle(TextRenderer.MeasureText(token.Value, font)); visualizer.DrawTag(new TagRectangle(token.Value, rect), font); } return(visualizer.Save()); }
public Visualizer(ICloudSetting cloudSetting) { CloudSetting = cloudSetting; bitmap = new Bitmap(cloudSetting.ImageSize.Width, cloudSetting.ImageSize.Height); graphics = Graphics.FromImage(bitmap); }