public void SetNameClasses() { foreach (Class c in Facade.classes) { String name = RecognizeShapes.FindTextClass(c, strokes_text, 0); c.SetName(name); } }
public void SetMethodsClasses() { foreach (Class c in Facade.classes) { String[] methods_list = null; String methods = RecognizeShapes.FindTextClass(c, strokes_text, 2); if (methods != null) { methods_list = methods.Split(new Char[] { ' ' }); } c.SetMethods(methods_list); } }
public void SetAttributesClasses() { foreach (Class c in Facade.classes) { String[] attributes_list = null; String attributes = RecognizeShapes.FindTextClass(c, strokes_text, 1); if (attributes != null) { attributes_list = attributes.Split(new Char[] { ' ' }); } c.SetAttributes(attributes_list); } }
public static void CreateCHICOFile() { // El archivo se va a guardar en la ruta indicada en el cuadro de diálogo de guardar using (StreamWriter stream_writer = new StreamWriter(Facade.path)) { // Se escribe la cabecera stream_writer.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); stream_writer.Write("<com.chico.chico:Model xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:Domain_Package=\"Domain_Package\" xmlns:com.chico.chico=\"com.chico.chico\">\n"); // Se recorre la lista de clases para ir escribiendo el contenido de cada una en el archivo for (int i = 0; i < Facade.classes.Count; i++) { Class c = Facade.classes[i]; String name = c.GetName(); stream_writer.Write("\t<itsClasses name =" + "\"" + name + "\"" + ">\n"); if (c.GetAttributes() != null) { for (int j = 0; j < c.GetAttributes().Length; j++) { String attribute = c.GetAttributes().GetValue(j).ToString(); stream_writer.Write("\t\t<itsAttributes name =" + "\"" + attribute + "\"" + "/>\n"); } } if (c.GetMethods() != null) { for (int j = 0; j < c.GetMethods().Length; j++) { String met = c.GetMethods().GetValue(j).ToString(); stream_writer.Write("\t\t<itsMethods name =" + "\"" + met + "\"" + "/>\n"); } } stream_writer.Write("\t</itsClasses>\n"); } // Se recorre la lista de relaciones para ir escribiendo el contenido de cada // una en el archivo for (int i = 0; i < Facade.relations.Count; i++) { Relation r = Facade.relations[i]; String source = "//@itsClasses." + RecognizeShapes.SearchIndexClass(r.GetStartClass()); String target = "//@itsClasses." + RecognizeShapes.SearchIndexClass(r.GetEndClass());; String relation_type = ""; switch (r.GetType()) { case 0: relation_type = "Domain_Package:Bidirectional_Association"; break; case 1: relation_type = "Domain_Package:Association"; break; case 2: relation_type = "Domain_Package:Generalization"; break; case 3: relation_type = "Domain_Package:Aggregation"; break; } stream_writer.Write("\t<itsRelationships xsi:type=" + "\"" + relation_type + "\""); stream_writer.Write(" source=" + "\"" + source + "\""); stream_writer.Write(" target=" + "\"" + target + "\""); stream_writer.Write("/>\n"); } stream_writer.Write("</com.chico.chico:Model>"); } }
private void exportarToolStripMenuItem_Click(object sender, EventArgs e) { GetPath(); if (Facade.path == null) { MessageBox.Show("Debe introducir una ruta", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { double dist_between_points = 0; List <Point> resampled = new List <Point>(); Renderer renderer = new Renderer(); Graphics g = pnlInput.CreateGraphics(); foreach (Stroke s in ink_overlay.Ink.Strokes) { if (!s.Deleted) { // Separar el texto de las figuras Divider(s); for (int i = 0; i < strokes_shape.Count; i++) { // Buscar las esquinas en las figuras dist_between_points = CornerFinder.DeterminingResampleSpacing(strokes_shape[i]); resampled = (List <Point>)CornerFinder.ResamplePoints(strokes_shape[i], dist_between_points); List <int> corners = (List <int>)CornerFinder.GetCorners(resampled); // Dividir las polilíneas en líneas SplitStrokes.SplitStroke(strokes_shape[i], resampled, corners, 0); } } } for (int i = 0; i < strokes_shape.Count; i++) { RecognizeShapes.Clasifier(strokes_shape[i]); } // Buscar clases RecognizeShapes.SearchClasses(); MessageBox.Show(Facade.classes.Count.ToString()); // Determinar el nombre de las clases SetNameClasses(); foreach (Class c in Facade.classes) { MessageBox.Show(c.GetName()); } // Determinar los atributos de las clases SetAttributesClasses(); // Determinar los metodos de las clases SetMethodsClasses(); // Actualizar la lista de strokes no procesados, es decir, todos los que no formen // parte de las clases. Esto reduce el grupo de strokes a procesar a las relaciones // entre clases. ActualiceNonRecognizedStrokes(); // Repetir buscar corner y dividir en líneas (con los strokes que no se han reconocido) for (int i = 0; i < Facade.strokes_without_recognize.Count; i++) { if (!Facade.strokes_without_recognize[i].Deleted) { // Buscar las esquinas en las figuras dist_between_points = CornerFinder.DeterminingResampleSpacing(Facade.strokes_without_recognize[i]); resampled = (List <Point>)CornerFinder.ResamplePoints(Facade.strokes_without_recognize[i], dist_between_points); List <int> corners = (List <int>)CornerFinder.GetCorners(resampled); // Dividir las polilíneas en líneas SplitStrokes.SplitStroke(Facade.strokes_without_recognize[i], resampled, corners, 1); } } if (Facade.strokes_without_recognize.Count > 0) { RecognizeShapes.SearchRelationships(); } CreateXML.CreateCHICOFile(); MessageBox.Show("Exportado"); } }