Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/Visualization/Visualization.cs @ 10888

Last change on this file since 10888 was 9945, checked in by ascheibe, 11 years ago

#1886

  • added new convex hull algorithm based on SMO/SVM
  • added unit test and a visualization
  • updated MIConvexHull
File size: 2.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System.Collections.Generic;
23using System.Drawing;
24using System.Linq;
25using System.Windows.Forms;
26
27namespace Visualization {
28  public partial class VisualizationForm : Form {
29    public double[][] Inputs { get; set; }
30    public List<double[]> ConvexHull1 { get; set; }
31    public List<double[]> ConvexHull2 { get; set; }
32
33    public VisualizationForm() {
34      InitializeComponent();
35    }
36
37    private void Visualization_Load(object sender, System.EventArgs e) {
38      Draw();
39    }
40
41    private void DrawPixel(int x, int y, Color color, Bitmap image) {
42
43      using (Graphics g = Graphics.FromImage(image)) {
44        using (Brush b = new SolidBrush(color)) {
45          g.FillEllipse(b, x, y, 5, 5);
46        }
47      }
48    }
49
50    private void Draw() {
51      Bitmap image = new Bitmap(pictureBox.Width, pictureBox.Height);
52
53      foreach (var input in Inputs) {
54        DrawPixel((int)input.First(), (int)input.Last(), Color.Black, image);
55      }
56      foreach (var input in ConvexHull1) {
57        DrawPixel((int)input.First() + 1, (int)input.Last() + 1, Color.Red, image);
58      }
59      foreach (var input in ConvexHull2) {
60        DrawPixel((int)input.First(), (int)input.Last(), Color.Blue, image);
61      }
62
63      pictureBox.Image = image;
64    }
65  }
66}
Note: See TracBrowser for help on using the repository browser.