示例#1
0
 public Classifier(DSHierarchyWrapper hierarchy, DSClassifierWrapper classifier)
 {
     InitializeComponent();
     hierarchy_  = hierarchy;
     classifier_ = classifier;
 }
示例#2
0
 public Classifier(DSHierarchyWrapper hierarchy)
 {
     InitializeComponent();
     hierarchy_ = hierarchy;
 }
 public HierarchyComponents(DSHierarchyWrapper hierarchy)
 {
     InitializeComponent();
     hierarchy_ = hierarchy;
 }
示例#4
0
        public void visualize(DSHierarchyWrapper hierarchy, Panel panel1, PictureBox pictureBox1, TrackBar trackBar1)
        {
            Image drawing;

            if (hierarchy.getAttributes().Count > 0 || hierarchy.getClassifiers().Count > 0)
            {
                int max_count = 0;
                List <List <VisualUnit> >  visual_table = new List <List <VisualUnit> >();
                List <DSClassifierWrapper> classifiers  = hierarchy.getClassifiers();
                List <DSAttributeWrapper>  attributes   = hierarchy.getAttributes();
                classifiers.Sort((x, y) => x.getLevel().CompareTo(y.getLevel()));
                foreach (DSClassifierWrapper cl in classifiers)
                {
                    if (cl.getLevel() > visual_table.Count)
                    {
                        visual_table.Add(new List <VisualUnit>());
                    }
                    visual_table[cl.getLevel() - 1].Add(new VisualUnit(cl));
                }
                foreach (List <VisualUnit> list in visual_table)
                {
                    if (list.Count > max_count)
                    {
                        max_count = list.Count;
                    }
                }
                if (max_count > 0)
                {
                    if (max_count > attributes.Count)
                    {
                        drawing = new Bitmap(400 * max_count, 500 * (visual_table.Count + 1));
                    }
                    else
                    {
                        drawing = new Bitmap(300 * attributes.Count, 500 * (visual_table.Count + 1));
                    }
                }
                else
                {
                    drawing = new Bitmap(400 * attributes.Count, 500);
                }
                for (int i = visual_table.Count - 1; i >= 0; i--)
                {
                    for (int j = 0; j < visual_table[i].Count; j++)
                    {
                        PointF   p1 = new PointF((drawing.Width / (visual_table[i].Count * 2)) + (drawing.Width / (visual_table[i].Count) * j), 40.0F + 500 * (visual_table.Count - visual_table[i][j].classifier_.getLevel()));
                        PointF   p2 = new PointF(p1.X - 80, 200.0F + 500 * (visual_table.Count - visual_table[i][j].classifier_.getLevel()));
                        PointF   p3 = new PointF(p1.X + 80, 200.0F + 500 * (visual_table.Count - visual_table[i][j].classifier_.getLevel()));
                        PointF[] p  = { p1, p2, p3 };
                        visual_table[i][j].setPoints(p);
                    }
                }

                using (Graphics g = Graphics.FromImage(drawing))
                {
                    foreach (List <VisualUnit> list in visual_table)
                    {
                        foreach (VisualUnit unit in list)
                        {
                            g.DrawPolygon(new Pen(Color.Black, 4), unit.points);
                            if (unit.classifier_.getType() == "Fuzzy")
                            {
                                g.FillPolygon(new SolidBrush(Color.SkyBlue), unit.points);
                            }
                            else if (unit.classifier_.getType() == "Regressive")
                            {
                                g.FillPolygon(new SolidBrush(Color.Silver), unit.points);
                            }
                            g.DrawString(unit.classifier_.getName(), new Font("Verdana", 14), new SolidBrush(Color.Black), unit.points[1].X, unit.points[1].Y - 25);
                            List <DSClassifierWrapper> childs = unit.classifier_.getChilds();
                            if (childs.Count > 0)
                            {
                                foreach (DSClassifierWrapper cl in childs)
                                {
                                    foreach (List <VisualUnit> l in visual_table)
                                    {
                                        foreach (VisualUnit u in l)
                                        {
                                            string name1 = u.classifier_.getID();
                                            string name2 = cl.getID();
                                            if (u.classifier_.getID() == cl.getID())
                                            {
                                                g.DrawLine(new Pen(Color.Black, 3), new PointF(unit.points[1].X + 80, unit.points[2].Y), u.points[0]);
                                            }
                                        }
                                    }
                                }
                                trackBar1.Value = 0;
                                childs.Clear();
                            }
                        }
                    }
                    for (int i = 0; i < attributes.Count; i++)
                    {
                        PointF point = new PointF((drawing.Width / (attributes.Count * 2) - 25) + (drawing.Width / attributes.Count) * i, (500 * visual_table.Count) + 200);
                        g.DrawEllipse(new Pen(Color.Black, 3), new RectangleF(point, new SizeF(30.0F, 30.0F)));
                        g.DrawString(attributes[i].getName(), new Font("Verdana", 16), new SolidBrush(Color.Black), point.X - 50, point.Y + 55);
                        foreach (List <VisualUnit> l in visual_table)
                        {
                            foreach (VisualUnit u in l)
                            {
                                foreach (DSAttributeWrapper attr in u.classifier_.getAttributes())
                                {
                                    if (attr.getID() == attributes[i].getID())
                                    {
                                        PointF p = DrawBrokenLine(visual_table, new PointF(point.X + 15, point.Y), new PointF(u.points[1].X + 80, u.points[2].Y));
                                        if (p.X != -1 && p.Y != -1)
                                        {
                                            g.DrawLine(new Pen(Color.Black, 3), new PointF(point.X + 15, point.Y), p);
                                            g.DrawLine(new Pen(Color.Black, 3), p, new PointF(u.points[1].X + 80, u.points[2].Y));
                                        }
                                        else
                                        {
                                            g.DrawLine(new Pen(Color.Black, 3), new PointF(point.X + 15, point.Y), new PointF(u.points[1].X + 80, u.points[2].Y));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    g.Dispose();
                }
                trackBar1.Enabled = true;

                pictureBox1.Size  = drawing.Size;
                pictureBox1.Image = drawing;
                pictureBox1.Focus();
            }
            else
            {
                if (pictureBox1.Image != null)
                {
                    Graphics g = Graphics.FromImage(pictureBox1.Image);
                    g.Clear(pictureBox1.BackColor);
                    g.Dispose();

                    pictureBox1.Image = null;
                    pictureBox1.Size  = panel1.Size;
                }
                trackBar1.Value   = 0;
                trackBar1.Enabled = false;
            }
        }
示例#5
0
 public Attributes(DSHierarchyWrapper hierarchy)
 {
     InitializeComponent();
     hierarchy_ = hierarchy;
 }