Beispiel #1
0
        /// <summary>
        /// Create a collection of clusters that should be presented to the user
        /// </summary>
        /// <param name="strategy"></param>
        /// <param name="listView"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        virtual protected List <ICluster> Cluster(IClusteringStrategy strategy, ObjectListView listView, OLVColumn column)
        {
            // Build a map that correlates cluster key to clusters
            NullableDictionary <object, ICluster> map = new NullableDictionary <object, ICluster>();
            int count = 0;

            //++Added by KhoiVV
            if (listView.Objects == null)
            {
                return(new List <ICluster>(map.Values));
            }
            //--Added by KhoiVV

            foreach (object model in listView.ObjectsForClustering)
            {
                this.ClusterOneModel(strategy, map, model);

                if (count++ > this.MaxObjectsToConsider)
                {
                    break;
                }
            }

            // Now that we know exactly how many items are in each cluster, create a label for it
            foreach (ICluster cluster in map.Values)
            {
                cluster.DisplayLabel = strategy.GetClusterDisplayLabel(cluster);
            }

            return(new List <ICluster>(map.Values));
        }
Beispiel #2
0
        /// <summary>
        /// Create a collection of clusters that should be presented to the user
        /// </summary>
        /// <param name="strategy"></param>
        /// <param name="listView"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        protected virtual List<ICluster> Cluster(IClusteringStrategy strategy, ObjectListView listView, OLVColumn column)
        {
            // Build a map that correlates cluster key to clusters
            var map = new NullableDictionary<object, ICluster>();
            int count = 0;
            foreach (object model in listView.Objects)
            {
                object key = strategy.GetClusterKey(model);
                if (key == DBNull.Value)
                    key = null;
                if (key == null && !TreatNullAsDataValue)
                    continue;
                if (map.ContainsKey(key))
                    map[key].Count += 1;
                else
                    map[key] = strategy.CreateCluster(key);

                // Check our limit
                count += 1;
                if (count > MaxObjectsToConsider)
                    break;
            }

            // Now that we know exactly how many items are in each cluster, create a label for it
            foreach (ICluster cluster in map.Values)
                cluster.DisplayLabel = strategy.GetClusterDisplayLabel(cluster);

            return new List<ICluster>(map.Values);
        }
        /// <summary>
        /// Create a collection of clusters that should be presented to the user
        /// </summary>
        /// <param name="strategy"></param>
        /// <param name="listView"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        virtual protected List <ICluster> Cluster(IClusteringStrategy strategy, ObjectListView listView, OLVColumn column)
        {
            // Build a map that correlates cluster key to clusters
            NullableDictionary <object, ICluster> map = new NullableDictionary <object, ICluster>();
            int count = 0;

            foreach (object model in listView.Objects)
            {
                object key = strategy.GetClusterKey(null, model);
                if (key == System.DBNull.Value)
                {
                    key = null;
                }
                if (key == null && !this.TreatNullAsDataValue)
                {
                    continue;
                }
                if (map.ContainsKey(key))
                {
                    map[key].Count += 1;
                }
                else
                {
                    map[key] = strategy.CreateCluster(key);
                }

                // Check our limit
                count += 1;
                if (count > this.MaxObjectsToConsider)
                {
                    break;
                }
            }

            // Now that we know exactly how many items are in each cluster, create a label for it
            foreach (ICluster cluster in map.Values)
            {
                cluster.DisplayLabel = strategy.GetClusterDisplayLabel(cluster);
            }

            return(new List <ICluster>(map.Values));
        }
Beispiel #4
0
        /// <summary>
        /// Create a collection of clusters that should be presented to the user
        /// </summary>
        /// <param name="strategy"></param>
        /// <param name="listView"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        virtual protected List<ICluster> Cluster(IClusteringStrategy strategy, ObjectListView listView, OLVColumn column) {
            // Build a map that correlates cluster key to clusters
            NullableDictionary<object, ICluster> map = new NullableDictionary<object, ICluster>();
            int count = 0;
            foreach (object model in listView.ObjectsForClustering) {
                this.ClusterOneModel(strategy, map, model);

                if (count++ > this.MaxObjectsToConsider)
                    break;
            }

            // Now that we know exactly how many items are in each cluster, create a label for it
            foreach (ICluster cluster in map.Values)
                cluster.DisplayLabel = strategy.GetClusterDisplayLabel(cluster);

            return new List<ICluster>(map.Values);
        }
Beispiel #5
0
        /// <summary>
        /// Create a collection of clusters that should be presented to the user
        /// </summary>
        /// <param name="strategy"></param>
        /// <param name="listView"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        virtual protected List<ICluster> Cluster(IClusteringStrategy strategy, ObjectListView listView, OLVColumn column) {
            // Build a map that correlates cluster key to clusters
            NullableDictionary<object, ICluster> map = new NullableDictionary<object, ICluster>();
            int count = 0;
            foreach (object model in listView.Objects) {
                object key = strategy.GetClusterKey(model);
                if (key == System.DBNull.Value)
                    key = null;
                if (key == null && !this.TreatNullAsDataValue)
                    continue;
                if (map.ContainsKey(key))
                    map[key].Count += 1;
                else
                    map[key] = strategy.CreateCluster(key);

                // Check our limit
                count += 1;
                if (count > this.MaxObjectsToConsider)
                    break;
            }

            // Now that we know exactly how many items are in each cluster, create a label for it
            foreach (ICluster cluster in map.Values)
                cluster.DisplayLabel = strategy.GetClusterDisplayLabel(cluster);

            return new List<ICluster>(map.Values);
        }