- Timestamp:
- 06/04/14 15:32:33 (10 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/MultiScatterPlotView.cs
r10915 r10952 18 18 19 19 [View("Multi Scatter Plot View")] 20 [Content(typeof(ScatterPlotContent), true)]20 [Content(typeof(ScatterPlotContent), false)] 21 21 public partial class MultiScatterPlotView : ItemView { 22 23 private const int HEADER_WIDTH = 50; 24 private const int HEADER_HEIGHT = 50; 25 private const int MAX_AUTO_SIZE_ELEMENTS = 6; 26 private const int FIXED_CHART_WIDTH = 250; 27 private const int FIXED_CHART_HEIGHT = 150; 22 28 23 29 private IChartLogic logic; … … 34 40 35 41 public void InitData() { 36 37 42 variables = new List<string>(logic.GetVariableNames()); 38 39 43 } 40 44 … … 45 49 InitData(); 46 50 GenerateMultiLayout(); 51 } 52 } 53 54 //Add header elements to the table layout panel 55 private void addHeaderToTableLayoutPanels() { 56 57 for (int i = 1; i < variables.Count + 1; i++) { 58 // Use buttons for header elements 59 Button xButton = new Button(); 60 xButton.Enabled = false; 61 xButton.BackColor = Color.Gainsboro; 62 xButton.Text = variables[i - 1]; 63 xButton.Dock = DockStyle.Fill; 64 tableLayoutPanel.Controls.Add(xButton, 0, i); 65 Button yButton = new Button(); 66 yButton.Enabled = false; 67 yButton.BackColor = Color.Gainsboro; 68 yButton.Text = variables[i - 1]; 69 yButton.Dock = DockStyle.Fill; 70 tableLayoutPanel.Controls.Add(yButton, i, 0); 47 71 } 48 72 } … … 59 83 tableLayoutPanel.RowCount = variables.Count+1; 60 84 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)); 85 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, HEADER_WIDTH)); 86 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, HEADER_HEIGHT)); 67 87 // set column and row layout 68 88 for (int x = 0; x < variables.Count; x++) 69 89 { 70 90 // 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));91 if (variables.Count <= MAX_AUTO_SIZE_ELEMENTS) { 92 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - HEADER_WIDTH) / variables.Count)); 93 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, (tableLayoutPanel.Height - HEADER_HEIGHT) / variables.Count)); 74 94 } 75 95 // fixed size 76 96 else { 77 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, fixedElementSize));78 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, fixedElementSize));97 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, FIXED_CHART_WIDTH)); 98 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, FIXED_CHART_HEIGHT)); 79 99 } 80 100 } 81 101 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 } 102 addHeaderToTableLayoutPanels(); 103 addChartsToTableLayoutPanel(); 104 105 } 94 106 107 private void addChartsToTableLayoutPanel() { 95 108 //set scatter plots and histograms 96 for (int x = 1; x < variables.Count + 1; x++) 97 { 109 for (int x = 1; x < variables.Count + 1; x++) { 98 110 99 for (int y = 1; y < variables.Count + 1; y++) 100 { 101 // use historgram if x variable equals y variable 111 for (int y = 1; y < variables.Count + 1; y++) { 112 // use historgram if x and y variable are equal 102 113 if (x == y) { 103 114 PreprocessingDataTable dataTable = new PreprocessingDataTable(); … … 105 116 dataTable.Rows.Add(dataRow); 106 117 PreprocessingDataTableView pcv = new PreprocessingDataTableView(); 107 pcv. DoubleClick += tableLayoutElementDoubleClick;118 pcv.ChartDoubleClick += HistogramDoubleClick; 108 119 pcv.Content = dataTable; 109 120 tableLayoutPanel.Controls.Add(pcv, y, x); 110 121 } 111 122 //scatter plot 112 else { 113 ScatterPlot scatterPlot = logic.CreateScatterPlot(variables[x - 1], variables[y -1]);123 else { 124 ScatterPlot scatterPlot = logic.CreateScatterPlot(variables[x - 1], variables[y - 1]); 114 125 PreprocessingScatterPlotView pspv = new PreprocessingScatterPlotView(); 115 pspv. DoubleClick += tableLayoutElementDoubleClick;126 pspv.ChartDoubleClick += ScatterPlotDoubleClick; 116 127 pspv.Content = scatterPlot; 117 128 pspv.Dock = DockStyle.Fill; 118 tableLayoutPanel.Controls.Add(pspv, y, x);129 tableLayoutPanel.Controls.Add(pspv, x, y); 119 130 } 120 131 } … … 122 133 } 123 134 124 private void tableLayoutElementDoubleClick(object sender, EventArgs e) { 135 //Open scatter plot in new tab with new content when double clicked 136 private void ScatterPlotDoubleClick(object sender, EventArgs e) { 137 PreprocessingScatterPlotView pspv = (PreprocessingScatterPlotView)sender; 138 ScatterPlotContent scatterContent = new ScatterPlotContent(logic); // create new content 139 ScatterPlot scatterPlot = pspv.Content; 140 setVariablesInContentFromScatterPlot(scatterContent, scatterPlot); 125 141 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 } 142 MainFormManager.MainForm.ShowContent(scatterContent, typeof(SingleScatterPlotView)); // open in new tab 143 } 138 144 139 145 //Extract variable names from scatter plot and set them in content 146 private void setVariablesInContentFromScatterPlot(ScatterPlotContent scatterContent, ScatterPlot scatterPlot) { 147 148 // only one data row should be in scatter plot 149 if (scatterPlot.Rows.Count == 1) { 150 // TODO -> find better way to get variable names 151 string[] variables = scatterPlot.Rows.ElementAt(0).Name.Split(new string[]{" - "},StringSplitOptions.None); // extract variable names from string 152 scatterContent.SelectedXVariable = variables[0]; 153 scatterContent.SelectedYVariable = variables[1]; 154 } 155 } 156 157 //Set variable item list from with variable from data table 158 private void setVariableItemListFromDataTable(HistogramContent histoContent, PreprocessingDataTable dataTable) { 159 160 // only one data row should be in data table 161 if (dataTable.Rows.Count == 1) { 162 string variableName = dataTable.Rows.ElementAt(0).Name; 163 164 // set only variable name checked 165 foreach(var checkedItem in histoContent.VariableItemList) 166 { 167 if(checkedItem.Value == variableName) 168 histoContent.VariableItemList.SetItemCheckedState(checkedItem,true); 169 else 170 histoContent.VariableItemList.SetItemCheckedState(checkedItem,false); 171 172 } 173 } 174 } 175 176 //open histogram in new tab with new content when double clicked 177 private void HistogramDoubleClick(object sender, EventArgs e) { 178 PreprocessingDataTableView pcv = (PreprocessingDataTableView)sender; 179 HistogramContent histoContent = new HistogramContent(logic); // create new content 180 histoContent.VariableItemList = logic.CreateVariableItemList(); 181 PreprocessingDataTable dataTable = pcv.Content; 182 setVariableItemListFromDataTable(histoContent, dataTable); 183 184 MainFormManager.MainForm.ShowContent(histoContent, typeof(HistogramView)); // open in new tab 140 185 } 141 186 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs
r10908 r10952 373 373 374 374 375 376 375 } 377 376 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingDataTableView.Designer.cs
r10877 r10952 73 73 legend1.Name = "Default"; 74 74 this.chart.Legends.Add(legend1); 75 this.chart.Location = new System.Drawing.Point(0, 3);75 this.chart.Location = new System.Drawing.Point(0, 0); 76 76 this.chart.Name = "chart"; 77 77 series1.ChartArea = "Default"; … … 79 79 series1.Name = "Default"; 80 80 this.chart.Series.Add(series1); 81 this.chart.Size = new System.Drawing.Size(359, 27 1);81 this.chart.Size = new System.Drawing.Size(359, 274); 82 82 this.chart.TabIndex = 3; 83 83 this.chart.Text = "chart"; … … 88 88 this.chart.Titles.Add(title1); 89 89 this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend); 90 this.chart.DoubleClick += new System.EventHandler(this.chart_DoubleClick); 90 91 this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown); 91 92 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingDataTableView.cs
r10914 r10952 39 39 protected List<Series> invisibleSeries; 40 40 protected Dictionary<IObservableList<double>, DataRow> valuesRowsTable; 41 private event EventHandler chartDoubleClick; 41 42 42 43 public new PreprocessingDataTable Content { … … 759 760 } 760 761 762 public event EventHandler ChartDoubleClick { 763 add { chartDoubleClick += value; } 764 remove { chartDoubleClick -= value; } 765 } 766 761 767 #region Helpers 762 768 public static IEnumerable<double> DoubleRange(double min, double max, double step) { … … 816 822 } 817 823 #endregion 824 825 //bubble double click event with data table view as sender 826 private void chart_DoubleClick(object sender, EventArgs e) { 827 if (chartDoubleClick != null) 828 chartDoubleClick(this, e); 829 } 818 830 } 819 831 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingScatterPlotView.Designer.cs
r10915 r10952 72 72 legend1.Name = "Default"; 73 73 this.chart.Legends.Add(legend1); 74 this.chart.Location = new System.Drawing.Point(0, 3);74 this.chart.Location = new System.Drawing.Point(0, 0); 75 75 this.chart.Name = "chart"; 76 76 series1.ChartArea = "Default"; … … 78 78 series1.Name = "Default"; 79 79 this.chart.Series.Add(series1); 80 this.chart.Size = new System.Drawing.Size(359, 27 1);80 this.chart.Size = new System.Drawing.Size(359, 274); 81 81 this.chart.TabIndex = 3; 82 82 this.chart.Text = "chart"; … … 87 87 this.chart.Titles.Add(title1); 88 88 this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend); 89 this.chart.DoubleClick += new System.EventHandler(this.chart_DoubleClick); 89 90 this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown); 90 91 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingScatterPlotView.cs
r10915 r10952 39 39 protected List<Series> invisibleSeries; 40 40 protected Dictionary<IObservableList<Point2D<double>>, ScatterPlotDataRow> pointsRowsTable; 41 private event EventHandler chartDoubleClick; 41 42 42 43 public new ScatterPlot Content { … … 220 221 double yZoomInterval = Math.Pow(10, digits); 221 222 this.chart.ChartAreas[0].CursorY.Interval = yZoomInterval; 223 } 224 225 226 public event EventHandler ChartDoubleClick { 227 add { chartDoubleClick += value; } 228 remove { chartDoubleClick -= value; } 222 229 } 223 230 … … 450 457 } 451 458 #endregion 459 460 //bubble double click event with scatter plot view as sender 461 private void chart_DoubleClick(object sender, EventArgs e) { 462 if (chartDoubleClick != null) 463 chartDoubleClick(this, e); 464 } 452 465 } 453 466 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/SingleScatterPlotView.cs
r10915 r10952 19 19 20 20 [View("Single Scatter Plot View")] 21 [Content(typeof(ScatterPlotContent), false)]21 [Content(typeof(ScatterPlotContent), true)] 22 22 public partial class SingleScatterPlotView : ItemView { 23 23 … … 42 42 comboBoxYVariable.Items.AddRange(variables.ToArray()); 43 43 44 if (variables.Count() >= 2) { 45 comboBoxXVariable.SelectedIndex = 0; 46 comboBoxYVariable.SelectedIndex = 1; 47 UpdateScatterPlot(); 48 44 // use x and y variable from content 45 if (Content.SelectedXVariable != null && Content.SelectedYVariable != null) { 46 comboBoxXVariable.SelectedItem = Content.SelectedXVariable; 47 comboBoxYVariable.SelectedItem = Content.SelectedYVariable; 48 } else { 49 if (variables.Count() >= 2) { 50 comboBoxXVariable.SelectedIndex = 0; 51 comboBoxYVariable.SelectedIndex = 1; 52 UpdateScatterPlot(); 53 54 } 49 55 } 50 56 … … 67 73 ScatterPlot scatterPlot = logic.CreateScatterPlot((string)comboBoxXVariable.SelectedItem, (string)comboBoxYVariable.SelectedItem); 68 74 scatterPlotView.Content = scatterPlot; 75 76 //save selected x and y variable in content 77 this.Content.SelectedXVariable = (string)comboBoxXVariable.SelectedItem; 78 this.Content.SelectedYVariable = (string)comboBoxYVariable.SelectedItem; 69 79 } 70 80 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/ViewShortcutListView.cs
r10904 r10952 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Core.Views; … … 33 34 itemsGroupBox.Text = "View Shortcuts"; 34 35 } 36 37 protected override void itemsListView_DoubleClick(object sender, EventArgs e) { 38 if (itemsListView.SelectedItems.Count == 1) { 39 IViewShortcut item = itemsListView.SelectedItems[0].Tag as IViewShortcut; 40 if (item != null) { 41 42 if (item is IViewChartShortcut) 43 item = (IViewChartShortcut)item.Clone(); 44 45 IContentView view = MainFormManager.MainForm.ShowContent(item); 46 if (view != null) { 47 view.ReadOnly = ReadOnly; 48 view.Locked = Locked; 49 } 50 } 51 } 52 } 35 53 } 36 54 }
Note: See TracChangeset
for help on using the changeset viewer.