protected VertexData(VertexData movableParent, bool isFixedToParent, Point position)
 {
     MovableParent   = movableParent;
     IsFixedToParent = isFixedToParent;
     Parent          = null;
     Position        = position;
 }
        /// <summary>
        /// Initializes the data of the compound vertices.
        /// </summary>
        /// <param name="vertexBorders">Dictionary of the border thicknesses.</param>
        /// <param name="vertexSizes">Dictionary of the vertex sizes.</param>
        /// <param name="layoutTypes">Dictionary of the layout types.</param>
        /// <param name="movableParentUpdateQueue">The compound vertices with fixed layout
        /// should be added to this queue.</param>
        private void InitCompoundVertices(
            IDictionary <TVertex, Thickness> vertexBorders,
            IDictionary <TVertex, Size> vertexSizes,
            IDictionary <TVertex, CompoundVertexInnerLayoutType> layoutTypes,
            Queue <TVertex> movableParentUpdateQueue)
        {
            for (int i = _levels.Count - 1; i >= 0; i--)
            {
                foreach (var vertex in _levels[i])
                {
                    if (!_compoundGraph.IsCompoundVertex(vertex))
                    {
                        continue;
                    }

                    //get the data of the vertex
                    Thickness border;
                    vertexBorders.TryGetValue(vertex, out border);

                    Size vertexSize;
                    vertexSizes.TryGetValue(vertex, out vertexSize);
                    var layoutType = CompoundVertexInnerLayoutType.Automatic;
                    layoutTypes.TryGetValue(vertex, out layoutType);

                    if (layoutType == CompoundVertexInnerLayoutType.Fixed)
                    {
                        movableParentUpdateQueue.Enqueue(vertex);
                    }

                    var position = new Point();
                    VertexPositions.TryGetValue(vertex, out position);

                    //create the information container for this compound vertex
                    var dataContainer = new CompoundVertexData(vertex, _rootCompoundVertex, false, position, vertexSize, border, layoutType);
                    if (i == 0)
                    {
                        dataContainer.Parent = _rootCompoundVertex;
                        _rootCompoundVertex.Children.Add(dataContainer);
                    }

                    _compoundVertexDatas[vertex] = dataContainer;
                    _vertexDatas[vertex]         = dataContainer;

                    //add the datas of the childrens
                    var children     = _compoundGraph.GetChildrenVertices(vertex);
                    var childrenData = children.Select(v => _vertexDatas[v]).ToList();
                    dataContainer.Children = childrenData;
                    foreach (var child in dataContainer.Children)
                    {
                        _rootCompoundVertex.Children.Remove(child);
                        child.Parent = dataContainer;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VertexData"/> class.
 /// </summary>
 /// <param name="vertex">Target vertex.</param>
 /// <param name="movableParent">Moveable parent vertex data.</param>
 /// <param name="isFixedToParent">Indicates if the vertex position is fixed to its parent.</param>
 /// <param name="position">Vertex position.</param>
 protected VertexData(
     [CanBeNull] TVertex vertex,
     [CanBeNull] VertexData movableParent,
     bool isFixedToParent,
     Point position)
 {
     Vertex          = vertex;
     MovableParent   = movableParent;
     IsFixedToParent = isFixedToParent;
     Parent          = null;
     Position        = position;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes the data of the compound vertices.
        /// </summary>
        /// <param name="verticesBorders">Dictionary of the vertices border thicknesses.</param>
        /// <param name="verticesSizes">Dictionary of the vertices sizes.</param>
        /// <param name="layoutTypes">Dictionary of the layout types.</param>
        /// <param name="movableParentUpdateQueue">
        /// The compound vertices with fixed layout should be added to this queue.
        /// </param>
        private void InitCompoundVertices(
            [NotNull] IDictionary <TVertex, Thickness> verticesBorders,
            [NotNull] IDictionary <TVertex, Size> verticesSizes,
            [NotNull] IDictionary <TVertex, CompoundVertexInnerLayoutType> layoutTypes,
            [NotNull, ItemNotNull] Queue <TVertex> movableParentUpdateQueue)
        {
            for (int i = Levels.Count - 1; i >= 0; --i)
            {
                foreach (TVertex vertex in Levels[i])
                {
                    if (!_compoundGraph.IsCompoundVertex(vertex))
                    {
                        continue;
                    }

                    // Get the data of the vertex
                    verticesBorders.TryGetValue(vertex, out Thickness border);

                    verticesSizes.TryGetValue(vertex, out Size vertexSize);
                    layoutTypes.TryGetValue(vertex, out CompoundVertexInnerLayoutType layoutType);

                    if (layoutType == CompoundVertexInnerLayoutType.Fixed)
                    {
                        movableParentUpdateQueue.Enqueue(vertex);
                    }

                    VerticesPositions.TryGetValue(vertex, out Point position);

                    // Create the information container for this compound vertex
                    var dataContainer = new CompoundVertexData(vertex, _rootCompoundVertex, false, position, vertexSize, border, layoutType);
                    if (i == 0)
                    {
                        dataContainer.Parent = _rootCompoundVertex;
                        // ReSharper disable once PossibleNullReferenceException, Justification: root always has children
                        _rootCompoundVertex.Children.Add(dataContainer);
                    }
                    _compoundVerticesData[vertex] = dataContainer;
                    _verticesData[vertex]         = dataContainer;

                    // Add the data of the children
                    IEnumerable <TVertex> children     = _compoundGraph.GetChildrenVertices(vertex);
                    List <VertexData>     childrenData = children.Select(v => _verticesData[v]).ToList();
                    dataContainer.Children = childrenData;
                    foreach (VertexData child in dataContainer.Children)
                    {
                        // ReSharper disable once PossibleNullReferenceException, Justification: root always has children
                        _rootCompoundVertex.Children.Remove(child);
                        child.Parent = dataContainer;
                    }
                }
            }
        }