Пример #1
0
        public override ExperimentNode Clone()
        {
            var clone = new ExperimentStartNode();

            clone.CopyFrom(this);
            return(clone);
        }
Пример #2
0
        /// <summary>
        /// Connects the nodes to start and end node.
        /// In case user selected partial graph without start or/and end node, this methods adds
        /// accordingly Start and End node to the given composite graph.
        /// If some selected nodes didn't have any outgoing paths they are automatically connected to the end node.
        /// If some selected nodes didn't have any incoming paths they are automatically connected to the start node.
        /// </summary>
        /// <param name="compositeComponentGraph">The composite component graph.</param>

        // HERZUM SPRINT 2.4 TLAB-157
        // private static void ConnectNodesToStartAndEndNode(CompositeComponentGraph compositeComponentGraph)
        public static void ConnectNodesToStartAndEndNode(CompositeComponentGraph compositeComponentGraph)
        // END HERZUM SPRINT 2.4 TLAB-157
        {
            if (compositeComponentGraph.StartNode == null || compositeComponentGraph.EndNode == null)
            {
                double startX, startY, endX, endY;

                DetermineOptimalStartEndPositions(compositeComponentGraph, out startX, out startY, out endX, out endY);

                if (compositeComponentGraph.StartNode == null)
                {
                    //create start node and add it to graph, and connect it to the existing graph
                    ExperimentStartNode start = new ExperimentStartNode();
                    start.Data.X = startX;
                    start.Data.Y = startY;
                    compositeComponentGraph.AddVertex(start);
                    compositeComponentGraph.StartNode = start;
                }

                if (compositeComponentGraph.EndNode == null)
                {
                    //create start node and add it to graph, and connect it to the existing graph
                    ExperimentEndNode end = new ExperimentEndNode();
                    end.Data.X = endX;
                    end.Data.Y = endY;
                    compositeComponentGraph.AddVertex(end);
                    compositeComponentGraph.EndNode = end;
                }

                //connect subgraph to start and end
                foreach (ExperimentNode node in compositeComponentGraph.Vertices)
                {
                    if (node is ExperimentStartNode == false && node is ExperimentEndNode == false)
                    {
                        //if node has not any incoming connection from other Selected Nodes it has to be connected to the start
                        if (compositeComponentGraph.IsInEdgesEmpty(node))
                        {
                            compositeComponentGraph.AddEdge(new ExperimentNodeConnection(Guid.NewGuid().ToString(), compositeComponentGraph.StartNode, node));
                        }

                        //if node has not any outcoming connection from other Selected Nodes it has to be connected to the end
                        if (compositeComponentGraph.IsOutEdgesEmpty(node))
                        {
                            compositeComponentGraph.AddEdge(new ExperimentNodeConnection(Guid.NewGuid().ToString(), node, compositeComponentGraph.EndNode));
                        }
                    }
                }
                // HERZUM SPRINT 3.0: COMPOSITE BUG FIX
                if (compositeComponentGraph.EdgeCount == 0 && compositeComponentGraph.StartNode != null && compositeComponentGraph.EndNode != null)
                {
                    compositeComponentGraph.AddEdge(new ExperimentNodeConnection(Guid.NewGuid().ToString(), compositeComponentGraph.StartNode, compositeComponentGraph.EndNode));
                    compositeComponentGraph.StartNode.Data.X = 0;
                    compositeComponentGraph.StartNode.Data.Y = 0;
                    compositeComponentGraph.EndNode.Data.X   = 0;
                    compositeComponentGraph.EndNode.Data.Y   = 100;
                }
                // END HERZUM SPRINT 3.0: COMPOSITE BUG FIX
            }
        }
