示例#1
0
        public GroupComparerDecorator(GroupComparer groupComparer, SortOrder sortOrder, IAggregateResultProvider results, DataAxis axis)
        {
            this.groupComparer = groupComparer;
            this.results       = results;
            this.axis          = axis;

            this.sortOrderMultiplier = sortOrder == SortOrder.Descending ? -1 : 1;
        }
示例#2
0
        internal DataSettings()
        {
            this.FilterDescriptions      = new DescriptionsSettingsList <TFilter>(this);
            this.RowGroupDescriptions    = new DescriptionsSettingsList <TGroup>(this);
            this.ColumnGroupDescriptions = new DescriptionsSettingsList <TGroup>(this);
            this.AggregateDescriptions   = new DescriptionsSettingsList <TAggregate>(this);
            this.SortDescriptions        = new DescriptionsSettingsList <TSort>(this);

            this.aggregatesLevel    = -1;
            this.aggregatesPosition = DataAxis.Columns;
        }
        private static List <IGroup> GetGroupsAtLevel(DataAxis axis, int level)
        {
            List <IGroup> groups = new List <IGroup>();
            Coordinate    root   = resultProvider.Root;

            if (axis == DataAxis.Rows)
            {
                GetSubGroups(root.RowGroup, groups, level);
            }
            else
            {
                GetSubGroups(root.ColumnGroup, groups, level);
            }
            return(groups);
        }
示例#4
0
        /// <summary>
        /// Compares two <see cref="IGroup"/>s based on their grand totals.
        /// </summary>
        /// <param name="results">The current aggregate results.</param>
        /// <param name="left">The first <see cref="IGroup"/> to compare.</param>
        /// <param name="right">The second <see cref="IGroup"/> to compare.</param>
        /// <param name="axis">Identifies if the groups are in <see cref="DataAxis.Rows"/> or <see cref="DataAxis.Columns"/>.</param>
        /// <returns>
        /// A signed integer that indicates the relative values of x and y, as shown in the following table.
        /// <para>Value Meaning Less than zero x is less than y.</para>
        /// <para>Zero x equals y.</para>
        /// <para>Greater than zero x is greater than y.</para>
        /// </returns>
        public override int CompareGroups(IAggregateResultProvider results, IGroup left, IGroup right, DataAxis axis)
        {
            Coordinate grandTotalCoordinateX;
            Coordinate grandTotalCoordinateY;

            if (axis == DataAxis.Rows)
            {
                grandTotalCoordinateX = new Coordinate(left, results.Root.ColumnGroup);
                grandTotalCoordinateY = new Coordinate(right, results.Root.ColumnGroup);
            }
            else
            {
                grandTotalCoordinateX = new Coordinate(results.Root.RowGroup, left);
                grandTotalCoordinateY = new Coordinate(results.Root.RowGroup, right);
            }

            AggregateValue aggregateValueX = results.GetAggregateResult(this.AggregateIndex, grandTotalCoordinateX);
            AggregateValue aggregateValueY = results.GetAggregateResult(this.AggregateIndex, grandTotalCoordinateY);

            // TODO: Exception handling, Provide AggregateResults Comparer, Proper order on value-vs-null and null-vs-value cases
            if (aggregateValueX != null && aggregateValueY != null)
            {
                object valueX = aggregateValueX.GetValue();
                object valueY = aggregateValueY.GetValue();

                IComparable comparableX = valueX as IComparable;
                if (comparableX != null)
                {
                    return(comparableX.CompareTo(valueY));
                }

                IComparable comparableY = valueY as IComparable;
                if (comparableY != null)
                {
                    return(-comparableY.CompareTo(valueX));
                }
            }

            return(0);
        }
示例#5
0
        // TODO: Consider wrapping the IGroups in small objects that has settable 'IsFiltered' property similar to the TotalValue that has settable 'FormattedValue'.
        // TODO: Or the other way around - make them both return an ISet/IDictionary implementations that contain the filtered groups / values for groups.

        /// <summary>
        /// Filters the groups within a parent group. Can filter based on count, average values or sorted values.
        /// </summary>
        /// <param name="groups">A read only list of all siblings.</param>
        /// <param name="results">The current aggregate results.</param>
        /// <param name="axis">Identifies if the groups are in <see cref="DataAxis.Rows"/> or <see cref="DataAxis.Columns"/>.</param>
        /// <param name="level">The level of the groups.</param>
        /// <returns>A <see cref="ICollection{IGroup}"/> implementation that is used to filter the groups.</returns>
        protected internal abstract ICollection <IGroup> Filter(IReadOnlyList <object> groups, IAggregateResultProvider results, DataAxis axis, int level);
 public override int CompareGroups(IAggregateResultProvider results, IGroup x, IGroup y, DataAxis axis)
 {
     throw new NotImplementedException();
 }
示例#7
0
 public IEnumerable <object> GetUniqueKeys(DataAxis axis, int groupDescriptionIndex)
 {
     throw new NotImplementedException();
 }
