public ILayoutParameters CreateParameters(string algorithmType, ILayoutParameters oldParameters)
 {
     switch (algorithmType)
     {
     /*case "Tree":
      *  return oldParameters.CreateNewParameter<SimpleTreeLayoutParameters>();
      * case "Circular":
      *  return oldParameters.CreateNewParameter<CircularLayoutParameters>();
      * case "FR":
      *  return oldParameters.CreateNewParameter<FreeFRLayoutParameters>();
      * case "BoundedFR":
      *  return oldParameters.CreateNewParameter<BoundedFRLayoutParameters>();
      * case "KK":
      *  return oldParameters.CreateNewParameter<KKLayoutParameters>();
      * case "ISOM":
      *  return oldParameters.CreateNewParameter<ISOMLayoutParameters>();
      * case "LinLog":
      *  return oldParameters.CreateNewParameter<LinLogLayoutParameters>();
      * case "EfficientSugiyama":
      *  return oldParameters.CreateNewParameter<EfficientSugiyamaLayoutParameters>();
      * case "Sugiyama":
      *  return oldParameters.CreateNewParameter<SugiyamaLayoutParameters>();
      * case "CompoundFDP":
      *  return oldParameters.CreateNewParameter<CompoundFDPLayoutParameters>();*/
     default:
         return(null);
     }
 }
Ejemplo n.º 2
0
        public static Size GetLineSizeFromLayoutParams(ILayoutParameters parameters)
        {
            var textLayout = Utilities.GetTextLayoutFromLayoutParams(parameters);

            textLayout.Text = "a\na";
            return(new Size(parameters.Width, textLayout.GetCoordinateFromIndex(2).Y));
        }
Ejemplo n.º 3
0
        public static Size GetCharSizeFromLayoutParams(ILayoutParameters parameters)
        {
            var textLayout = GetTextLayoutFromLayoutParams(parameters);

            textLayout.Text = "a\na";
            return(new Size(textLayout.GetCoordinateFromIndex(1).X, textLayout.GetCoordinateFromIndex(2).Y));
        }
Ejemplo n.º 4
0
        public static TextLayout GetTextLayoutFromLayoutParams(ILayoutParameters parameters)
        {
            var result = new TextLayout();

            result.Font = parameters.Font;
            return(result);
        }
Ejemplo n.º 5
0
 public static TParam CreateNewParameter <TParam>(this ILayoutParameters oldParameters)
     where TParam : class, ILayoutParameters, new()
 {
     return(!(oldParameters is TParam)
         ? new TParam() :
            (TParam)(oldParameters as TParam).Clone());
 }
 public ILayoutParameters CreateParameters(string algorithmType, ILayoutParameters oldParameters)
 {
     switch (algorithmType)
     {
     /*case "DoubleTree":
      *      return !( oldParameters is DoubleTreeLayoutParameters ) ? new DoubleTreeLayoutParameters() : (DoubleTreeLayoutParameters)( oldParameters as DoubleTreeLayoutParameters ).Clone();
      * case "BaloonTree":
      *      return !( oldParameters is BalloonTreeLayoutParameters ) ? new BalloonTreeLayoutParameters() : (BalloonTreeLayoutParameters)( oldParameters as BalloonTreeLayoutParameters ).Clone();*/
     default:
         return(null);
     }
 }
