예제 #1
0
        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();
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
 public LayouterSettings(Point center, int spiralCoefficient, SpiralType spiralType)
 {
     Center            = center;
     SpiralCoefficient = spiralCoefficient;
     SpiralType        = spiralType;
 }
예제 #6
0
 public void Lituus()
 {
     spiralType = SpiralType.Lituus;
 }
예제 #7
0
 public void Hyperbolic()
 {
     spiralType = SpiralType.Hyperbolic;
 }
예제 #8
0
 public void Parabolic()
 {
     spiralType = SpiralType.Parabolic;
 }
예제 #9
0
 public void Logarithmic()
 {
     spiralType = SpiralType.Logarithmic;
 }
예제 #10
0
 public void Archimedes()
 {
     spiralType = SpiralType.Archimedes;
 }
예제 #11
0
 public ILayouter GetLayouter(SpiralType type)
 {
     return(new CloudLayouter(spirals.First(x => x.Type == type)));
 }
예제 #12
0
파일: FormConfig.cs 프로젝트: PShenica/di
 public FormConfig(Color backgroundColor, Size formSize, SpiralType spiralType)
 {
     BackgroundColor = backgroundColor;
     FormSize        = formSize;
     SpiralType      = spiralType;
 }
예제 #13
0
 public void GoldenC()
 {
     spiralType = SpiralType.GoldenC;
 }
예제 #14
0
 public void Golden()
 {
     spiralType = SpiralType.Golden;
 }
예제 #15
0
        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);
        }
예제 #16
0
 public void Lituus()
 {
     this.spiralType = SpiralType.Lituus;
 }