示例#1
0
        private object RemoveOverlaps1()
        {
            OneWayFSAParameters params1 = new OneWayFSAParameters();

            params1.HorizontalGap = 40;
            params1.VerticalGap   = 40;

            var vertexRectangles = new Dictionary <string, Rectangle>();

            for (int i = 0; i < vertexLabels.Length; ++i)
            {
                var vertex = vertexPositions[vertexLabels[i]];
                var border = vertexBorders[vertexLabels[i]];

                var rect = new Rectangle();
                rect.Width  = border.Right - border.Left;
                rect.Height = border.Bottom - border.Top;
                vertexRectangles.Add(vertexLabels[i], rect);
            }

            OneWayFSAAlgorithm <string> algo1;

            algo1 = new OneWayFSAAlgorithm <string>(null, params1);
            algo1.Compute();

            return(null);
        }
示例#2
0
        public void Compute([NotNull] OneWayFSAParameters parameters)
        {
            Dictionary <int, Rect> rectangles = GetRectangles();

            Dictionary <int, Rect> initialRectangles = rectangles.ToDictionary(
                pair => pair.Key,
                pair => new Rect(pair.Value.Location, pair.Value.Size));

            var algorithm = new OneWayFSAAlgorithm <int>(rectangles, parameters);

            algorithm.Compute();

            // Fulfill minimum spacing
            AssertNoOverlap(Distinct(algorithm.Rectangles.Values));
            foreach (KeyValuePair <int, Rect> pair in algorithm.Rectangles)
            {
                Rect initialRectangle = initialRectangles[pair.Key];
                // Size must not change
                Assert.AreEqual(initialRectangle.Size, pair.Value.Size);

                // X or Y must not change depending on the used Way
                if (parameters.Way == OneWayFSAWay.Horizontal)
                {
                    Assert.AreEqual(initialRectangle.Y, pair.Value.Y);
                }
                else
                {
                    Assert.AreEqual(initialRectangle.X, pair.Value.X);
                }
            }
        }