Ejemplo n.º 7
0
        public override double PrepareForDrawing(ILayoutParameters parameters)
        {
            var baseResult = base.PrepareForDrawing(parameters);

#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
            // MonoDevelop complains about comparing double to a const int,
            // but we detect uninitialized case here, so it's ok.
            if (LineHeight == 0) // UI has not been initalized yet
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
            {
                return(baseResult);
            }
            targetImageHeight = PreferedHeightInLines * LineHeight;
            ShellProvider.NumberOfDummyLines = PreferedHeightInLines;
            return(baseResult);
        }
        public ILayoutParameters CreateParameters(string algorithmType, ILayoutParameters oldParameters)
        {
            switch (algorithmType)
            {
            case "DoubleTree":
                return(oldParameters.CreateNewParameter <DoubleTreeLayoutParameters>());

            case "BalloonTree":
                return(oldParameters.CreateNewParameter <BalloonTreeLayoutParameters>());

            case "RadialTree":
                return(oldParameters.CreateNewParameter <RadialTreeLayoutParameters>());

            default:
                return(null);
            }
        }
        /// <inheritdoc />
        public ILayoutParameters CreateParameters(string algorithmType, ILayoutParameters parameters)
        {
            if (algorithmType is null)
            {
                throw new ArgumentNullException(nameof(algorithmType));
            }

            switch (algorithmType)
            {
            case DoubleTreeAlgorithm:
                return(parameters.CreateNewParameters <DoubleTreeLayoutParameters>());

            case BalloonTreeAlgorithm:
                return(parameters.CreateNewParameters <BalloonTreeLayoutParameters>());
            }

            return(null);
        }
        public ILayoutParameters CreateParameters(string algorithmType, ILayoutParameters oldParameters)
        {
            switch (algorithmType)
            {
            case "Tree":
                return(oldParameters.CreateNewParameter <SimpleTreeLayoutParameters>());

            case "Circular":
                return(oldParameters.CreateNewParameter <CircularLayoutParameters>());

            case "FR":
                return(oldParameters.CreateNewParameter <FreeFRLayoutParameters>());

            case "BoundedFR":
                return(oldParameters.CreateNewParameter <BoundedFRLayoutParameters>());

            case "KK":
                return(oldParameters.CreateNewParameter <KKLayoutParameters>());

            case "ISOM":
                return(oldParameters.CreateNewParameter <ISOMLayoutParameters>());

            case "LinLog":
                return(oldParameters.CreateNewParameter <LinLogLayoutParameters>());

            case "EfficientSugiyama":
                return(oldParameters.CreateNewParameter <EfficientSugiyamaLayoutParameters>());

            case "Sugiyama":
                return(oldParameters.CreateNewParameter <SugiyamaLayoutParameters>());

            case "CompoundFDP":
                return(oldParameters.CreateNewParameter <CompoundFDPLayoutParameters>());

            case "StressMajorization":
                return(oldParameters.CreateNewParameter <StressMajorizationLayoutParameters>());

            case "Grid":
                return(oldParameters.CreateNewParameter <GridLayoutParameters>());

            default:
                return(null);
            }
        }
        /// <inheritdoc />
        public ILayoutAlgorithm <TVertex, TEdge, TGraph> CreateAlgorithm(
            string algorithmType,
            ILayoutContext <TVertex, TEdge, TGraph> context,
            ILayoutParameters parameters)
        {
            if (algorithmType is null)
            {
                throw new ArgumentNullException(nameof(algorithmType));
            }
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var layoutContext = context as ContextualLayoutContext <TVertex, TEdge, TGraph>;

            if (layoutContext is null)
            {
                throw new ArgumentException(
                          $"Layout context must be a not null {nameof(ContextualLayoutContext<TVertex, TEdge, TGraph>)}.",
                          nameof(context));
            }

            switch (algorithmType)
            {
            case DoubleTreeAlgorithm:
                return(new DoubleTreeLayoutAlgorithm <TVertex, TEdge, TGraph>(
                           layoutContext.Graph,
                           layoutContext.Positions,
                           layoutContext.Sizes,
                           layoutContext.SelectedVertex,
                           parameters as DoubleTreeLayoutParameters));

            case BalloonTreeAlgorithm:
                return(new BalloonTreeLayoutAlgorithm <TVertex, TEdge, TGraph>(
                           layoutContext.Graph,
                           layoutContext.Positions,
                           layoutContext.SelectedVertex,
                           parameters as BalloonTreeLayoutParameters));
            }

            return(null);
        }
        /// <inheritdoc />
        public ILayoutParameters CreateParameters(string algorithmType, ILayoutParameters parameters)
        {
            if (algorithmType is null)
            {
                throw new ArgumentNullException(nameof(algorithmType));
            }

            switch (algorithmType)
            {
            case CircularAlgorithm:
                return(parameters.CreateNewParameters <CircularLayoutParameters>());

            case TreeAlgorithm:
                return(parameters.CreateNewParameters <SimpleTreeLayoutParameters>());

            case FRAlgorithm:
                return(parameters.CreateNewParameters <FreeFRLayoutParameters>());

            case BoundedFRAlgorithm:
                return(parameters.CreateNewParameters <BoundedFRLayoutParameters>());

            case KKAlgorithm:
                return(parameters.CreateNewParameters <KKLayoutParameters>());

            case ISOMAlgorithm:
                return(parameters.CreateNewParameters <ISOMLayoutParameters>());

            case LinLogAlgorithm:
                return(parameters.CreateNewParameters <LinLogLayoutParameters>());

            case SugiyamaAlgorithm:
                return(parameters.CreateNewParameters <SugiyamaLayoutParameters>());

            case CompoundFDPAlgorithm:
                return(parameters.CreateNewParameters <CompoundFDPLayoutParameters>());

            case RandomAlgorithm:
                return(parameters.CreateNewParameters <RandomLayoutParameters>());
            }

            return(null);
        }
        /// <inheritdoc />
        public ILayoutAlgorithm <TVertex, TEdge, TGraph> CreateAlgorithm(
            string algorithmType,
            ILayoutContext <TVertex, TEdge, TGraph> context,
            ILayoutParameters parameters)
        {
            if (algorithmType is null)
            {
                throw new ArgumentNullException(nameof(algorithmType));
            }
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (context.Graph is null)
            {
                return(null);
            }

            return(CreateAlgorithmInternal(algorithmType, context, parameters));
        }
        public virtual double PrepareForDrawing(ILayoutParameters parameters)
        {
            cursorInRow       = null;
            defaultForeground = parameters.DefaultForeground;
            selectionColor    = parameters.SelectionColor;
            textLayout        = TextLayoutCache.GetValue(parameters);
            lineSize          = LineSizeCache.GetValue(parameters);
            charWidth         = CharSizeCache.GetValue(parameters).Width;

            if (lineSize.Width == 0)
            {
                return(0);
            }

            // Math.Max used to prevent division by zero errors on windows narrower than one character
            MaximalColumn = Math.Max(((int)(lineSize.Width / charWidth)) - 1, 0);

            var charsOnLine = MaximalColumn + 1;
            var lengthInTextElementsAtLeastOne = lengthInTextElements == 0 ? 1 : lengthInTextElements; // because even empty line has height of one line

            lineCount = Math.Max(minimalSublineCount, DivisionWithCeiling(lengthInTextElementsAtLeastOne, charsOnLine));
            return(lineSize.Height * lineCount);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Generate and initialize layout algorithm
        /// </summary>
        /// <param name="newAlgorithmType">Layout algorithm type</param>
        /// <param name="iGraph">Graph</param>
        /// <param name="positions">Optional vertex positions</param>
        /// <param name="sizes">Optional vertex sizes</param>
        /// <param name="parameters">Optional algorithm parameters</param>
        public ILayoutAlgorithm <TVertex, TEdge, TGraph> CreateLayoutAlgorithm(LayoutAlgorithmTypeEnum newAlgorithmType, TGraph iGraph, IDictionary <TVertex, Point> positions = null, IDictionary <TVertex, Size> sizes = null, ILayoutParameters parameters = null)
        {
            if (iGraph == null)
            {
                return(null);
            }
            if (parameters == null)
            {
                parameters = CreateLayoutParameters(newAlgorithmType);
            }
            var graph = iGraph.CopyToGraph <TGraph, TVertex, TEdge>();

            var tGraph = (IMutableBidirectionalGraph <TVertex, TEdge>)graph;

            if (tGraph != null)
            {
                tGraph.RemoveEdgeIf(a => a.SkipProcessing == ProcessingOptionEnum.Exclude);
                tGraph.RemoveVertexIf(a => a.SkipProcessing == ProcessingOptionEnum.Exclude);
            }

            switch (newAlgorithmType)
            {
            case LayoutAlgorithmTypeEnum.Tree:
                return(new SimpleTreeLayoutAlgorithm <TVertex, TEdge, TGraph>(graph, positions, sizes, parameters as SimpleTreeLayoutParameters));

            case LayoutAlgorithmTypeEnum.SimpleRandom:
                return(new RandomLayoutAlgorithm <TVertex, TEdge, TGraph>(graph, positions, parameters as RandomLayoutAlgorithmParams));

            case LayoutAlgorithmTypeEnum.Circular:
                return(new CircularLayoutAlgorithm <TVertex, TEdge, TGraph>(graph, positions, sizes, parameters as CircularLayoutParameters));

            case LayoutAlgorithmTypeEnum.FR:
                return(new FRLayoutAlgorithm <TVertex, TEdge, TGraph>(graph, positions, parameters as FRLayoutParametersBase));

            case LayoutAlgorithmTypeEnum.BoundedFR:
                return(new FRLayoutAlgorithm <TVertex, TEdge, TGraph>(graph, positions, parameters as BoundedFRLayoutParameters));

            case LayoutAlgorithmTypeEnum.KK:
                return(new KKLayoutAlgorithm <TVertex, TEdge, TGraph>(graph, positions, parameters as KKLayoutParameters));

            case LayoutAlgorithmTypeEnum.ISOM:
                return(new ISOMLayoutAlgorithm <TVertex, TEdge, TGraph>(graph, positions, parameters as ISOMLayoutParameters));

            case LayoutAlgorithmTypeEnum.LinLog:
                return(new LinLogLayoutAlgorithm <TVertex, TEdge, TGraph>(graph, positions, parameters as LinLogLayoutParameters));

            case LayoutAlgorithmTypeEnum.EfficientSugiyama:
                return(new EfficientSugiyamaLayoutAlgorithm <TVertex, TEdge, TGraph>(graph, parameters as EfficientSugiyamaLayoutParameters, positions, sizes));

            case LayoutAlgorithmTypeEnum.Sugiyama:
                return(new SugiyamaLayoutAlgorithm <TVertex, TEdge, TGraph>(graph, sizes, positions, parameters as SugiyamaLayoutParameters,
                                                                            e => (e is TypedEdge <TVertex>
                                                                                  ?(e as TypedEdge <TVertex>).Type
                                                                                  : EdgeTypes.Hierarchical)));

            case LayoutAlgorithmTypeEnum.CompoundFDP:
                return(new CompoundFDPLayoutAlgorithm <TVertex, TEdge, TGraph>(graph, sizes, new Dictionary <TVertex, Thickness>(), new Dictionary <TVertex, CompoundVertexInnerLayoutType>(),
                                                                               positions, parameters as CompoundFDPLayoutParameters));

            /*case LayoutAlgorithmTypeEnum.BalloonTree:
             *  return new BalloonTreeLayoutAlgorithm<TVertex, TEdge, TGraph>(Graph, Positions, Sizes, parameters as BalloonTreeLayoutParameters, Graph.Vertices.FirstOrDefault());*/
            default:
                return(null);
            }
        }
        public void StandardFactory()
        {
            var vertex    = new TestVertex("10");
            var positions = new Dictionary <TestVertex, Point>();
            var sizes     = new Dictionary <TestVertex, Size>();
            var graph     = new BidirectionalGraph <TestVertex, Edge <TestVertex> >();

            graph.AddVertex(vertex);
            var context = new ContextualLayoutContext <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(
                graph,
                vertex,
                positions,
                sizes);

            var factory = new ContextualLayoutAlgorithmFactory <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >();

            CollectionAssert.AreEqual(
                new[] { "DoubleTree", "BalloonTree" },
                factory.AlgorithmTypes);


            Assert.IsNull(
                factory.CreateAlgorithm(
                    string.Empty,
                    context,
                    new DoubleTreeLayoutParameters()));

            Assert.IsNull(
                factory.CreateAlgorithm(
                    "NotExist",
                    context,
                    new DoubleTreeLayoutParameters()));

            Assert.IsNull(
                factory.CreateAlgorithm(
                    "doubletree",
                    context,
                    new DoubleTreeLayoutParameters()));

            Assert.IsInstanceOf <DoubleTreeLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "DoubleTree",
                    context,
                    new DoubleTreeLayoutParameters()));

            Assert.IsInstanceOf <BalloonTreeLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "BalloonTree",
                    context,
                    new BalloonTreeLayoutParameters()));


            var testParameters                  = new TestLayoutParameters();
            var doubleTreeParameters            = new DoubleTreeLayoutParameters();
            ILayoutParameters createdParameters = factory.CreateParameters(string.Empty, doubleTreeParameters);

            Assert.IsNull(createdParameters);

            createdParameters = factory.CreateParameters("NotExist", doubleTreeParameters);
            Assert.IsNull(createdParameters);

            createdParameters = factory.CreateParameters("DoubleTree", null);
            Assert.IsInstanceOf <DoubleTreeLayoutParameters>(createdParameters);
            Assert.AreNotSame(doubleTreeParameters, createdParameters);

            createdParameters = factory.CreateParameters("DoubleTree", testParameters);
            Assert.IsInstanceOf <DoubleTreeLayoutParameters>(createdParameters);
            Assert.AreNotSame(testParameters, createdParameters);

            createdParameters = factory.CreateParameters("DoubleTree", doubleTreeParameters);
            Assert.IsInstanceOf <DoubleTreeLayoutParameters>(createdParameters);
            Assert.AreNotSame(doubleTreeParameters, createdParameters);

            var balloonTreeParameters = new BalloonTreeLayoutParameters();

            createdParameters = factory.CreateParameters("BalloonTree", null);
            Assert.IsInstanceOf <BalloonTreeLayoutParameters>(createdParameters);
            Assert.AreNotSame(balloonTreeParameters, createdParameters);

            createdParameters = factory.CreateParameters("BalloonTree", testParameters);
            Assert.IsInstanceOf <BalloonTreeLayoutParameters>(createdParameters);
            Assert.AreNotSame(testParameters, createdParameters);

            createdParameters = factory.CreateParameters("BalloonTree", balloonTreeParameters);
            Assert.IsInstanceOf <BalloonTreeLayoutParameters>(createdParameters);
            Assert.AreNotSame(balloonTreeParameters, createdParameters);


            Assert.IsFalse(factory.IsValidAlgorithm(null));
            Assert.IsFalse(factory.IsValidAlgorithm(string.Empty));
            Assert.IsTrue(factory.IsValidAlgorithm("DoubleTree"));
            Assert.IsFalse(factory.IsValidAlgorithm("doubletree"));
            Assert.IsTrue(factory.IsValidAlgorithm("BalloonTree"));


            var algorithm1 = new TestLayoutAlgorithm();

            Assert.IsEmpty(factory.GetAlgorithmType(algorithm1));

            var algorithm2 = new DoubleTreeLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph, positions, sizes, vertex, doubleTreeParameters);

            Assert.AreEqual("DoubleTree", factory.GetAlgorithmType(algorithm2));

            var algorithm3 = new BalloonTreeLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph, positions, vertex, balloonTreeParameters);

            Assert.AreEqual("BalloonTree", factory.GetAlgorithmType(algorithm3));


            Assert.IsFalse(factory.NeedEdgeRouting(string.Empty));
            Assert.IsTrue(factory.NeedEdgeRouting("DoubleTree"));
            Assert.IsTrue(factory.NeedEdgeRouting("BalloonTree"));


            Assert.IsFalse(factory.NeedOverlapRemoval(string.Empty));
            Assert.IsFalse(factory.NeedOverlapRemoval("DoubleTree"));
            Assert.IsFalse(factory.NeedOverlapRemoval("BalloonTree"));
        }
        private static ILayoutAlgorithm <TVertex, TEdge, TGraph> CreateAlgorithmInternal(
            [NotNull] string algorithmType,
            [NotNull] ILayoutContext <TVertex, TEdge, TGraph> context,
            [CanBeNull] ILayoutParameters parameters)
        {
            if (context.Mode == LayoutMode.Simple)
            {
                if (string.Equals(algorithmType, CircularAlgorithm))
                {
                    return(new CircularLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               context.Graph,
                               context.Positions,
                               context.Sizes,
                               parameters as CircularLayoutParameters));
                }

                if (string.Equals(algorithmType, TreeAlgorithm))
                {
                    return(new SimpleTreeLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               context.Graph,
                               context.Positions,
                               context.Sizes,
                               parameters as SimpleTreeLayoutParameters));
                }

                if (string.Equals(algorithmType, FRAlgorithm))
                {
                    return(new FRLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               context.Graph,
                               context.Positions,
                               parameters as FRLayoutParametersBase));
                }

                if (string.Equals(algorithmType, BoundedFRAlgorithm))
                {
                    return(new FRLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               context.Graph,
                               context.Positions,
                               parameters as BoundedFRLayoutParameters));
                }

                if (string.Equals(algorithmType, KKAlgorithm))
                {
                    return(new KKLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               context.Graph,
                               context.Positions,
                               parameters as KKLayoutParameters));
                }

                if (string.Equals(algorithmType, ISOMAlgorithm))
                {
                    return(new ISOMLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               context.Graph,
                               context.Positions,
                               parameters as ISOMLayoutParameters));
                }

                if (string.Equals(algorithmType, LinLogAlgorithm))
                {
                    return(new LinLogLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               context.Graph,
                               context.Positions,
                               parameters as LinLogLayoutParameters));
                }

                if (string.Equals(algorithmType, SugiyamaAlgorithm))
                {
                    return(new SugiyamaLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               context.Graph,
                               context.Positions,
                               context.Sizes,
                               parameters as SugiyamaLayoutParameters));
                }

                if (string.Equals(algorithmType, CompoundFDPAlgorithm))
                {
                    return(new CompoundFDPLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               context.Graph,
                               context.Positions,
                               context.Sizes,
                               new Dictionary <TVertex, Thickness>(),
                               new Dictionary <TVertex, CompoundVertexInnerLayoutType>(),
                               parameters as CompoundFDPLayoutParameters));
                }

                if (string.Equals(algorithmType, RandomAlgorithm))
                {
                    return(new RandomLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               context.Graph,
                               context.Positions,
                               context.Sizes,
                               new Dictionary <TVertex, RandomVertexType>(),
                               parameters as RandomLayoutParameters));
                }

                return(null);
            }

            if (context.Mode == LayoutMode.Compound &&
                context is ICompoundLayoutContext <TVertex, TEdge, TGraph> compoundContext &&
                string.Equals(algorithmType, CompoundFDPAlgorithm))
            {
                return(new CompoundFDPLayoutAlgorithm <TVertex, TEdge, TGraph>(
                           compoundContext.Graph,
                           compoundContext.Positions,
                           compoundContext.Sizes,
                           compoundContext.VerticesBorders,
                           compoundContext.LayoutTypes,
                           parameters as CompoundFDPLayoutParameters));
            }

            return(null);
        }
        public ILayoutAlgorithm <TVertex, TEdge, TGraph> CreateAlgorithm(string newAlgorithmType, ILayoutContext <TVertex, TEdge, TGraph> context, ILayoutParameters parameters)
        {
            if (context == null || context.Graph == null)
            {
                return(null);
            }

            if (context.Mode == LayoutMode.Simple)
            {
                switch (newAlgorithmType)
                {
                case "Tree":
                    return(new SimpleTreeLayoutAlgorithm <TVertex, TEdge, TGraph>(context.Graph, context.Positions,
                                                                                  context.Sizes,
                                                                                  parameters as SimpleTreeLayoutParameters));

                case "Circular":
                    return(new CircularLayoutAlgorithm <TVertex, TEdge, TGraph>(context.Graph, context.Positions,
                                                                                context.Sizes,
                                                                                parameters as CircularLayoutParameters));

                case "FR":
                    return(new FRLayoutAlgorithm <TVertex, TEdge, TGraph>(context.Graph, context.Positions,
                                                                          parameters as FRLayoutParametersBase));

                case "BoundedFR":
                    return(new FRLayoutAlgorithm <TVertex, TEdge, TGraph>(context.Graph, context.Positions,
                                                                          parameters as BoundedFRLayoutParameters));

                case "KK":
                    return(new KKLayoutAlgorithm <TVertex, TEdge, TGraph>(context.Graph, context.Positions,
                                                                          parameters as KKLayoutParameters));

                case "ISOM":
                    return(new ISOMLayoutAlgorithm <TVertex, TEdge, TGraph>(context.Graph, context.Positions,
                                                                            parameters as ISOMLayoutParameters));

                case "LinLog":
                    return(new LinLogLayoutAlgorithm <TVertex, TEdge, TGraph>(context.Graph, context.Positions,
                                                                              parameters as LinLogLayoutParameters));

                case "EfficientSugiyama":
                    return(new EfficientSugiyamaLayoutAlgorithm <TVertex, TEdge, TGraph>(context.Graph,
                                                                                         parameters as EfficientSugiyamaLayoutParameters,
                                                                                         context.Positions,
                                                                                         context.Sizes));

                case "Sugiyama":
                    return(new SugiyamaLayoutAlgorithm <TVertex, TEdge, TGraph>(context.Graph, context.Sizes,
                                                                                context.Positions,
                                                                                parameters as
                                                                                SugiyamaLayoutParameters,
                                                                                e => (e is TypedEdge <TVertex>
                                                                                      ?(e as TypedEdge <TVertex>).Type
                                                                                      : EdgeTypes.Hierarchical)));

                case "CompoundFDP":
                    return(new CompoundFDPLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               context.Graph,
                               context.Sizes,
                               new Dictionary <TVertex, Thickness>(),
                               new Dictionary <TVertex, CompoundVertexInnerLayoutType>(),
                               context.Positions,
                               parameters as CompoundFDPLayoutParameters));

                default:
                    return(null);
                }
            }
            else if (context.Mode == LayoutMode.Compound)
            {
                var compoundContext = context as ICompoundLayoutContext <TVertex, TEdge, TGraph>;
                switch (newAlgorithmType)
                {
                case "CompoundFDP":
                    return(new CompoundFDPLayoutAlgorithm <TVertex, TEdge, TGraph>(
                               compoundContext.Graph,
                               compoundContext.Sizes,
                               compoundContext.VertexBorders,
                               compoundContext.LayoutTypes,
                               compoundContext.Positions,
                               parameters as CompoundFDPLayoutParameters));

                default:
                    return(null);
                }
            }
            return(null);
        }
        ILayoutAlgorithm <TVertex, TEdge, TGraph> ILayoutAlgorithmFactory <TVertex, TEdge, TGraph> .CreateAlgorithm(string newAlgorithmType, ILayoutContext <TVertex, TEdge, TGraph> context, ILayoutParameters parameters)
        {
            Contract.Requires(newAlgorithmType != null);
            Contract.Requires(context as ContextualLayoutContext <TVertex, TEdge, TGraph> != null);

            var laf = (ILayoutAlgorithmFactory <TVertex, TEdge, TGraph>) this;

            Contract.Requires(laf.AlgorithmTypes.Contains(newAlgorithmType));

            return(default(ILayoutAlgorithm <TVertex, TEdge, TGraph>));
        }
        public void StandardFactory()
        {
            var positions     = new Dictionary <TestVertex, Point>();
            var sizes         = new Dictionary <TestVertex, Size>();
            var borders       = new Dictionary <TestVertex, Thickness>();
            var layoutTypes   = new Dictionary <TestVertex, CompoundVertexInnerLayoutType>();
            var graph         = new BidirectionalGraph <TestVertex, Edge <TestVertex> >();
            var simpleContext = new LayoutContext <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(
                graph,
                positions,
                sizes,
                LayoutMode.Simple);
            var compoundContext1 = new LayoutContext <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(
                graph,
                positions,
                sizes,
                LayoutMode.Compound);
            var compoundContext2 = new CompoundLayoutContext <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(
                graph,
                positions,
                sizes,
                LayoutMode.Compound,
                borders,
                layoutTypes);
            var nullGraphContext = new LayoutContext <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(
                null,
                positions,
                sizes,
                LayoutMode.Simple);

            var factory = new StandardLayoutAlgorithmFactory <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >();

            CollectionAssert.AreEqual(
                new[]
            {
                "Circular", "Tree", "FR", "BoundedFR", "KK",
                "ISOM", "LinLog", "Sugiyama", "CompoundFDP",
                "Random"
            },
                factory.AlgorithmTypes);


            Assert.IsNull(
                factory.CreateAlgorithm(
                    string.Empty,
                    simpleContext,
                    new CircularLayoutParameters()));

            Assert.IsNull(
                factory.CreateAlgorithm(
                    "NotExist",
                    simpleContext,
                    new CircularLayoutParameters()));

            Assert.IsNull(
                factory.CreateAlgorithm(
                    "Circular",
                    nullGraphContext,
                    new CircularLayoutParameters()));

            Assert.IsInstanceOf <CircularLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "Circular",
                    simpleContext,
                    new CircularLayoutParameters()));

            Assert.IsInstanceOf <SimpleTreeLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "Tree",
                    simpleContext,
                    new SimpleTreeLayoutParameters()));

            Assert.IsInstanceOf <FRLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "FR",
                    simpleContext,
                    new FreeFRLayoutParameters()));

            Assert.IsInstanceOf <FRLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "BoundedFR",
                    simpleContext,
                    new BoundedFRLayoutParameters()));

            Assert.IsInstanceOf <KKLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "KK",
                    simpleContext,
                    new KKLayoutParameters()));

            Assert.IsInstanceOf <ISOMLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "ISOM",
                    simpleContext,
                    new ISOMLayoutParameters()));

            Assert.IsInstanceOf <LinLogLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "LinLog",
                    simpleContext,
                    new LinLogLayoutParameters()));

            Assert.IsInstanceOf <SugiyamaLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "Sugiyama",
                    simpleContext,
                    new SugiyamaLayoutParameters()));

            Assert.IsInstanceOf <CompoundFDPLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "CompoundFDP",
                    simpleContext,
                    new CompoundFDPLayoutParameters()));

            Assert.IsInstanceOf <RandomLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "Random",
                    simpleContext,
                    new RandomLayoutParameters()));

            Assert.IsNull(
                factory.CreateAlgorithm(
                    "CompoundFDP",
                    compoundContext1,
                    new CompoundFDPLayoutParameters()));

            Assert.IsNull(
                factory.CreateAlgorithm(
                    "Circular",
                    compoundContext2,
                    new CompoundFDPLayoutParameters()));

            Assert.IsInstanceOf <CompoundFDPLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > > >(
                factory.CreateAlgorithm(
                    "CompoundFDP",
                    compoundContext2,
                    new CompoundFDPLayoutParameters()));


            var testParameters     = new TestLayoutParameters();
            var circularParameters = new CircularLayoutParameters();
            ILayoutParameters createdParameters = factory.CreateParameters(string.Empty, circularParameters);

            Assert.IsNull(createdParameters);

            createdParameters = factory.CreateParameters("NotExist", circularParameters);
            Assert.IsNull(createdParameters);

            createdParameters = factory.CreateParameters("Circular", null);
            Assert.IsInstanceOf <CircularLayoutParameters>(createdParameters);
            Assert.AreNotSame(circularParameters, createdParameters);

            createdParameters = factory.CreateParameters("Circular", testParameters);
            Assert.IsInstanceOf <CircularLayoutParameters>(createdParameters);
            Assert.AreNotSame(testParameters, createdParameters);

            createdParameters = factory.CreateParameters("Circular", circularParameters);
            Assert.IsInstanceOf <CircularLayoutParameters>(createdParameters);
            Assert.AreNotSame(circularParameters, createdParameters);

            var treeParameters = new SimpleTreeLayoutParameters();

            createdParameters = factory.CreateParameters("Tree", null);
            Assert.IsInstanceOf <SimpleTreeLayoutParameters>(createdParameters);
            Assert.AreNotSame(treeParameters, createdParameters);

            createdParameters = factory.CreateParameters("Tree", testParameters);
            Assert.IsInstanceOf <SimpleTreeLayoutParameters>(createdParameters);
            Assert.AreNotSame(testParameters, createdParameters);

            createdParameters = factory.CreateParameters("Tree", treeParameters);
            Assert.IsInstanceOf <SimpleTreeLayoutParameters>(createdParameters);
            Assert.AreNotSame(treeParameters, createdParameters);

            var frParameters = new FreeFRLayoutParameters();

            createdParameters = factory.CreateParameters("FR", null);
            Assert.IsInstanceOf <FreeFRLayoutParameters>(createdParameters);
            Assert.AreNotSame(frParameters, createdParameters);

            createdParameters = factory.CreateParameters("FR", testParameters);
            Assert.IsInstanceOf <FreeFRLayoutParameters>(createdParameters);
            Assert.AreNotSame(treeParameters, createdParameters);

            createdParameters = factory.CreateParameters("FR", frParameters);
            Assert.IsInstanceOf <FreeFRLayoutParameters>(createdParameters);
            Assert.AreNotSame(frParameters, createdParameters);

            var boundedFrParameters = new BoundedFRLayoutParameters();

            createdParameters = factory.CreateParameters("BoundedFR", null);
            Assert.IsInstanceOf <BoundedFRLayoutParameters>(createdParameters);
            Assert.AreNotSame(boundedFrParameters, createdParameters);

            createdParameters = factory.CreateParameters("BoundedFR", testParameters);
            Assert.IsInstanceOf <BoundedFRLayoutParameters>(createdParameters);
            Assert.AreNotSame(treeParameters, createdParameters);

            createdParameters = factory.CreateParameters("BoundedFR", boundedFrParameters);
            Assert.IsInstanceOf <BoundedFRLayoutParameters>(createdParameters);
            Assert.AreNotSame(boundedFrParameters, createdParameters);

            var kkParameters = new KKLayoutParameters();

            createdParameters = factory.CreateParameters("KK", null);
            Assert.IsInstanceOf <KKLayoutParameters>(createdParameters);
            Assert.AreNotSame(kkParameters, createdParameters);

            createdParameters = factory.CreateParameters("KK", testParameters);
            Assert.IsInstanceOf <KKLayoutParameters>(createdParameters);
            Assert.AreNotSame(treeParameters, createdParameters);

            createdParameters = factory.CreateParameters("KK", kkParameters);
            Assert.IsInstanceOf <KKLayoutParameters>(createdParameters);
            Assert.AreNotSame(kkParameters, createdParameters);

            var isomParameters = new ISOMLayoutParameters();

            createdParameters = factory.CreateParameters("ISOM", null);
            Assert.IsInstanceOf <ISOMLayoutParameters>(createdParameters);
            Assert.AreNotSame(isomParameters, createdParameters);

            createdParameters = factory.CreateParameters("ISOM", testParameters);
            Assert.IsInstanceOf <ISOMLayoutParameters>(createdParameters);
            Assert.AreNotSame(treeParameters, createdParameters);

            createdParameters = factory.CreateParameters("ISOM", isomParameters);
            Assert.IsInstanceOf <ISOMLayoutParameters>(createdParameters);
            Assert.AreNotSame(isomParameters, createdParameters);

            var linLogParameters = new LinLogLayoutParameters();

            createdParameters = factory.CreateParameters("LinLog", null);
            Assert.IsInstanceOf <LinLogLayoutParameters>(createdParameters);
            Assert.AreNotSame(linLogParameters, createdParameters);

            createdParameters = factory.CreateParameters("LinLog", testParameters);
            Assert.IsInstanceOf <LinLogLayoutParameters>(createdParameters);
            Assert.AreNotSame(treeParameters, createdParameters);

            createdParameters = factory.CreateParameters("LinLog", linLogParameters);
            Assert.IsInstanceOf <LinLogLayoutParameters>(createdParameters);
            Assert.AreNotSame(linLogParameters, createdParameters);

            var sugiyamaParameters = new SugiyamaLayoutParameters();

            createdParameters = factory.CreateParameters("Sugiyama", null);
            Assert.IsInstanceOf <SugiyamaLayoutParameters>(createdParameters);
            Assert.AreNotSame(sugiyamaParameters, createdParameters);

            createdParameters = factory.CreateParameters("Sugiyama", testParameters);
            Assert.IsInstanceOf <SugiyamaLayoutParameters>(createdParameters);
            Assert.AreNotSame(treeParameters, createdParameters);

            createdParameters = factory.CreateParameters("Sugiyama", sugiyamaParameters);
            Assert.IsInstanceOf <SugiyamaLayoutParameters>(createdParameters);
            Assert.AreNotSame(sugiyamaParameters, createdParameters);

            var compoundFDPParameters = new CompoundFDPLayoutParameters();

            createdParameters = factory.CreateParameters("CompoundFDP", null);
            Assert.IsInstanceOf <CompoundFDPLayoutParameters>(createdParameters);
            Assert.AreNotSame(compoundFDPParameters, createdParameters);

            createdParameters = factory.CreateParameters("CompoundFDP", testParameters);
            Assert.IsInstanceOf <CompoundFDPLayoutParameters>(createdParameters);
            Assert.AreNotSame(treeParameters, createdParameters);

            createdParameters = factory.CreateParameters("CompoundFDP", compoundFDPParameters);
            Assert.IsInstanceOf <CompoundFDPLayoutParameters>(createdParameters);
            Assert.AreNotSame(compoundFDPParameters, createdParameters);

            var randomParameters = new RandomLayoutParameters();

            createdParameters = factory.CreateParameters("Random", null);
            Assert.IsInstanceOf <RandomLayoutParameters>(createdParameters);
            Assert.AreNotSame(randomParameters, createdParameters);

            createdParameters = factory.CreateParameters("Random", testParameters);
            Assert.IsInstanceOf <RandomLayoutParameters>(createdParameters);
            Assert.AreNotSame(treeParameters, createdParameters);

            createdParameters = factory.CreateParameters("Random", randomParameters);
            Assert.IsInstanceOf <RandomLayoutParameters>(createdParameters);
            Assert.AreNotSame(randomParameters, createdParameters);


            Assert.IsFalse(factory.IsValidAlgorithm(null));
            Assert.IsFalse(factory.IsValidAlgorithm(string.Empty));
            Assert.IsTrue(factory.IsValidAlgorithm("Circular"));
            Assert.IsFalse(factory.IsValidAlgorithm("circular"));
            Assert.IsTrue(factory.IsValidAlgorithm("Tree"));
            Assert.IsTrue(factory.IsValidAlgorithm("FR"));
            Assert.IsTrue(factory.IsValidAlgorithm("BoundedFR"));
            Assert.IsTrue(factory.IsValidAlgorithm("KK"));
            Assert.IsTrue(factory.IsValidAlgorithm("ISOM"));
            Assert.IsTrue(factory.IsValidAlgorithm("LinLog"));
            Assert.IsTrue(factory.IsValidAlgorithm("Sugiyama"));
            Assert.IsTrue(factory.IsValidAlgorithm("CompoundFDP"));
            Assert.IsTrue(factory.IsValidAlgorithm("Random"));


            var algorithm1 = new TestLayoutAlgorithm();

            Assert.IsEmpty(factory.GetAlgorithmType(algorithm1));

            var algorithm2 = new CircularLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph, positions, sizes, circularParameters);

            Assert.AreEqual("Circular", factory.GetAlgorithmType(algorithm2));

            var algorithm3 = new SimpleTreeLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph, positions, sizes, treeParameters);

            Assert.AreEqual("Tree", factory.GetAlgorithmType(algorithm3));

            var algorithm4 = new FRLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph, positions, frParameters);

            Assert.AreEqual("FR", factory.GetAlgorithmType(algorithm4));

            var algorithm5 = new FRLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph, positions, boundedFrParameters);

            Assert.AreEqual("BoundedFR", factory.GetAlgorithmType(algorithm5));

            var algorithm6 = new KKLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph, positions, kkParameters);

            Assert.AreEqual("KK", factory.GetAlgorithmType(algorithm6));

            var algorithm7 = new ISOMLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph, positions, isomParameters);

            Assert.AreEqual("ISOM", factory.GetAlgorithmType(algorithm7));

            var algorithm8 = new LinLogLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph);

            Assert.AreEqual("LinLog", factory.GetAlgorithmType(algorithm8));

            var algorithm9 = new SugiyamaLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph, positions, sizes, sugiyamaParameters);

            Assert.AreEqual("Sugiyama", factory.GetAlgorithmType(algorithm9));

            var algorithm10 = new CompoundFDPLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph, sizes, borders, layoutTypes);

            Assert.AreEqual("CompoundFDP", factory.GetAlgorithmType(algorithm10));

            var algorithm11 = new RandomLayoutAlgorithm <TestVertex, Edge <TestVertex>, BidirectionalGraph <TestVertex, Edge <TestVertex> > >(graph, sizes, null, randomParameters);

            Assert.AreEqual("Random", factory.GetAlgorithmType(algorithm11));


            Assert.IsFalse(factory.NeedEdgeRouting(string.Empty));
            Assert.IsTrue(factory.NeedEdgeRouting("Circular"));
            Assert.IsTrue(factory.NeedEdgeRouting("Tree"));
            Assert.IsTrue(factory.NeedEdgeRouting("FR"));
            Assert.IsTrue(factory.NeedEdgeRouting("BoundedFR"));
            Assert.IsTrue(factory.NeedEdgeRouting("KK"));
            Assert.IsTrue(factory.NeedEdgeRouting("ISOM"));
            Assert.IsTrue(factory.NeedEdgeRouting("LinLog"));
            Assert.IsFalse(factory.NeedEdgeRouting("Sugiyama"));
            Assert.IsTrue(factory.NeedEdgeRouting("CompoundFDP"));
            Assert.IsTrue(factory.NeedEdgeRouting("Random"));


            Assert.IsFalse(factory.NeedOverlapRemoval(string.Empty));
            Assert.IsFalse(factory.NeedOverlapRemoval("Circular"));
            Assert.IsFalse(factory.NeedOverlapRemoval("Tree"));
            Assert.IsTrue(factory.NeedOverlapRemoval("FR"));
            Assert.IsTrue(factory.NeedOverlapRemoval("BoundedFR"));
            Assert.IsTrue(factory.NeedOverlapRemoval("KK"));
            Assert.IsTrue(factory.NeedOverlapRemoval("ISOM"));
            Assert.IsTrue(factory.NeedOverlapRemoval("LinLog"));
            Assert.IsFalse(factory.NeedOverlapRemoval("Sugiyama"));
            Assert.IsFalse(factory.NeedOverlapRemoval("CompoundFDP"));
            Assert.IsTrue(factory.NeedOverlapRemoval("Random"));
        }
        public ILayoutAlgorithm <TVertex, TEdge, TGraph> CreateAlgorithm(string newAlgorithmType,
                                                                         ILayoutContext <TVertex, TEdge, TGraph> context, ILayoutParameters parameters)
        {
            var layoutContext = context as ContextualLayoutContext <TVertex, TEdge, TGraph>;

            switch (newAlgorithmType)
            {
            /*case "DoubleTree":
             *      return new DoubleTreeLayoutAlgorithm<TVertex, TEdge, TGraph>( layoutContext.Graph, layoutContext.Positions, layoutContext.Sizes, parameters as DoubleTreeLayoutParameters, layoutContext.SelectedVertex );
             * case "BalloonTree":
             *      return new BalloonTreeLayoutAlgorithm<TVertex, TEdge, TGraph>( layoutContext.Graph, layoutContext.Positions, layoutContext.Sizes, parameters as BalloonTreeLayoutParameters, layoutContext.SelectedVertex );*/
            default:
                return(null);
            }
        }
