Beispiel #1
0
        /// <summary>
        /// Create default params if algorithm was changed and default params property is null
        /// </summary>
        /// <param name="type">Algorithm type (inner)</param>
        private void SetDefaultParams(int type)
        {
            switch (type)
            {
            //layout
            case 0:
                if (DefaultLayoutAlgorithmParams != null)
                {
                    return;
                }
                DefaultLayoutAlgorithmParams = AlgorithmFactory.CreateLayoutParameters(DefaultLayoutAlgorithm);
                return;

            //overlap
            case 1:
                if (DefaultOverlapRemovalAlgorithmParams != null)
                {
                    return;
                }
                DefaultOverlapRemovalAlgorithmParams = AlgorithmFactory.CreateOverlapRemovalParameters(DefaultOverlapRemovalAlgorithm);
                return;

            //edge
            case 2:
                if (DefaultEdgeRoutingAlgorithmParams != null)
                {
                    return;
                }
                DefaultEdgeRoutingAlgorithmParams = AlgorithmFactory.CreateEdgeRoutingParameters(DefaultEdgeRoutingAlgorithm);
                return;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Generate layout algorithm according to LogicCore layout algorithm default/external properties set
 /// </summary>
 /// <param name="desiredSize">Desired rectangular area size that will be taken into account</param>
 /// <param name="vertexPositions">Vertices positions</param>
 /// <param name="rectangles">Vertices rectangular sizes</param>
 public IExternalEdgeRouting <TVertex, TEdge> GenerateEdgeRoutingAlgorithm(Size desiredSize, IDictionary <TVertex, Point> vertexPositions = null, IDictionary <TVertex, Rect> rectangles = null)
 {
     if (ExternalEdgeRoutingAlgorithm == null && DefaultEdgeRoutingAlgorithm != EdgeRoutingAlgorithmTypeEnum.None)
     {
         return(AlgorithmFactory.CreateEdgeRoutingAlgorithm(DefaultEdgeRoutingAlgorithm, new Rect(desiredSize), Graph, vertexPositions, rectangles, DefaultEdgeRoutingAlgorithmParams));
     }
     return(ExternalEdgeRoutingAlgorithm);
 }
Beispiel #3
0
 /// <summary>
 /// Gets if current algorithms set needs vertices sizes
 /// </summary>
 public bool AreVertexSizesNeeded()
 {
     return((ExternalLayoutAlgorithm == null && AlgorithmFactory.NeedSizes(DefaultLayoutAlgorithm))
            ||
            (ExternalLayoutAlgorithm != null && ExternalLayoutAlgorithm.NeedVertexSizes)
            ||
            AreOverlapNeeded() || ExternalEdgeRoutingAlgorithm != null || DefaultEdgeRoutingAlgorithm != EdgeRoutingAlgorithmTypeEnum.None);
 }
Beispiel #4
0
 /// <summary>
 /// Gets if current algorithms set needs vertices sizes
 /// </summary>
 public bool AreVertexSizesNeeded()
 {
     return((ExternalLayoutAlgorithm == null && AlgorithmFactory.NeedSizes(DefaultLayoutAlgorithm))
            ||
            (ExternalLayoutAlgorithm != null && ExternalLayoutAlgorithm.NeedVertexSizes)
            ||
            AreOverlapNeeded());
 }
Beispiel #5
0
        /// <summary>
        /// Generate layout algorithm according to LogicCore layout algorithm default/external properties set
        /// </summary>
        /// <param name="vertexSizes">Vertices sizes</param>
        /// <param name="vertexPositions">Vertices positions</param>
        public IExternalLayout <TVertex, TEdge> GenerateLayoutAlgorithm(Dictionary <TVertex, Size> vertexSizes, IDictionary <TVertex, Point> vertexPositions)
        {
            var alg = ExternalLayoutAlgorithm ?? AlgorithmFactory.CreateLayoutAlgorithm(DefaultLayoutAlgorithm, Graph, vertexPositions, vertexSizes, DefaultLayoutAlgorithmParams);

            if (alg != null && alg.NeedVertexSizes)
            {
                alg.VertexSizes = vertexSizes;
            }
            return(alg);
        }
Beispiel #6
0
        /// <summary>
        /// Generate overlap removal algorithm according to LogicCore overlap removal algorithm default/external properties set
        /// </summary>
        /// <param name="rectangles">Vertices rectangular sizes</param>
        public IExternalOverlapRemoval <TVertex> GenerateOverlapRemovalAlgorithm(Dictionary <TVertex, Rect> rectangles = null)
        {
            if (ExternalOverlapRemovalAlgorithm == null)
            {
                //create default OR
                return(AlgorithmFactory.CreateOverlapRemovalAlgorithm(DefaultOverlapRemovalAlgorithm, null, DefaultOverlapRemovalAlgorithmParams));
            }
            var overlap = ExternalOverlapRemovalAlgorithm;

            overlap.Rectangles = rectangles;
            return(overlap);
        }
Beispiel #7
0
 /// <summary>
 /// Gets if current algorithms set actualy needs overlap removal algorithm
 /// </summary>
 public bool AreOverlapNeeded()
 {
     return((ExternalOverlapRemovalAlgorithm == null && AlgorithmFactory.NeedOverlapRemoval(DefaultLayoutAlgorithm) && DefaultOverlapRemovalAlgorithm != OverlapRemovalAlgorithmTypeEnum.None) ||
            (ExternalOverlapRemovalAlgorithm != null));
 }
Beispiel #8
0
 /// <summary>
 /// Creates new algorithm factory
 /// </summary>
 public void CreateNewAlgorithmFactory()
 {
     AlgorithmFactory = new AlgorithmFactory <TVertex, TEdge, TGraph>();
 }