示例#1
0
 // to create a null root. Root is unused as part of the processing.
 public ACNode(string name)
 {
     this.id = "";
     this.name = name;
     this.parent = null;
     this.children = new List<ACNode>();
 }
示例#2
0
 public ACNode(string name, ACNode parent)
 {
     ID_SEED++;
     this.id = ID_SEED.ToString();
     this.name = name;
     this.parent = parent;
     this.children = new List<ACNode>();
 }
示例#3
0
 public void addChild(ACNode node)
 {
     children.Add(node);
 }
        private static ACNode getArchitectureChart(DirectedPathNode root)
        {
            // Algorithm to generate architecture chart.

            // Start with the root node.
            ACNode nullRoot = new ACNode("null root");
            ACNode acRoot = new ACNode("SYSTEM", nullRoot);
            ACNode inputRoot = null;
            ACNode outputRoot = null;
            DirectedPathNode current = null;

            // determine now many input nodes there are.
            int inputNodes = getInputNodes(root);

            // build input tree.
            current = root;
            buildInputTree(current, acRoot, inputRoot, inputNodes);

            current = getDispatcher(root);
            acRoot.addChild(new ACNode(current.name, acRoot));

            // now we must build the dispatch tree.
            buildDispatchTree(current, acRoot);

            // now we need to build the output tree.
            int outputNodes = getOutputNodes(root);

            // build input tree.
            current = root;
            buildOutputTree(current, acRoot, outputRoot, outputNodes);

            return acRoot;
        }
        private static void buildOutputTree(DirectedPathNode root, ACNode acRoot, ACNode outputRoot, int outputNodes)
        {
            bool foundConverger = false;
            DirectedPathNode current = root;
            if (outputNodes > 1)
            {
                outputRoot = new ACNode("OUTPUT", acRoot);
                acRoot.addChild(outputRoot);

                while (!foundConverger)
                {
                    if (current.convergentPaths() > 1)
                    {
                        foundConverger = true;
                    }
                    else
                    {
                        current = current.next[MAIN_PATH];
                    }
                }
                // current = converger.
                int index = 0;
                while (index < outputNodes)
                {
                    outputRoot.addChild(new ACNode(current.name, outputRoot));
                    current = current.next[MAIN_PATH];
                    index++;
                }
            }
            else // just one input node.
            {
                outputRoot = new ACNode(current.name, acRoot);
                acRoot.addChild(outputRoot);
            }
        }
        private static void buildInputTree(DirectedPathNode current, ACNode acRoot, ACNode inputRoot, int inputNodes)
        {
            if (inputNodes > 1)
            {
                inputRoot = new ACNode("INPUT", acRoot);
                acRoot.addChild(inputRoot);

                int inputIndex = 0;
                while (inputIndex < inputNodes)
                {
                    inputRoot.addChild(new ACNode(current.name, inputRoot));
                    current = current.next[MAIN_PATH];
                    inputIndex++;
                }
            }
            else // just one input node.
            {
                inputRoot = new ACNode(current.name, acRoot);
                acRoot.addChild(inputRoot);
            }
        }
        /// <summary>
        /// Can only handle linear nodes on the dispatch tree.
        /// Can handle any number of branches and any length of strings
        /// though.
        /// </summary>
        /// <param name="d">d is the dispatcher node from which we buld.</param>
        private static void buildDispatchTree(DirectedPathNode d, ACNode root)
        {
            DirectedPathNode current = d.next[MAIN_PATH]; // start on the first element off dispatcher.
            int path = MAIN_PATH;
            ACNode dispatcher = root.children[DISPATCHER_INDEX];
            ACNode currentDepth = dispatcher;
            while (path < d.divergentPaths())
            {
                // add path node.
                current = d.next[path];
                currentDepth = dispatcher;
                currentDepth.addChild(new ACNode(current.name, currentDepth));
                currentDepth = currentDepth.children[path];
                current = current.next[MAIN_PATH];

                // we are going to go along the path until we reach
                // the convergence point.
                while (current.convergentPaths() == 1)
                {

                    currentDepth.addChild(new ACNode(current.name, currentDepth));
                    currentDepth = currentDepth.children[MAIN_PATH]; // want to select the path we just added.
                    current = current.next[MAIN_PATH];  // needs to be last so the while doesn't give us a problem
                }
                // lets do the next node.
                path++;
            }
        }
        public static void displayChart(DDTDiagram dfd, int processingStartID, int outputStartID)
        {
            // first lets get the directed graph from the DFD
            DirectedPathNode root = TransactionDFDConverter.getDirectedPath(dfd);
            string processingStart = DDTHelper.manager.project.getDDTObject(processingStartID).ToString();
            string outputStart = DDTHelper.manager.project.getDDTObject(outputStartID).ToString();

            ACNode nullRoot = new ACNode("null root");
            ACNode acRoot = new ACNode("SYSTEM", nullRoot);
            ACNode input = new ACNode("INPUT", acRoot);
            ACNode processing = new ACNode("PROCESSING", acRoot);
            ACNode output = new ACNode("OUTPUT", acRoot);

            acRoot.addChild(input);
            acRoot.addChild(processing);
            acRoot.addChild(output);

            DirectedPathNode current = root;
            // build the input tree.
            while (current.name != processingStart)
            {
                ACNode newNode = new ACNode(current.name, input);
                input.addChild(newNode);
                current = current.next[0];
            }
            // build the processing tree.
            while (current.name != outputStart)
            {
                ACNode newNode = new ACNode(current.name, processing);
                processing.addChild(newNode);
                current = current.next[0];
            }
            // build output tree.
            while (current != null)
            {
                ACNode newNode = new ACNode(current.name, output);
                output.addChild(newNode);
                current = current.next[0];
            }

            // actually create the architecture chart.
            TreeData.TreeDataTableDataTable dtTree = new TreeData.TreeDataTableDataTable();
            acRoot.getTree(dtTree);

            TreeBuilder t = new TreeBuilder(dtTree);
            //Now - Generate the tree itself
            Image i = Image.FromStream(
                t.GenerateTree(acRoot.id,
                System.Drawing.Imaging.ImageFormat.Bmp));
            i.Save("C://test.bmp");

            //ExecuteCommand("C://test.bmp", 100);
            PictureBox pb = new PictureBox();
            pb.SizeMode = PictureBoxSizeMode.AutoSize;
            pb.Image = i;

            Form newForm = new Form();
            newForm.Controls.Add(pb);
            newForm.AutoSize = true;
            newForm.BackColor = Color.White;
            newForm.Show();
        }