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 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); } }
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); } }
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(); }