Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.cs @ 12937

Last change on this file since 12937 was 12012, checked in by ascheibe, 10 years ago

#2212 merged r12008, r12009, r12010 back into trunk

File size: 3.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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;
23using System.Collections.Generic;
24using System.ComponentModel;
25using System.Drawing;
26using System.Data;
27using System.Linq;
28using System.Text;
29using System.Windows.Forms;
30using System.Windows.Forms.DataVisualization.Charting;
31using HeuristicLab.Common;
32
33namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
34  public partial class VariableTrackbar : UserControl {
35    private readonly string variableName;
36    private const double FACTOR = 1000;
37
38    public double Value {
39      get { return trackBar.Value / FACTOR; }
40    }
41
42    public string VariableName {
43      get { return variableName; }
44    }
45
46    public VariableTrackbar(string variableName, IEnumerable<double> values) {
47      InitializeComponent();
48      this.variableName = variableName;
49      groupBox.Text = variableName;
50      var valuesArr = values.ToArray();
51      this.valueTextBox.Text = string.Format("{0:0.000e+00}", valuesArr.Median());
52      boxPlotChart.Series["DataSeries"].Points.Clear();
53      boxPlotChart.Series["DataSeries"].Points.DataBindY(valuesArr);
54      boxPlotChart.Series["BoxPlot"].ChartType = SeriesChartType.BoxPlot;
55      boxPlotChart.Series["BoxPlot"]["BoxPlotSeries"] = "DataSeries";
56      boxPlotChart.Series["BoxPlot"]["BoxPlotWhiskerPercentile"] = "5";
57      boxPlotChart.Series["BoxPlot"]["BoxPlotPercentile"] = "30";
58      boxPlotChart.Series["BoxPlot"]["BoxPlotShowAverage"] = "true";
59      boxPlotChart.Series["BoxPlot"]["BoxPlotShowMedian"] = "true";
60      boxPlotChart.Series["BoxPlot"]["BoxPlotShowUnusualValues"] = "true";
61      boxPlotChart.ChartAreas[0].AxisY.Minimum = valuesArr.Min() ;
62      boxPlotChart.ChartAreas[0].AxisY.Maximum = valuesArr.Max() ;
63     
64
65      trackBar.Minimum = (int)Math.Round(valuesArr.Min() * FACTOR);
66      trackBar.Maximum = (int)Math.Round(valuesArr.Max() * FACTOR);
67      trackBar.Value = (int)Math.Round(valuesArr.Median() * FACTOR);
68      trackBar.TickStyle = TickStyle.None;
69      trackBar.Tag = variableName;
70    }
71
72    private void TrackBarValueChanged(object sender, EventArgs e) {
73      valueTextBox.Text = string.Format("{0:0.000e+00}", trackBar.Value / FACTOR);
74      RaiseValueChanged(EventArgs.Empty);
75    }
76
77    public event EventHandler ValueChanged;
78    private void RaiseValueChanged(EventArgs e) {
79      var handler = ValueChanged;
80      if (handler != null) handler(this, e);
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.