Example #1
0
 public void add_child(Classifier_ classifier)
 {
     classifier.Parent = this;
     children_classifiers.Add(classifier);
 }
Example #2
0
 private void draw_class(double top_left_X, double top_left_Y, Classifier_ classifier, int width)
 {
     draw_class_frame(top_left_X, top_left_Y, width);
     draw_class_info(top_left_X, top_left_Y, classifier, width);
 }
Example #3
0
        private void draw_class_info(double top_left_X, double top_left_Y, Classifier_ classifier, int width)
        {
            TextBlock class_name = new TextBlock();
            TextBlock class_fields = new TextBlock();
            TextBlock class_methods = new TextBlock();
            class_name.Width = width * 0.9;
            class_fields.Width = class_methods.Width = width * 0.975;
            //class_fields.Background = Brushes.White;

            class_fields.Height = class_methods.Height = width / 4 - 2;

            if (classifier.Name.Length <= 15)
            { class_name.Text = classifier.Name; }
            else
            { class_name.Text = classifier.Name.Substring(0, 12) + "..."; }

            String field_text = "[no fields]";
            if (classifier.Fields.Count > 0)
            { field_text = ""; }
            int field_count = classifier.Fields.Count;
            foreach (Field_ field in classifier.Fields)
            {

                if (field.Visibility == Member_Level_Visibility.PRIVATE)
                { field_text += "-"; }
                else if (field.Visibility == Member_Level_Visibility.PUBLIC)
                { field_text += "+"; }
                else
                { field_text += "#"; }
                field_text += field.Name + " : " + field.Type;
                if (!(field.Equals(classifier.Fields[field_count - 1])))
                { field_text += Environment.NewLine; }
            }
            class_fields.Text = field_text;

            String method_text = "[no methods]";
            if (classifier.Methods.Count > 0)
            { method_text = ""; }
            int method_count = classifier.Methods.Count;
            foreach (Method_ method in classifier.Methods)
            {
                if (method.Visibility == Member_Level_Visibility.PRIVATE)
                { method_text += "-"; }
                else if (method.Visibility == Member_Level_Visibility.PUBLIC)
                { method_text += "+"; }
                else
                { method_text += "#"; }
                method_text += method.Name + "(";
                int no_of_params = method.Parameters.Count;
                foreach (Variable_ param in method.Parameters)
                {
                    method_text += param.Name + " : " + param.Type;
                    if (!(param.Equals(method.Parameters[no_of_params - 1])))
                    { method_text += ", "; }
                }
                method_text += ") : " + method.ReturnType;
                if (!(method.Equals(classifier.Methods[method_count - 1])))
                { method_text += Environment.NewLine; }

            }
            class_methods.Text = method_text;

            class_name.FontFamily = new FontFamily("Courier New");
            class_fields.TextWrapping = class_methods.TextWrapping = TextWrapping.Wrap;
            Canvas.SetLeft(class_name, top_left_X + width / 20);
            Canvas.SetLeft(class_fields, top_left_X + width / 80);
            Canvas.SetLeft(class_methods, top_left_X + width / 80);

            Canvas.SetTop(class_name, top_left_Y);
            Canvas.SetTop(class_fields, top_left_Y + width / 8);
            Canvas.SetTop(class_methods, top_left_Y + width * 3 / 8);

            Canvas.SetZIndex(class_name, 1);
            Canvas.SetZIndex(class_fields, 1);
            Canvas.SetZIndex(class_methods, 1);

            class_name.FontSize = width / 10;

            if (width < 300)
            { class_fields.FontSize = class_methods.FontSize = width / 20; }
            else
            { class_fields.FontSize = class_methods.FontSize = 300 / 20; }

            if (width >= 150)
            {
                vWindow.main_view.Children.Add(class_methods);
                vWindow.main_view.Children.Add(class_fields);
            }
            vWindow.main_view.Children.Add(class_name);
        }
Example #4
0
        private Classifier_ get_classifier_info(XmlNode node)
        {
            Classifier_ classifier;
            if (node.Name.ToUpper() == "CLASS")
            { classifier = new Classifier_(node.Attributes["name"].Value, ClassifierType.CLASS);}

            else if (node.Name.ToUpper() == "INTERFACE")
            {  classifier = new Classifier_(node.Attributes["name"].Value, ClassifierType.INTERFACE);}
            else
            {  return null;}

            if ((node.Attributes["visibility"] == null) || (node.Attributes["visibility"].Value == ""))
            { classifier.Visibility = Top_Level_Visibility.PACKAGE_PRIVATE; }
            else if (node.Attributes["visibility"].Value.ToUpper() == "PUBLIC")
            { classifier.Visibility = Top_Level_Visibility.PUBLIC;}

            foreach (XmlNode child_node in node.ChildNodes)
            {
                if (child_node.Name.ToUpper() == "FIELD")
                {
                    Field_ field = new Field_(child_node.Attributes["name"].Value, child_node.Attributes["type"].Value);

                    if (child_node.Attributes["visibility"] != null)
                    {
                        if (child_node.Attributes["visibility"].Value.ToUpper() == "PRIVATE")
                        { field.Visibility = Member_Level_Visibility.PRIVATE; }
                        else if (child_node.Attributes["visibility"].Value.ToUpper() == "PUBLIC")
                        { field.Visibility = Member_Level_Visibility.PUBLIC; }
                        else if (child_node.Attributes["visibility"].Value.ToUpper() == "PROTECTED")
                        { field.Visibility = Member_Level_Visibility.PROTECTED; }
                    }

                    if (child_node.Attributes["isstatic"] != null)
                    {
                        if (child_node.Attributes["isstatic"].Value == "false")
                        { field.IsStatic = false; }
                        else
                        { field.IsStatic = true; }
                    }
                    classifier.add_field(field);
                }

                if (child_node.Name.ToUpper() == "METHOD")
                {
                    Method_ method = new Method_(child_node.Attributes["name"].Value,child_node.Attributes["returntype"].Value );

                    if (child_node.Attributes["visibility"] != null)
                    {
                        if (child_node.Attributes["visibility"].Value.ToUpper() == "PRIVATE")
                        { method.Visibility = Member_Level_Visibility.PRIVATE; }
                        else if (child_node.Attributes["visibility"].Value.ToUpper() == "PUBLIC")
                        { method.Visibility = Member_Level_Visibility.PUBLIC; }
                        else if (child_node.Attributes["visibility"].Value.ToUpper() == "PROTECTED")
                        { method.Visibility = Member_Level_Visibility.PROTECTED; }
                    }

                    if (child_node.Attributes["isstatic"] != null)
                    {
                        if (child_node.Attributes["isstatic"].Value == "false")
                        { method.IsStatic = false; }
                        else
                        { method.IsStatic = true; }
                    }

                    foreach (XmlNode parameter in child_node.ChildNodes)
                    {
                        if (parameter.Name.ToUpper() == "PARAMETER")
                        {
                            method.add_parameter( new Variable_(parameter.Attributes["name"].Value,parameter.Attributes["type"].Value));
                        }

                    }

                    classifier.add_method(method);
                }

            }

            return classifier;
        }