Exemple #1
0
        private IGraphTransformation ReadTransformation(IGraphPresentation presentation)
        {
            var transformationType = myReader.ReadString();

            if (transformationType == "DynamicClusterTransformation")
            {
                var t = new DynamicClusterTransformation();

                var count = myReader.ReadInt32();
                for (int i = 0; i < count; ++i)
                {
                    var id = myReader.ReadString();
                    if (myReader.ReadBoolean())
                    {
                        t.AddCluster(id);
                    }
                    else
                    {
                        t.HideCluster(id);
                    }
                }

                count = myReader.ReadInt32();
                for (int i = 0; i < count; ++i)
                {
                    var nodeId    = myReader.ReadString();
                    var clusterId = myReader.ReadString();

                    if (clusterId == string.Empty)
                    {
                        t.RemoveFromClusters(nodeId);
                    }
                    else
                    {
                        t.AddToCluster(nodeId, clusterId);
                    }
                }

                return(t);
            }
            else if (transformationType == "ClusterFoldingTransformation")
            {
                var t = new ClusterFoldingTransformation(presentation);

                var count = myReader.ReadInt32();
                for (int i = 0; i < count; ++i)
                {
                    t.Add(myReader.ReadString());
                }

                return(t);
            }
            else
            {
                throw new NotSupportedException("Unknown transformation type: " + transformationType);
            }
        }
Exemple #2
0
        public static ClusterFoldingTransformation ClusterFolding(this IGraphPresentation presentation)
        {
            var transformations = presentation.GetModule <ITransformationModule>();
            var transformation  = transformations.Items
                                  .OfType <ClusterFoldingTransformation>()
                                  .SingleOrDefault();

            if (transformation == null)
            {
                transformation = new ClusterFoldingTransformation(presentation);
                transformations.Add(transformation);
            }

            return(transformation);
        }