예제 #1
0
            public override void UpdateEdge(IGraph graph, IEdge edge, TEdge dataItem)
            {
                var labelData  = this.GetLabelData(dataItem, edge.GetSourceNode(), edge.GetTargetNode());
                var edgeObject = this.GetEdgeObject(dataItem);

                this.helper.builderUpdateEdge(graph, edge, labelData, edgeObject);
            }
        /// <summary>
        /// Determines whether source or target node of the given edge is part of <see cref="nodes"/>.
        /// </summary>
        private bool IsInterEdge(IEdge edge)
        {
            var sourceInNodes = nodes.Contains(edge.GetSourceNode());
            var targetInNodes = nodes.Contains(edge.GetTargetNode());

            return(sourceInNodes && !targetInNodes ||
                   targetInNodes && !sourceInNodes);
        }
        private void UpdateEdgeAndCreateMirrorEdge(IGraph graph, IEdge edge, object labelData, TNode edgeObject)
        {
            INode sourceMirrorNode;
            INode targetMirrorNode;

            if (this.nodeToMirrorNode.TryGetValue(edge.GetSourceNode(), out sourceMirrorNode) &&
                this.nodeToMirrorNode.TryGetValue(edge.GetTargetNode(), out targetMirrorNode))
            {
                this.mirrorGraph.CreateEdge(sourceMirrorNode, targetMirrorNode);
            }
            this.UpdateEdge(graph, edge, labelData);
        }
        private static void AddAboveLayerConstraint(LayerConstraintData layerConstraintData, IEdge edge, IGraph graph)
        {
            var sourceNode = edge.GetSourceNode();
            var targetNode = edge.GetTargetNode();

            var sourceNodes = new List <INode>();
            var targetNodes = new List <INode>();

            CollectLeafNodes(graph, sourceNode, sourceNodes);
            CollectLeafNodes(graph, targetNode, targetNodes);
            foreach (var source in sourceNodes)
            {
                foreach (var target in targetNodes)
                {
                    layerConstraintData.PlaceAbove(target, source);
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Removes bends inside of nodes, in addition to the clean-ups provided by
        /// the base implementation.
        /// </summary>
        public override void CleanUpEdge(IInputModeContext context, IGraph graph, IEdge edge)
        {
            base.CleanUpEdge(context, graph, edge);
            // now check bends which lie inside the node bounds and remove them...
            var sourceNode = edge.GetSourceNode();

            if (sourceNode != null)
            {
                var sourceContainsTest = sourceNode.SafeLookup <IShapeGeometry>();
                while (edge.Bends.Count > 0 && sourceContainsTest.IsInside(edge.Bends[0].Location.ToPointD()))
                {
                    var bendLocation = edge.Bends[0].Location.ToPointD();
                    // we try to move to port to the bend location so that the edge shape stays the same
                    graph.SetPortLocation(edge.SourcePort, bendLocation);
                    if (edge.SourcePort.GetLocation() != bendLocation)
                    {
                        break; // does not work - bail out
                    }
                    graph.Remove(edge.Bends[0]);
                }
            }
            var targetNode = edge.GetTargetNode();

            if (targetNode != null)
            {
                var targetContainsTest = targetNode.SafeLookup <IShapeGeometry>();
                while (edge.Bends.Count > 0 && targetContainsTest.IsInside(edge.Bends[edge.Bends.Count - 1].Location.ToPointD()))
                {
                    var lastBend     = edge.Bends[edge.Bends.Count - 1];
                    var bendLocation = lastBend.Location.ToPointD();
                    // we try to move to port to the bend location so that the edge shape stays the same
                    graph.SetPortLocation(edge.TargetPort, bendLocation);
                    if (edge.TargetPort.GetLocation() != bendLocation)
                    {
                        break; // does not work - bail out
                    }
                    graph.Remove(lastBend);
                }
            }
        }
예제 #6
0
        public EdgeAvatar(GameObject nodeAvatarPrefab, IEdge edge)
        {
            this.gameObject = MonoBehaviour.Instantiate(nodeAvatarPrefab, Vector3.zero, Quaternion.identity);

            MBEdgeAvatar mbEdegAvatar = this.gameObject.GetComponent <MBEdgeAvatar>();
            INode        source       = edge.GetSourceNode();
            INode        target       = edge.GetTargetNode();
            IAvatar      sourceAvatar;
            IAvatar      targetAvatar;

            if (source.TryGetAvatar(out sourceAvatar) && target.TryGetAvatar(out targetAvatar) && mbEdegAvatar != null)
            {
                this.sourceNodeAvatar = (INodeAvatar)sourceAvatar;
                this.targetNodeAvatar = (INodeAvatar)targetAvatar;

                mbEdegAvatar.SetSourceNodeAvatar(this.sourceNodeAvatar);
                mbEdegAvatar.SetTargetNodeAvatar(this.targetNodeAvatar);
            }
            else
            {
                G3DLogger.Log("Missing component in edge {0}, avatar constructor failed.", edge.GetId());
                this.SelfDestruct();
            }
        }
 /// <summary>
 /// Determines whether both source and target node of the given edge is part of <see cref="nodes"/>.
 /// </summary>
 private bool IsSubgraphEdge(IEdge edge)
 {
     return(nodes.Contains(edge.GetSourceNode()) &&
            nodes.Contains(edge.GetTargetNode()));
 }