1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Data;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Windows.Forms;
|
---|
9 | using HeuristicLab.Core;
|
---|
10 | using HeuristicLab.Charting;
|
---|
11 |
|
---|
12 | namespace HeuristicLab.CEDMA.Charting {
|
---|
13 | public partial class ResultListView : ViewBase {
|
---|
14 | private ResultList results;
|
---|
15 | private const string FREQUENCY = "<Frequency>";
|
---|
16 | private const string CONSTANT_SIZE = "<constant>";
|
---|
17 | private double xJitterFactor = 0.0;
|
---|
18 | private double yJitterFactor = 0.0;
|
---|
19 | private double maxXJitterPercent = .1;
|
---|
20 | private double maxYJitterPercent = .1;
|
---|
21 |
|
---|
22 | public ResultListView(ResultList results) {
|
---|
23 | this.results = results;
|
---|
24 | results.Changed += new EventHandler(results_Changed);
|
---|
25 | InitializeComponent();
|
---|
26 | xAxisComboBox.Items.AddRange(results.VariableNames);
|
---|
27 | yAxisComboBox.Items.Add(FREQUENCY);
|
---|
28 | yAxisComboBox.Items.AddRange(results.VariableNames);
|
---|
29 | sizeComboBox.Items.Add(CONSTANT_SIZE);
|
---|
30 | sizeComboBox.Items.AddRange(results.VariableNames);
|
---|
31 | sizeComboBox.SelectedItem = sizeComboBox.Items[0];
|
---|
32 | InitChart();
|
---|
33 | }
|
---|
34 |
|
---|
35 | private DateTime lastUpdate = DateTime.Now;
|
---|
36 | void results_Changed(object sender, EventArgs e) {
|
---|
37 | if(DateTime.Now.Subtract(lastUpdate).TotalSeconds < 3) return;
|
---|
38 | lastUpdate = DateTime.Now;
|
---|
39 | InitChart();
|
---|
40 | }
|
---|
41 |
|
---|
42 | private void InitChart() {
|
---|
43 | dataChart.Chart = new BubbleChart(0, 0, 100, 100);
|
---|
44 | foreach(string dim in results.VariableNames) {
|
---|
45 | dataChart.Chart.AddDimension(dim);
|
---|
46 | IList<double> xs = results.GetValues(dim);
|
---|
47 | for(int i = 0; i < xs.Count; i++) {
|
---|
48 | double x = xs[i];
|
---|
49 | if(double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN;
|
---|
50 | if(!double.IsNaN(x)) {
|
---|
51 | dataChart.Chart.AddDataPoint(dim, x);
|
---|
52 | }
|
---|
53 | }
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | private void yAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
58 | yJitterFactor = 0.0;
|
---|
59 | yTrackBar.Value = 0;
|
---|
60 | UpdateChart();
|
---|
61 | }
|
---|
62 |
|
---|
63 | private void xAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
64 | xJitterFactor = 0.0;
|
---|
65 | xTrackBar.Value = 0;
|
---|
66 | UpdateChart();
|
---|
67 | }
|
---|
68 |
|
---|
69 | private void UpdateChart() {
|
---|
70 | if(xAxisComboBox.SelectedItem == null || yAxisComboBox.SelectedItem == null) return;
|
---|
71 | if(yAxisComboBox.SelectedItem.Equals(FREQUENCY)) {
|
---|
72 | CreateHistogramChart();
|
---|
73 | } else {
|
---|
74 | dataChart.Chart.ShowXvsY((string)xAxisComboBox.SelectedItem, (string)yAxisComboBox.SelectedItem);
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | private void CreateHistogramChart() {
|
---|
79 | // TASK
|
---|
80 | }
|
---|
81 |
|
---|
82 | private void jitterTrackBar_ValueChanged(object sender, EventArgs e) {
|
---|
83 | if(dataChart.Chart != null) {
|
---|
84 | double xJitterFactor = xTrackBar.Value / 100.0 ;
|
---|
85 | double yJitterFactor = yTrackBar.Value / 100.0 ;
|
---|
86 | dataChart.Chart.SetJitter(xJitterFactor, yJitterFactor);
|
---|
87 | }
|
---|
88 | UpdateChart();
|
---|
89 | }
|
---|
90 |
|
---|
91 | private void sizeComboBox_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
92 | if(dataChart.Chart != null) {
|
---|
93 | dataChart.Chart.SetBubbleSizeDimension((string)sizeComboBox.SelectedItem, invertCheckbox.Checked);
|
---|
94 | UpdateChart();
|
---|
95 | }
|
---|
96 | }
|
---|
97 | }
|
---|
98 | }
|
---|