Free cookie consent management tool by TermsFeed Policy Generator

source: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ResultsView.cs @ 1104

Last change on this file since 1104 was 1075, checked in by gkronber, 16 years ago

worked on presentation layer for CEDMA #419

File size: 3.6 KB
RevLine 
[560]1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using HeuristicLab.Core;
[1075]10using HeuristicLab.CEDMA.Charting;
[560]11
[1073]12namespace HeuristicLab.CEDMA.Core {
[1075]13  public partial class ResultsView : ViewBase {
14    private Results results;
[560]15    private const string FREQUENCY = "<Frequency>";
[561]16    private const string CONSTANT_SIZE = "<constant>";
[571]17    private BubbleChartControl bubbleChartControl;
18    private HistogramControl histogramControl;
19    private Label pleaseSelectAxisLabel = new Label();
[560]20
[1075]21    public ResultsView(Results results) {
[560]22      this.results = results;
23      InitializeComponent();
[571]24      InitCharts();
[560]25      xAxisComboBox.Items.AddRange(results.VariableNames);
26      yAxisComboBox.Items.Add(FREQUENCY);
27      yAxisComboBox.Items.AddRange(results.VariableNames);
[561]28      sizeComboBox.Items.Add(CONSTANT_SIZE);
29      sizeComboBox.Items.AddRange(results.VariableNames);
30      sizeComboBox.SelectedItem = sizeComboBox.Items[0];
[571]31      sizeComboBox.Enabled = false;
32      invertCheckbox.Enabled = false;
33      sizeLabel.Enabled = false;
34      yAxisComboBox.SelectedItem = yAxisComboBox.Items[0];
35      xAxisComboBox.SelectedItem = xAxisComboBox.Items[0];
[560]36    }
37
[571]38    private void InitCharts() {
39      bubbleChartControl = new BubbleChartControl();
40      bubbleChartControl.Chart = new BubbleChart(results, 0, 0, 100, 100);
41      histogramControl = new HistogramControl();
42      histogramControl.Chart = new Histogram(results, 0, 0, 100, 100);
[561]43    }
44
[560]45    private void yAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
46      UpdateChart();
47    }
48
49    private void xAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
50      UpdateChart();
51    }
52
53    private void UpdateChart() {
54      if(xAxisComboBox.SelectedItem == null || yAxisComboBox.SelectedItem == null) return;
55      if(yAxisComboBox.SelectedItem.Equals(FREQUENCY)) {
[571]56        xJitterlabel.Enabled = false;
57        xTrackBar.Enabled = false;
58        yJitterLabel.Enabled = false;
59        yTrackBar.Enabled = false;
60        sizeComboBox.Enabled = false;
61        invertCheckbox.Enabled = false;
62        sizeLabel.Enabled = false;
63        chartPanel.Controls.Clear();
64        chartPanel.Controls.Add(histogramControl);
65        histogramControl.Chart.ShowFrequency((string)xAxisComboBox.SelectedItem);
66        histogramControl.Dock = DockStyle.Fill;
[560]67      } else {
[571]68        xJitterlabel.Enabled = true;
69        xTrackBar.Enabled = true;
70        yJitterLabel.Enabled = true;
71        yTrackBar.Enabled = true;
72        sizeComboBox.Enabled = true;
73        invertCheckbox.Enabled = true;
74        sizeLabel.Enabled = true;
75        chartPanel.Controls.Clear();
76        chartPanel.Controls.Add(bubbleChartControl);
77        bubbleChartControl.Chart.ShowXvsY((string)xAxisComboBox.SelectedItem, (string)yAxisComboBox.SelectedItem);
78        bubbleChartControl.Dock = DockStyle.Fill;
[560]79      }
80    }
81
[561]82    private void jitterTrackBar_ValueChanged(object sender, EventArgs e) {
[571]83      if(bubbleChartControl.Chart != null) {
[562]84        double xJitterFactor = xTrackBar.Value / 100.0;
85        double yJitterFactor = yTrackBar.Value / 100.0;
[571]86        bubbleChartControl.Chart.SetJitter(xJitterFactor, yJitterFactor);
[560]87      }
88      UpdateChart();
89    }
90
[561]91    private void sizeComboBox_SelectedIndexChanged(object sender, EventArgs e) {
[571]92      if(bubbleChartControl.Chart != null) {
93        bubbleChartControl.Chart.SetBubbleSizeDimension((string)sizeComboBox.SelectedItem, invertCheckbox.Checked);
[561]94        UpdateChart();
[560]95      }
96    }
97  }
98}
Note: See TracBrowser for help on using the repository browser.