using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using HeuristicLab.Analysis; using HeuristicLab.Analysis.Views; using HeuristicLab.Collections; using HeuristicLab.Core; using HeuristicLab.Core.Views; using HeuristicLab.Data; using HeuristicLab.DataPreprocessing.Implementations; using HeuristicLab.MainForm; namespace HeuristicLab.DataPreprocessing.Views { [View("Multi Scatter Plot View")] [Content(typeof(ScatterPlotContent), true)] public partial class MultiScatterPlotView : ItemView { private IChartLogic logic; private List variables; public MultiScatterPlotView() { InitializeComponent(); } public new ScatterPlotContent Content { get { return (ScatterPlotContent)base.Content; } set { base.Content = value; } } public void InitData() { variables = new List(logic.GetVariableNames()); } protected override void OnContentChanged() { base.OnContentChanged(); if (Content != null) { logic = Content.ChartLogic; InitData(); GenerateMultiLayout(); } } private void GenerateMultiLayout() { tableLayoutPanel.Controls.Clear(); //Clear out the existing row and column styles tableLayoutPanel.ColumnStyles.Clear(); tableLayoutPanel.RowStyles.Clear(); //Set row and column count tableLayoutPanel.ColumnCount = variables.Count+1; tableLayoutPanel.RowCount = variables.Count+1; int headerSize = 50; int maxAutoSizeElements = 6; int fixedElementSize = 200; tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, headerSize)); tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, headerSize)); // set column and row layout for (int x = 0; x < variables.Count; x++) { // auto size if (variables.Count <= maxAutoSizeElements) { tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - headerSize) / variables.Count)); tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, (tableLayoutPanel.Height - headerSize) / variables.Count)); } // fixed size else { tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, fixedElementSize)); tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, fixedElementSize)); } } // set variable header elements for (int i = 1; i < variables.Count +1; i++) { Button b1 = new Button(); b1.Text = variables[i-1]; b1.Dock = DockStyle.Fill; tableLayoutPanel.Controls.Add(b1,0,i); Button b2 = new Button(); b2.Text = variables[i - 1]; b2.Dock = DockStyle.Fill; tableLayoutPanel.Controls.Add(b2, i, 0); } //set scatter plots and histograms for (int x = 1; x < variables.Count + 1; x++) { for (int y = 1; y < variables.Count + 1; y++) { // use historgram if x variable equals y variable if (x == y) { PreprocessingDataTable dataTable = new PreprocessingDataTable(); DataRow dataRow = logic.CreateDataRow(variables[x - 1], DataRowVisualProperties.DataRowChartType.Histogram); dataTable.Rows.Add(dataRow); PreprocessingDataTableView pcv = new PreprocessingDataTableView(); pcv.DoubleClick += tableLayoutElementDoubleClick; pcv.Content = dataTable; tableLayoutPanel.Controls.Add(pcv, y, x); } //scatter plot else { ScatterPlot scatterPlot = logic.CreateScatterPlot(variables[x - 1], variables[y-1]); PreprocessingScatterPlotView pspv = new PreprocessingScatterPlotView(); pspv.DoubleClick += tableLayoutElementDoubleClick; pspv.Content = scatterPlot; pspv.Dock = DockStyle.Fill; tableLayoutPanel.Controls.Add(pspv, y, x); } } } } private void tableLayoutElementDoubleClick(object sender, EventArgs e) { //histogram clicked if(sender.GetType() == typeof(PreprocessingDataTableView)) { PreprocessingDataTableView pcv = (PreprocessingDataTableView)sender; //ScatterPlotContent spc = new ScatterPlotContent( } // scatter plot clicked else if (sender.GetType() == typeof(PreprocessingScatterPlotView)) { PreprocessingScatterPlotView pspv = (PreprocessingScatterPlotView)sender; MainFormManager.MainForm.ShowContent(this.Content, typeof(SingleScatterPlotView)); } } } }