1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Linq;
|
---|
6 | using System.Text;
|
---|
7 | using System.Windows.Forms;
|
---|
8 | using HeuristicLab.Analysis;
|
---|
9 | using HeuristicLab.Analysis.Views;
|
---|
10 | using HeuristicLab.Collections;
|
---|
11 | using HeuristicLab.Core;
|
---|
12 | using HeuristicLab.Core.Views;
|
---|
13 | using HeuristicLab.Data;
|
---|
14 | using HeuristicLab.DataPreprocessing.Implementations;
|
---|
15 | using HeuristicLab.MainForm;
|
---|
16 |
|
---|
17 | namespace HeuristicLab.DataPreprocessing.Views {
|
---|
18 |
|
---|
19 | [View("Multi Scatter Plot View")]
|
---|
20 | [Content(typeof(ScatterPlotContent), true)]
|
---|
21 | public partial class MultiScatterPlotView : ItemView {
|
---|
22 |
|
---|
23 | private IChartLogic logic;
|
---|
24 | private List<string> variables;
|
---|
25 |
|
---|
26 | public MultiScatterPlotView() {
|
---|
27 | InitializeComponent();
|
---|
28 | }
|
---|
29 |
|
---|
30 | public new ScatterPlotContent Content {
|
---|
31 | get { return (ScatterPlotContent)base.Content; }
|
---|
32 | set { base.Content = value; }
|
---|
33 | }
|
---|
34 |
|
---|
35 | public void InitData() {
|
---|
36 |
|
---|
37 | variables = new List<string>(logic.GetVariableNames());
|
---|
38 |
|
---|
39 | }
|
---|
40 |
|
---|
41 | protected override void OnContentChanged() {
|
---|
42 | base.OnContentChanged();
|
---|
43 | if (Content != null) {
|
---|
44 | logic = Content.ChartLogic;
|
---|
45 | InitData();
|
---|
46 | GenerateMultiLayout();
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | private void GenerateMultiLayout()
|
---|
51 | {
|
---|
52 | tableLayoutPanel.Controls.Clear();
|
---|
53 | //Clear out the existing row and column styles
|
---|
54 | tableLayoutPanel.ColumnStyles.Clear();
|
---|
55 | tableLayoutPanel.RowStyles.Clear();
|
---|
56 |
|
---|
57 | //Set row and column count
|
---|
58 | tableLayoutPanel.ColumnCount = variables.Count+1;
|
---|
59 | tableLayoutPanel.RowCount = variables.Count+1;
|
---|
60 |
|
---|
61 | int headerSize = 50;
|
---|
62 | int maxAutoSizeElements = 6;
|
---|
63 | int fixedElementSize = 200;
|
---|
64 |
|
---|
65 | tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, headerSize));
|
---|
66 | tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, headerSize));
|
---|
67 | // set column and row layout
|
---|
68 | for (int x = 0; x < variables.Count; x++)
|
---|
69 | {
|
---|
70 | // auto size
|
---|
71 | if (variables.Count <= maxAutoSizeElements) {
|
---|
72 | tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - headerSize) / variables.Count));
|
---|
73 | tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, (tableLayoutPanel.Height - headerSize) / variables.Count));
|
---|
74 | }
|
---|
75 | // fixed size
|
---|
76 | else {
|
---|
77 | tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, fixedElementSize));
|
---|
78 | tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, fixedElementSize));
|
---|
79 | }
|
---|
80 | }
|
---|
81 |
|
---|
82 | // set variable header elements
|
---|
83 | for (int i = 1; i < variables.Count +1; i++)
|
---|
84 | {
|
---|
85 | Button b1 = new Button();
|
---|
86 | b1.Text = variables[i-1];
|
---|
87 | b1.Dock = DockStyle.Fill;
|
---|
88 | tableLayoutPanel.Controls.Add(b1,0,i);
|
---|
89 | Button b2 = new Button();
|
---|
90 | b2.Text = variables[i - 1];
|
---|
91 | b2.Dock = DockStyle.Fill;
|
---|
92 | tableLayoutPanel.Controls.Add(b2, i, 0);
|
---|
93 | }
|
---|
94 |
|
---|
95 | //set scatter plots and histograms
|
---|
96 | for (int x = 1; x < variables.Count + 1; x++)
|
---|
97 | {
|
---|
98 |
|
---|
99 | for (int y = 1; y < variables.Count + 1; y++)
|
---|
100 | {
|
---|
101 | // use historgram if x variable equals y variable
|
---|
102 | if (x == y) {
|
---|
103 | PreprocessingDataTable dataTable = new PreprocessingDataTable();
|
---|
104 | DataRow dataRow = logic.CreateDataRow(variables[x - 1], DataRowVisualProperties.DataRowChartType.Histogram);
|
---|
105 | dataTable.Rows.Add(dataRow);
|
---|
106 | PreprocessingDataTableView pcv = new PreprocessingDataTableView();
|
---|
107 | pcv.DoubleClick += tableLayoutElementDoubleClick;
|
---|
108 | pcv.Content = dataTable;
|
---|
109 | tableLayoutPanel.Controls.Add(pcv, y, x);
|
---|
110 | }
|
---|
111 | //scatter plot
|
---|
112 | else {
|
---|
113 | ScatterPlot scatterPlot = logic.CreateScatterPlot(variables[x - 1], variables[y-1]);
|
---|
114 | PreprocessingScatterPlotView pspv = new PreprocessingScatterPlotView();
|
---|
115 | pspv.DoubleClick += tableLayoutElementDoubleClick;
|
---|
116 | pspv.Content = scatterPlot;
|
---|
117 | pspv.Dock = DockStyle.Fill;
|
---|
118 | tableLayoutPanel.Controls.Add(pspv, y, x);
|
---|
119 | }
|
---|
120 | }
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | private void tableLayoutElementDoubleClick(object sender, EventArgs e) {
|
---|
125 |
|
---|
126 | //histogram clicked
|
---|
127 | if(sender.GetType() == typeof(PreprocessingDataTableView))
|
---|
128 | {
|
---|
129 | PreprocessingDataTableView pcv = (PreprocessingDataTableView)sender;
|
---|
130 | //ScatterPlotContent spc = new ScatterPlotContent(
|
---|
131 |
|
---|
132 | }
|
---|
133 | // scatter plot clicked
|
---|
134 | else if (sender.GetType() == typeof(PreprocessingScatterPlotView)) {
|
---|
135 | PreprocessingScatterPlotView pspv = (PreprocessingScatterPlotView)sender;
|
---|
136 | MainFormManager.MainForm.ShowContent(this.Content, typeof(SingleScatterPlotView));
|
---|
137 | }
|
---|
138 |
|
---|
139 |
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | }
|
---|