Ejemplo n.º 22
0
        public ILayoutAlgorithm <TVertex, TEdge, TGraph> CreateLayoutAlgorithm(LayoutAlgorithmTypeEnum newAlgorithmType, TGraph Graph, IDictionary <TVertex, Point> Positions = null, IDictionary <TVertex, Size> Sizes = null, ILayoutParameters parameters = null)
        {
            if (Graph == null)
            {
                return(null);
            }
            if (parameters == null)
            {
                parameters = CreateLayoutParameters(newAlgorithmType);
            }

            switch (newAlgorithmType)
            {
            case LayoutAlgorithmTypeEnum.Tree:
                return(new SimpleTreeLayoutAlgorithm <TVertex, TEdge, TGraph>(Graph, Positions, Sizes, parameters as SimpleTreeLayoutParameters));

            case LayoutAlgorithmTypeEnum.SimpleRandom:
                return(new RandomLayoutAlgorithm <TVertex, TEdge, TGraph>(Graph));

            case LayoutAlgorithmTypeEnum.Circular:
                return(new CircularLayoutAlgorithm <TVertex, TEdge, TGraph>(Graph, Positions, Sizes, parameters as CircularLayoutParameters));

            case LayoutAlgorithmTypeEnum.FR:
                return(new FRLayoutAlgorithm <TVertex, TEdge, TGraph>(Graph, Positions, parameters as FRLayoutParametersBase));

            case LayoutAlgorithmTypeEnum.BoundedFR:
                return(new FRLayoutAlgorithm <TVertex, TEdge, TGraph>(Graph, Positions, parameters as BoundedFRLayoutParameters));

            case LayoutAlgorithmTypeEnum.KK:
                return(new KKLayoutAlgorithm <TVertex, TEdge, TGraph>(Graph, Positions, parameters as KKLayoutParameters));

            case LayoutAlgorithmTypeEnum.ISOM:
                return(new ISOMLayoutAlgorithm <TVertex, TEdge, TGraph>(Graph, Positions, parameters as ISOMLayoutParameters));

            case LayoutAlgorithmTypeEnum.LinLog:
                return(new LinLogLayoutAlgorithm <TVertex, TEdge, TGraph>(Graph, Positions, parameters as LinLogLayoutParameters));

            case LayoutAlgorithmTypeEnum.EfficientSugiyama:
                return(new EfficientSugiyamaLayoutAlgorithm <TVertex, TEdge, TGraph>(Graph, parameters as EfficientSugiyamaLayoutParameters, Positions, Sizes));

            case LayoutAlgorithmTypeEnum.Sugiyama:
                return(new SugiyamaLayoutAlgorithm <TVertex, TEdge, TGraph>(Graph, Sizes, Positions, parameters as SugiyamaLayoutParameters,
                                                                            e => (e is TypedEdge <TVertex>
                                                                                  ?(e as TypedEdge <TVertex>).Type
                                                                                  : EdgeTypes.Hierarchical)));

            case LayoutAlgorithmTypeEnum.CompoundFDP:
                return(new CompoundFDPLayoutAlgorithm <TVertex, TEdge, TGraph>(Graph, Sizes, new Dictionary <TVertex, Thickness>(), new Dictionary <TVertex, CompoundVertexInnerLayoutType>(),
                                                                               Positions, parameters as CompoundFDPLayoutParameters));

            /*case LayoutAlgorithmTypeEnum.BalloonTree:
             *  return new BalloonTreeLayoutAlgorithm<TVertex, TEdge, TGraph>(Graph, Positions, Sizes, parameters as BalloonTreeLayoutParameters, Graph.Vertices.FirstOrDefault());*/
            default:
                return(null);
            }
        }
Ejemplo n.º 23
0
        ILayoutParameters ILayoutAlgorithmFactory <TVertex, TEdge, TGraph> .CreateParameters(string algorithmType, ILayoutParameters oldParameters)
        {
            Contract.Requires(algorithmType != null);
            var laf = (ILayoutAlgorithmFactory <TVertex, TEdge, TGraph>) this;

            Contract.Requires(laf.AlgorithmTypes.Contains(algorithmType));

            return(default(ILayoutParameters));
        }