Example #1
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog d = new OpenFileDialog())
            {
                d.Filter = "Arff File|*.arff";
                if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var fileReader = new java.io.FileReader(d.FileName);
                    var instances  = new weka.core.Instances(new java.io.BufferedReader(fileReader));
                    instances.setClassIndex(instances.numAttributes() - 1);
                    fileReader.close();

                    clear_all();
                    foreach (weka.core.Instance i in instances)
                    {
                        var p = new valuePoint(i.value(0), i.value(1), (int)i.classValue());
                        if (p.x < 0 || p.x >= 1 || p.y < 0 || p.y >= 1)
                        {
                            continue;
                        }
                        point_list.Add(p);
                    }
                    draw_all_points();
                    this.pictureBox1.Invalidate();
                }
            }
        }
Example #2
0
        new public PatrolPath getShortestPath(IPoint src, IPoint dest, List <IPoint> availableTiles)
        {
            DistanceMap   distMap            = getDistanceMap(src);
            PatrolPath    reverse            = new PatrolPath();
            valuePoint    vPrevious          = new valuePoint();
            List <IPoint> availableTilesCopy = availableTiles.GetRange(0, availableTiles.Count);

            if (isPointInList(availableTiles, dest))
            {
                //Get last point, add to path,get next, add, etc
                reverse.MyWaypoints.Add(dest);
                vPrevious.p = dest;
                while (!vPrevious.p.equals(src))
                {
                    vPrevious = getPreviousInPath(getValuePoint(distMap.MyPoints, vPrevious.p),
                                                  availableTilesCopy, distMap.MyPoints);
                    if (vPrevious != null && vPrevious.p != null)
                    {
                        reverse.MyWaypoints.Add(vPrevious.p);
                        availableTilesCopy.Remove(availableTilesCopy.Find(delegate(IPoint p) { return(p.equals(vPrevious.p)); }));
                    }
                    else //Ran out of available points before reaching end
                    {
                        return(null);
                    }
                }
                //Reverse path
                reverse.MyWaypoints.Reverse();
            }
            return(reverse);
        }
Example #3
0
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            valuePoint p = new valuePoint((double)e.X / WXLEN, (double)e.Y / WYLEN, current_value);

            point_list.Add(p);
            draw_point(p);
            pictureBox1.Invalidate();
        }
Example #4
0
        private void draw_point(valuePoint p, Color?c = null)
        {
            //Graphics g = pictureBox1.CreateGraphics();
            //Rectangle rect = new System.Drawing.Rectangle((int)(p.x * WXLEN), (int)(p.y * WYLEN), WXLEN / XLEN, WYLEN / YLEN);
            //g.FillRectangle(choose_brush(p.value), rect);

            for (int ii = 0; ii < WXLEN / XLEN; ++ii)
            {
                for (int jj = 0; jj < WYLEN / YLEN; ++jj)
                {
                    m_pictureBoxBitmap.SetPixel((int)(p.x * WXLEN) + ii, (int)(p.y * WYLEN + jj), c.HasValue ? c.Value : GetValueColor(p.value, true));
                }
            }
        }
Example #5
0
        private void btnLoadStep_Click(object sender, EventArgs e)
        {
            if (m_loadStepInstances == null)
            {
                using (OpenFileDialog d = new OpenFileDialog())
                {
                    d.Filter = "Arff File|*.arff";
                    if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        m_loadStepInstances = new weka.core.Instances(new java.io.BufferedReader(new java.io.FileReader(d.FileName)));
                        m_loadStepInstances.setClassIndex(m_loadStepInstances.numAttributes() - 1);

                        clear_all();
                    }
                }
            }
            else
            {
                for (int i = m_loadStepIdx; i < m_loadStepInstances.numInstances(); ++i)
                {
                    var ins = m_loadStepInstances.instance(i);
                    var p   = new valuePoint(ins.value(0), ins.value(1), (int)ins.classValue());
                    if (p.x < 0 || p.x >= 1 || p.y < 0 || p.y >= 1)
                    {
                        continue;
                    }

                    point_list.Add(p);

                    draw_point(p);

                    m_loadStepIdx = i + 1;
                    if (i % 1000 == 0)
                    {
                        break;
                    }
                }

                pictureBox1.Invalidate();
                if (m_loadStepIdx == m_loadStepInstances.numInstances())
                {
                    m_loadStepIdx       = 0;
                    m_loadStepInstances = null;
                }
            }
        }
Example #6
0
 private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
 {
     valuePoint p = new valuePoint((double)e.X / WXLEN, (double)e.Y / WYLEN, current_value);
     point_list.Add(p);
     draw_point(p);
     pictureBox1.Invalidate();
 }
Example #7
0
        private void draw_point(valuePoint p, Color? c = null)
        {
            //Graphics g = pictureBox1.CreateGraphics();
            //Rectangle rect = new System.Drawing.Rectangle((int)(p.x * WXLEN), (int)(p.y * WYLEN), WXLEN / XLEN, WYLEN / YLEN);
            //g.FillRectangle(choose_brush(p.value), rect);

            for (int ii = 0; ii < WXLEN / XLEN; ++ii)
                for (int jj = 0; jj < WYLEN / YLEN; ++jj)
                    m_pictureBoxBitmap.SetPixel((int)(p.x * WXLEN) + ii, (int)(p.y * WYLEN + jj), c.HasValue ? c.Value : GetValueColor(p.value, true));
        }
Example #8
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog d = new OpenFileDialog())
            {
                d.Filter = "Arff File|*.arff";
                if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var fileReader = new java.io.FileReader(d.FileName);
                    var instances = new weka.core.Instances(new java.io.BufferedReader(fileReader));
                    instances.setClassIndex(instances.numAttributes() - 1);
                    fileReader.close();

                    clear_all();
                    foreach (weka.core.Instance i in instances)
                    {
                        var p = new valuePoint(i.value(0), i.value(1), (int)i.classValue());
                        if (p.x < 0 || p.x >= 1 || p.y < 0 || p.y >= 1)
                            continue;
                        point_list.Add(p);
                    }
                    draw_all_points();
                    this.pictureBox1.Invalidate();
                }
            }
        }
Example #9
0
        private void btnLoadStep_Click(object sender, EventArgs e)
        {
            if (m_loadStepInstances == null)
            {
                using (OpenFileDialog d = new OpenFileDialog())
                {
                    d.Filter = "Arff File|*.arff";
                    if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        m_loadStepInstances = new weka.core.Instances(new java.io.BufferedReader(new java.io.FileReader(d.FileName)));
                        m_loadStepInstances.setClassIndex(m_loadStepInstances.numAttributes() - 1);

                        clear_all();
                    }
                }
            }
            else
            {
                for (int i = m_loadStepIdx; i < m_loadStepInstances.numInstances(); ++i)
                {
                    var ins = m_loadStepInstances.instance(i);
                    var p = new valuePoint(ins.value(0), ins.value(1), (int)ins.classValue());
                    if (p.x < 0 || p.x >= 1 || p.y < 0 || p.y >= 1)
                        continue;

                    point_list.Add(p);

                    draw_point(p);

                    m_loadStepIdx = i + 1;
                    if (i % 1000 == 0)
                    {
                        break;
                    }
                }

                pictureBox1.Invalidate();
                if (m_loadStepIdx == m_loadStepInstances.numInstances())
                {
                    m_loadStepIdx = 0;
                    m_loadStepInstances = null;
                }
            }
        }