private void ChangeSpiral() { using var form = new Form { Width = 400, FormBorderStyle = FormBorderStyle.FixedDialog, MaximizeBox = false }; var comboBox = new ComboBox { Width = 200 }; comboBox.Items.Insert(0, "Archimedean"); comboBox.Items.Insert(1, "UlamSpiral"); var button = new Button { Text = "Set", DialogResult = DialogResult.OK, Top = comboBox.Bottom }; button.Click += (sender, args) => { spiralType = (SpiralType)comboBox.SelectedIndex; tags = container.GetTags(File.ReadAllText(path), spiralType); form.Close(); }; form.Controls.Add(comboBox); form.Controls.Add(button); form.ShowDialog(); Invalidate(); }
public void SetUp() { var parser = new TextParser(new WordValidator()); var center = new Point(200, 200); var spiral = new ArchimedeanSpiral(center, 0.2, 1.0); spiralType = SpiralType.Archimedean; var factory = new LayouterFactory(new List <ISpiral> { spiral }); container = new TagsCloudContainer.TagsCloudContainer.TagsCloudContainer(parser, factory); }
public List <Tag> GetTags(string text, SpiralType type) { var wordEntry = GetWordEntry(text); var tags = new List <Tag>(); var graphics = Graphics.FromImage(new Bitmap(1, 1)); var layouter = factory.GetLayouter(type); foreach (var word in wordEntry.Keys.ToList()) { var wordFont = new Font("Arial", wordEntry[word] + 10); var wordSize = graphics.MeasureString(word, wordFont).ToSize(); var rectangle = layouter.PutNextRectangle(wordSize); tags.Add(new Tag(word, rectangle, wordFont, Brushes.Black)); } return(tags); }
protected override void OnLoad(EventArgs e) { FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; BackColor = config.BackgroundColor; Size = config.FormSize; spiralType = config.SpiralType; var menu = new MenuStrip(); menu.Items.Add(new ToolStripMenuItem("Text", null, (sender, args) => GetText())); menu.Items.Add(new ToolStripMenuItem("Save", null, (sender, args) => SaveBitmap())); menu.Items.Add(new ToolStripMenuItem("Font", null, (sender, args) => ChangeFont())); menu.Items.Add(new ToolStripMenuItem("Color", null, (sender, args) => ChangeColor())); menu.Items.Add(new ToolStripMenuItem("Background", null, (sender, args) => ChangeBackgroundColor())); menu.Items.Add(new ToolStripMenuItem("Window size", null, (sender, args) => ChangeWindowSize())); menu.Items.Add(new ToolStripMenuItem("Spiral", null, (sender, args) => ChangeSpiral())); menu.Items.Add(new ToolStripMenuItem("Set stop words", null, (sender, args) => SetStopWords())); Controls.Add(menu); }
public LayouterSettings(Point center, int spiralCoefficient, SpiralType spiralType) { Center = center; SpiralCoefficient = spiralCoefficient; SpiralType = spiralType; }
public void Lituus() { spiralType = SpiralType.Lituus; }
public void Hyperbolic() { spiralType = SpiralType.Hyperbolic; }
public void Parabolic() { spiralType = SpiralType.Parabolic; }
public void Logarithmic() { spiralType = SpiralType.Logarithmic; }
public void Archimedes() { spiralType = SpiralType.Archimedes; }
public ILayouter GetLayouter(SpiralType type) { return(new CloudLayouter(spirals.First(x => x.Type == type))); }
public FormConfig(Color backgroundColor, Size formSize, SpiralType spiralType) { BackgroundColor = backgroundColor; FormSize = formSize; SpiralType = spiralType; }
public void GoldenC() { spiralType = SpiralType.GoldenC; }
public void Golden() { spiralType = SpiralType.Golden; }
public List <VertexPoint> GetSpiralPoints(double StartX, double StartY, double A, double angle_offset, double max_r, int PartOfPattern, string StopAt, string Direction, string ToInOut, SpiralType Spiral) { bool FinishBorder = false; List <VertexPoint> points = new List <VertexPoint>(); VertexPoint StartPoint = new VertexPoint(); VertexPoint LastValid = new VertexPoint(); const double dtheta = (5 * Math.PI / 180); // Five degrees. StartPoint.x = StartX; StartPoint.y = StartY; StartPoint.PartOfPattern = PartOfPattern; StartPoint.PatternType = "Spiral"; for (double theta = 0; ; theta += dtheta) { double r = 0; switch (Spiral) { case SpiralType.Linear: r = A * theta; break; case SpiralType.Cubic: r = A * theta * theta * theta; break; case SpiralType.Exponential: r = (Math.Pow(theta / 180 * Math.PI, Math.E)) * A; break; case SpiralType.Quadratic: r = A * theta * theta; break; default: break; } // Convert to Cartesian coordinates. double x, y; PolarToCartesianRev(r, theta + angle_offset, out x, out y); VertexPoint vp = new VertexPoint(); // Center. vp.x += StartX + x; vp.y += StartY + y; if ((LastValid.x != vp.x) && (LastValid.y != vp.y)) { LastValid = WithinBounds(vp.x, vp.y); LastValid.PartOfPattern = PartOfPattern; LastValid.PatternType = "Spiral"; points.Add(LastValid); if (FinishBorder) { if (IsNearBorder(vp, vp, StartPoint, StopAt)) { break; } } } // If we have gone far enough, stop. if (r > max_r) { if (StopAt != "None") { FinishBorder = true; } else { break; } } } return(points); }
public void Lituus() { this.spiralType = SpiralType.Lituus; }