[10882] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Windows.Forms;
|
---|
| 5 | using HeuristicLab.Analysis;
|
---|
| 6 | using HeuristicLab.Core.Views;
|
---|
| 7 | using HeuristicLab.MainForm;
|
---|
| 8 |
|
---|
| 9 | namespace HeuristicLab.DataPreprocessing.Views {
|
---|
| 10 |
|
---|
[10987] | 11 | [View("Scatter Plot Single View")]
|
---|
[10952] | 12 | [Content(typeof(ScatterPlotContent), true)]
|
---|
[10987] | 13 | public partial class ScatterPlotSingleView : ItemView {
|
---|
[10882] | 14 |
|
---|
[10987] | 15 | public ScatterPlotSingleView() {
|
---|
[10882] | 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 |
|
---|
[10992] | 26 | IEnumerable<string> variables = Content.PreprocessingData.GetDoubleVariableNames();
|
---|
[10972] | 27 |
|
---|
| 28 | // add variables to combo boxes
|
---|
[10882] | 29 | comboBoxXVariable.Items.Clear();
|
---|
| 30 | comboBoxYVariable.Items.Clear();
|
---|
| 31 | comboBoxXVariable.Items.AddRange(variables.ToArray());
|
---|
| 32 | comboBoxYVariable.Items.AddRange(variables.ToArray());
|
---|
| 33 |
|
---|
[10952] | 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 | }
|
---|
[10882] | 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) {
|
---|
[10972] | 61 | //get scatter plot with selected x and y variable
|
---|
[10987] | 62 | ScatterPlot scatterPlot = Content.CreateScatterPlot((string)comboBoxXVariable.SelectedItem, (string)comboBoxYVariable.SelectedItem);
|
---|
[10882] | 63 | scatterPlotView.Content = scatterPlot;
|
---|
[10952] | 64 |
|
---|
| 65 | //save selected x and y variable in content
|
---|
| 66 | this.Content.SelectedXVariable = (string)comboBoxXVariable.SelectedItem;
|
---|
| 67 | this.Content.SelectedYVariable = (string)comboBoxYVariable.SelectedItem;
|
---|
[10882] | 68 | }
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[10992] | 73 |
|
---|
[10882] | 74 | }
|
---|