Пример #3
0
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (nodeData == null)
            {
                throw new ArgumentNullException("nodeData");
            }

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return(node);
        }
        /// <summary>
        /// Creates new m_experiment.
        /// </summary>
        /// <returns>Returns newly created m_experiment.</returns>
        public static Experiment New()
        {
            Experiment newExperiment = new Experiment(NewExperimentName, string.Empty);
            ExperimentStartNode start = new ExperimentStartNode();
            start.Data.X = 200;
            start.Data.Y = 100;
            newExperiment.AddVertex(start);
            
            ExperimentEndNode end = new ExperimentEndNode();
            end.Data.X = 200;
            end.Data.Y = 200;
            newExperiment.AddVertex(end);

            newExperiment.ReloadStartAndEndNode();
            newExperiment.ResetModifiedFlag();

            return newExperiment;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompositeComponentEditableGraph"/> class.
        /// Constructor used to create empty new editable graph. Initially it does not have OwnerNode.
        /// The OwnerNode is set in initialization step when metadata that contains graph is assigned to scope node.
        /// </summary>
        /// <param name="initStartEnd">if set to <c>true</c> [init start end].</param>
        public CompositeComponentEditableGraph(bool initStartEnd) : base()
        {
            if (initStartEnd)
            {
                ExperimentStartNode start = new ExperimentStartNode(Guid.NewGuid().ToString(), "Enter");
                start.Data.X = 0;
                start.Data.Y = 0;
                AddVertex(start);

                ExperimentEndNode end = new ExperimentEndNode(Guid.NewGuid().ToString(), "Exit");
                end.Data.X = 0;
                end.Data.Y = 0;
                AddVertex(end);

                ReloadStartAndEndNode();
            }

            //note, OwnerNode is set in InitializeComponentGraph of ScopeNode
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompositeComponentEditableGraph"/> class.
        /// Constructor used to create empty new editable graph. Initially it does not have OwnerNode. 
        /// The OwnerNode is set in initialization step when metadata that contains graph is assigned to scope node.
        /// </summary>
        /// <param name="initStartEnd">if set to <c>true</c> [init start end].</param>
        public CompositeComponentEditableGraph(bool initStartEnd) : base()
        {
            if (initStartEnd)
            {
                ExperimentStartNode start = new ExperimentStartNode(Guid.NewGuid().ToString(), "Enter");
                start.Data.X = 0;
                start.Data.Y = 0;
                AddVertex(start);

                ExperimentEndNode end = new ExperimentEndNode(Guid.NewGuid().ToString(), "Exit");
                end.Data.X = 0;
                end.Data.Y = 0;
                AddVertex(end);

                ReloadStartAndEndNode();
            }

            //note, OwnerNode is set in InitializeComponentGraph of ScopeNode
        }
Пример #7
0
        /// <summary>
        /// Creates new m_experiment.
        /// </summary>
        /// <returns>Returns newly created m_experiment.</returns>
        public static Experiment New()
        {
            Experiment          newExperiment = new Experiment(NewExperimentName, string.Empty);
            ExperimentStartNode start         = new ExperimentStartNode();

            start.Data.X = 200;
            start.Data.Y = 100;
            newExperiment.AddVertex(start);

            ExperimentEndNode end = new ExperimentEndNode();

            end.Data.X = 200;
            end.Data.Y = 200;
            newExperiment.AddVertex(end);

            newExperiment.ReloadStartAndEndNode();
            newExperiment.ResetModifiedFlag();

            return(newExperiment);
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var vertexControl = (GraphSharp.Controls.VertexControl)DataContext;
            m_enterScopeNode = (ExperimentStartNode)vertexControl.Vertex;

            //listen to property changed of the parent scope node, and update exit node x and y, if scope size is changing. 
            LoopScopeNodeControl scope = this.GetParent<LoopScopeNodeControl>(null);

            //find node label border - needed border height to adjust node move inside the canvas
            Border labelBorder = (Border)scope.Template.FindName("labelBorder", scope);
            m_labelHeight = labelBorder.ActualHeight;

            m_scopeNode = (LoopScopeNode)scope.VertexControl.Vertex;

            //listen to scope node size change and decision node position changes
            m_scopeNode.DataWithSize.PropertyChanged += ScopeNodeData_PropertyChanged;

            //intially move node to the border
            MoveNodeToCenterOfTopBorder();
        }
        /// <summary>
        /// Connects the nodes to start and end node.
        /// In case user selected partial graph without start or/and end node, this methods adds 
        /// accordingly Start and End node to the given composite graph. 
        /// If some selected nodes didn't have any outgoing paths they are automatically connected to the end node.
        /// If some selected nodes didn't have any incoming paths they are automatically connected to the start node.
        /// </summary>
        /// <param name="compositeComponentGraph">The composite component graph.</param>
        private static void ConnectNodesToStartAndEndNode(CompositeComponentGraph compositeComponentGraph)
        {
            if (compositeComponentGraph.StartNode == null || compositeComponentGraph.EndNode == null)
            {
                double startX, startY, endX, endY;

                DetermineOptimalStartEndPositions(compositeComponentGraph, out startX, out startY, out endX, out endY);

                if (compositeComponentGraph.StartNode == null)
                {
                    //create start node and add it to graph, and connect it to the existing graph
                    ExperimentStartNode start = new ExperimentStartNode();
                    start.Data.X = startX;
                    start.Data.Y = startY;
                    compositeComponentGraph.AddVertex(start);
                    compositeComponentGraph.StartNode = start;
                }

                if (compositeComponentGraph.EndNode == null)
                {
                    //create start node and add it to graph, and connect it to the existing graph
                    ExperimentEndNode end = new ExperimentEndNode();
                    end.Data.X = endX;
                    end.Data.Y = endY;
                    compositeComponentGraph.AddVertex(end);
                    compositeComponentGraph.EndNode = end;
                }

                //connect subgraph to start and end
                foreach (ExperimentNode node in compositeComponentGraph.Vertices)
                {
                    if (node is ExperimentStartNode == false && node is ExperimentEndNode == false)
                    {
                        //if node has not any incoming connection from other Selected Nodes it has to be connected to the start
                        if (compositeComponentGraph.IsInEdgesEmpty(node))
                        {
                            compositeComponentGraph.AddEdge(new ExperimentNodeConnection(Guid.NewGuid().ToString(), compositeComponentGraph.StartNode, node));
                        }

                        //if node has not any outcoming connection from other Selected Nodes it has to be connected to the end
                        if (compositeComponentGraph.IsOutEdgesEmpty(node))
                        {
                            compositeComponentGraph.AddEdge(new ExperimentNodeConnection(Guid.NewGuid().ToString(), node, compositeComponentGraph.EndNode));
                        }
                    }
                }
            }
        }
Пример #10
0
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
                throw new ArgumentNullException("id");
            if (nodeData == null)
                throw new ArgumentNullException("nodeData");

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            // HERZUM SPRINT 1.0
            else if (nodeData.Metadata is CommentMetadata)
            {
                // HERZUM SPRINT 1.2
                // node = new CommentNode(id, nodeData);
                node = new CommentNode(id, (SerializedVertexDataWithSize) nodeData);
                // END HERZUM SPRINT 1.2
            }
            // END HERZUM SPRINT 1.0
            // HERZUM SPRINT 2.0: TLAB-65 CLASS
            else if (nodeData.Metadata is ChallengeMetadata)
            {
                node = new ChallengeNode(id, (SerializedVertexDataWithSize) nodeData);
            }
            // END HERZUM SPRINT 2.0: TLAB-65 CLASS
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return node;
        }
Пример #11
0
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (nodeData == null)
            {
                throw new ArgumentNullException("nodeData");
            }

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            // HERZUM SPRINT 1.0
            else if (nodeData.Metadata is CommentMetadata)
            {
                // HERZUM SPRINT 1.2
                // node = new CommentNode(id, nodeData);
                node = new CommentNode(id, (SerializedVertexDataWithSize)nodeData);
                // END HERZUM SPRINT 1.2
            }
            // END HERZUM SPRINT 1.0
            // HERZUM SPRINT 2.0: TLAB-65 CLASS
            else if (nodeData.Metadata is ChallengeMetadata)
            {
                node = new ChallengeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            // END HERZUM SPRINT 2.0: TLAB-65 CLASS
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return(node);
        }
 public override ExperimentNode Clone()
 {
     var clone = new ExperimentStartNode();
     clone.CopyFrom(this);
     return clone;
 }
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
                throw new ArgumentNullException("id");
            if (nodeData == null)
                throw new ArgumentNullException("nodeData");

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return node;
        }