source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.cs @ 10992

Last change on this file since 10992 was 10992, checked in by rstoll, 8 years ago
  • removed ChartLogic and

moved logic accordingly to PreprocessingChartContent, ScatterPlotContent
modified views etc. to use IFilteredPreprocessingData instead of ChartLogic

  • reordered code
File size: 2.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Windows.Forms;
5using HeuristicLab.Analysis;
6using HeuristicLab.Core.Views;
7using HeuristicLab.MainForm;
8
9namespace HeuristicLab.DataPreprocessing.Views {
10
11  [View("Scatter Plot Single View")]
12  [Content(typeof(ScatterPlotContent), true)]
13  public partial class ScatterPlotSingleView : ItemView {
14
15    public ScatterPlotSingleView() {
16      InitializeComponent();
17    }
18
19    public new ScatterPlotContent Content {
20      get { return (ScatterPlotContent)base.Content; }
21      set { base.Content = value; }
22    }
23
24    public void InitData() {
25
26      IEnumerable<string> variables = Content.PreprocessingData.GetDoubleVariableNames();
27
28      // add variables to combo boxes
29      comboBoxXVariable.Items.Clear();
30      comboBoxYVariable.Items.Clear();
31      comboBoxXVariable.Items.AddRange(variables.ToArray());
32      comboBoxYVariable.Items.AddRange(variables.ToArray());
33
34      // use x and y variable from content
35      if (Content.SelectedXVariable != null && Content.SelectedYVariable != null) {
36        comboBoxXVariable.SelectedItem = Content.SelectedXVariable;
37        comboBoxYVariable.SelectedItem = Content.SelectedYVariable;
38      } else {
39        if (variables.Count() >= 2) {
40          comboBoxXVariable.SelectedIndex = 0;
41          comboBoxYVariable.SelectedIndex = 1;
42          UpdateScatterPlot();
43
44        }
45      }
46    }
47
48    protected override void OnContentChanged() {
49      base.OnContentChanged();
50      if (Content != null) {
51        InitData();
52      }
53    }
54
55    private void comboBox_SelectedIndexChanged(object sender, EventArgs e) {
56      UpdateScatterPlot();
57    }
58
59    private void UpdateScatterPlot() {
60      if (comboBoxXVariable.SelectedItem != null && comboBoxYVariable.SelectedItem != null) {
61        //get scatter plot with selected x and y variable
62        ScatterPlot scatterPlot = Content.CreateScatterPlot((string)comboBoxXVariable.SelectedItem, (string)comboBoxYVariable.SelectedItem);
63        scatterPlotView.Content = scatterPlot;
64
65        //save selected x and y variable in content
66        this.Content.SelectedXVariable = (string)comboBoxXVariable.SelectedItem;
67        this.Content.SelectedYVariable = (string)comboBoxYVariable.SelectedItem;
68      }
69    }
70
71  }
72
73
74}
Note: See TracBrowser for help on using the repository browser.