示例#8
0
        internal override bool Filter(IGroup group, IAggregateResultProvider results, DataAxis axis)
        {
            if (this.FilterImpl != null)
            {
                return(this.FilterImpl.PassesFilter(group));
            }

            return(true);
        }
        private void TestHelper(int level, DataAxis axis, SortOrder sortOrder)
        {
            var groups = GetGroupsAtLevel(axis, level);

            Assert.IsNotNull(groups);
            Assert.IsTrue(groups.Count > 0);
            CollectionAssert.AllItemsAreNotNull(groups);
            CollectionAssert.AllItemsAreUnique(groups);

            var comparer = new GroupComparerDecorator(this.grandTotalComparer, sortOrder, resultProvider, axis);

            if (level > 1)
            {
                var subGroups = GetGroupsAtLevel(axis, level - 1);

                foreach (var group in subGroups.OfType <Group>())
                {
                    group.SortSubGroups(comparer);

                    IGroup temp = null;
                    foreach (var subGroup in group.Items.OfType <IGroup>())
                    {
                        if (temp != null)
                        {
                            int result = grandTotalComparer.CompareGroups(resultProvider, temp, subGroup, axis);
                            if (sortOrder == SortOrder.Ascending)
                            {
                                Assert.IsTrue(result <= 0);
                            }
                            else
                            {
                                Assert.IsTrue(result >= 0);
                            }
                        }

                        temp = subGroup;
                    }
                }
            }
            else
            {
                groups.Sort(comparer);

                IGroup temp = null;
                foreach (var group in groups)
                {
                    if (temp != null)
                    {
                        int result = grandTotalComparer.CompareGroups(resultProvider, temp, group, axis);
                        if (sortOrder == SortOrder.Ascending)
                        {
                            Assert.IsTrue(result <= 0);
                        }
                        else
                        {
                            Assert.IsTrue(result >= 0);
                        }
                    }

                    temp = group;
                }
            }
        }
示例#10
0
 /// <summary>
 /// Compares two <see cref="IGroup"/>s based on the current aggregate results.
 /// </summary>
 /// <param name="results">The current aggregate results.</param>
 /// <param name="left">The first <see cref="IGroup"/> to compare.</param>
 /// <param name="right">The second <see cref="IGroup"/> to compare.</param>
 /// <param name="axis">Identifies if the groups are in <see cref="DataAxis.Rows"/> or <see cref="DataAxis.Columns"/>.</param>
 /// <returns>
 /// A signed integer that indicates the relative values of x and y, as shown in the following table.
 /// <para>Value Meaning Less than zero x is less than y.</para>
 /// <para>Zero x equals y.</para>
 /// <para>Greater than zero x is greater than y.</para>
 /// </returns>
 public abstract int CompareGroups(IAggregateResultProvider results, IGroup left, IGroup right, DataAxis axis);
        /// <summary>
        /// Adds detailed information about a supplied axis to the supplied TreeViewItem
        /// </summary>
        /// <param name="parent">Item TreeViewItem that will be the parent item to get the detail for the selected axis.</param>
        /// <param name="curAxis">The DataAxis we're going to be providing detail about</param>
        /// <param name="units">The units (if any) the current axis uses, like meters or degrees or whatnot</param>
        /// <returns></returns>
        private TreeViewItem AddAxisDetail(TreeViewItem parent, DataAxis curAxis, string units)
        {
            TreeViewItem newItem, axisDetail;
            int lowIndex, highIndex;

            newItem = AddSubItem(parent, curAxis.Name + " Axis [" + curAxis.Length + "]");
            newItem.IsExpanded = true;
            lowIndex = highIndex = -1;
            lowIndex = 0;
            highIndex = curAxis.Length - 1;
            AddSubItem(newItem, "Minimum value: " + curAxis.Map[lowIndex].Value + " " + units);
            AddSubItem(newItem, "Maximum value: " + curAxis.Map[highIndex].Value + " " + units);
            axisDetail = AddSubItem(newItem, "Detail");
            for (int j = lowIndex; j <= highIndex; j++)
                AddSubItem(axisDetail, "[" + curAxis.Map[j].Index + "] = " + curAxis.Map[j].Value.ToString() + " " + units); 
            return newItem;
        }
示例#12
0
        // TODO: Currently we are using the IGroup.Names as IComparables. Should we add IComparer?

        /// <summary>
        /// Compares two <see cref="IGroup"/>s based on their <see cref="IGroup.Name"/>s.
        /// </summary>
        /// <param name="results">The current aggregate results.</param>
        /// <param name="left">The first <see cref="IGroup"/> to compare.</param>
        /// <param name="right">The second <see cref="IGroup"/> to compare.</param>
        /// <param name="axis">Identifies if the groups are in <see cref="DataAxis.Rows"/> or <see cref="DataAxis.Columns"/>.</param>
        /// <returns>
        /// A signed integer that indicates the relative values of x and y, as shown in the following table.
        /// <para>Value Meaning Less than zero x is less than y.</para>
        /// <para>Zero x equals y.</para>
        /// <para>Greater than zero x is greater than y.</para>
        /// </returns>
        public override int CompareGroups(IAggregateResultProvider results, IGroup left, IGroup right, DataAxis axis)
        {
            if (left.Name == NullValue.Instance && right.Name == NullValue.Instance)
            {
                return(0);
            }
            else if (left.Name == NullValue.Instance)
            {
                return(1);
            }
            else if (right.Name == NullValue.Instance)
            {
                return(-1);
            }

            IComparable leftComparable = left.Name as IComparable;

            if (leftComparable != null)
            {
                return(leftComparable.CompareTo(right.Name));
            }

            IComparable rightComparable = right.Name as IComparable;

            if (rightComparable != null)
            {
                return(-rightComparable.CompareTo(left.Name));
            }

            return(0);
        }
示例#13
0
 /// <summary>
 /// Identifies if a group should be filtered or not.
 /// </summary>
 /// <param name="group">The group.</param>
 /// <param name="results">Results for the current grouping. Could be used for totals lookup.</param>
 /// <param name="axis">Identifies if the <paramref name="group"/> is positioned in the <see cref="DataAxis.Rows"/> or <see cref="DataAxis.Columns"/>.</param>
 /// <returns>True if the group should be preserved, False if the group should be removed.</returns>
 internal abstract bool Filter(IGroup group, IAggregateResultProvider results, DataAxis axis);