public void FindOverlappingIntervalsTest2()
        {
            var i1 = new GridInterval(1, 3);
            var i2 = new GridInterval(3, 5);
            var i3 = new GridInterval(1, 4);

            var overlappingGroups = GridIntervals.FindOverlappingIntervals(new[] { i1, i2, i3 });

            Assert.Single(overlappingGroups);
        }
        public void TestFindCenterOfMass()
        {
            var i1 = new GridInterval(-2, -2);
            var i2 = new GridInterval(-2, -2);
            var i3 = new GridInterval(0, 0);
            var i4 = new GridInterval(4, 4);

            var center = GridIntervals.FindCenterOfMass(new[] { i1, i2, i3, i4 });

            Assert.Equal(0, center);
        }
        public void FindOverlappingIntervalsTest()
        {
            var i1 = new GridInterval(0, 10);
            var i2 = new GridInterval(1, 3);
            var i3 = new GridInterval(2, 3);
            var i4 = new GridInterval(4, 13);
            var i5 = new GridInterval(12, 14);
            var i6 = new GridInterval(15, 16);

            var overlappingGroups = GridIntervals.FindOverlappingIntervals(new[] { i1, i2, i3, i4, i5, i6 });

            Assert.Equal(3, overlappingGroups.Count);
            Assert.Equal(3, overlappingGroups[0].Count);
            Assert.Equal(2, overlappingGroups[1].Count);
            Assert.Equal(2, overlappingGroups[2].Count);
            Assert.DoesNotContain(overlappingGroups.SelectMany(g => g), index => index == 5);
        }
        public void SeparateTest()
        {
            var i1  = new GridInterval(0, 2);
            var i2  = new GridInterval(1, 3);
            var i3  = new GridInterval(2, 4);
            var i4  = new GridInterval(-1, 0);
            var i12 = GridIntervals.Separate(i1, i2);

            Assert.Equal(-1, i12[0].Min);
            Assert.Equal(2, i12[1].Min);
            var i13 = GridIntervals.Separate(i1, i3);

            Assert.Equal(-1, i13[0].Min);
            Assert.Equal(2, i13[1].Min);
            var i14 = GridIntervals.Separate(i1, i4);

            Assert.Equal(0, i14[0].Min);
            Assert.Equal(-2, i14[1].Min);
        }
Beispiel #5
0
 public Grid(ChartBounds currentBounds, Canvas currentCanvas, Canvas currentBorderCanvas, GridIntervals currentIntervals)
 {
     this.currentCanvas       = currentCanvas;
     this.currentBorderCanvas = currentBorderCanvas;
     this.maxBoundsX          = currentBounds.MaxBoundsX;
     this.minBoundsX          = currentBounds.MinBoundsX;
     this.maxBoundsY          = currentBounds.MaxBoundsY;
     this.minBoundsY          = currentBounds.MinBoundsY;
     this.MajorIntervalsX     = currentIntervals.MajorIntervalsX;
     this.MajorIntervalsY     = currentIntervals.MajorIntervalsY;
     this.MinorIntervalsX     = currentIntervals.MinorIntervalsX;
     this.MinorIntervalsY     = currentIntervals.MinorIntervalsY;
 }