Changeset 10992
- Timestamp:
- 06/11/14 15:06:24 (10 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 2 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs
r10990 r10992 49 49 var statisticsLogic = new StatisticsLogic(data, searchLogic); 50 50 var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic, dataGridLogic); 51 var chartLogic = new ChartLogic(data);52 51 //var correlationMatrixLogic = new ChartLogic(data); 53 52 var filterLogic = new FilterLogic(data); … … 59 58 new StatisticsContent(statisticsLogic), 60 59 61 new LineChartContent( chartLogic),62 new HistogramContent( chartLogic),63 new ScatterPlotContent( Content),60 new LineChartContent(data), 61 new HistogramContent(data), 62 new ScatterPlotContent(data), 64 63 new CorrelationMatrixContent(Content), 65 64 new DataCompletenessChartContent(dataGridLogic, searchLogic), -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs
r10942 r10992 18 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 19 */ 20 #endregion 20 #endregion 21 21 using System; 22 22 using System.Windows.Forms; … … 40 40 base.OnContentChanged(); 41 41 if (Content != null) { 42 logic = Content.ChartLogic;43 42 44 43 classifierComboBox.Items.Clear(); 45 44 classifierComboBox.Items.Add("None"); 46 45 47 foreach (string var in logic.GetVariableNamesForHistogramClassification()) {46 foreach (string var in Content.GetVariableNamesForHistogramClassification()) { 48 47 classifierComboBox.Items.Add(var); 49 48 } … … 66 65 67 66 if (classifierComboBox.SelectedIndex != 0) { 68 Classification = logic.GetVariableValues(classifierComboBox.SelectedItem.ToString()); 67 int columndIndex = Content.PreprocessingData.GetColumnIndex(classifierComboBox.SelectedItem.ToString()); 68 Classification = Content.PreprocessingData.GetValues<double>(columndIndex); 69 69 } else { 70 70 Classification = null; -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs
r10987 r10992 24 24 using System.Windows.Forms; 25 25 using HeuristicLab.Analysis; 26 using HeuristicLab.Analysis.Views;27 26 using HeuristicLab.Collections; 28 using HeuristicLab.Core;29 27 using HeuristicLab.Core.Views; 30 28 using HeuristicLab.Data; … … 45 43 protected DataRowVisualProperties.DataRowChartType chartType; 46 44 protected string chartTitle; 47 protected IChartLogic logic;48 45 49 46 private const string DEFAULT_CHART_TITLE = "Chart"; 50 47 private const int FIXED_CHART_SIZE = 300; 51 private const int MAX_TABLE_ AUTO_SIZE_ROWS = 3;48 private const int MAX_TABLE_ROWS = 3; 52 49 53 50 public IEnumerable<double> Classification { get; set; } … … 70 67 dataTable.SelectedRows.Remove(variableName); 71 68 dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName))); 72 //variable isnt't displayed -> add69 //variable isnt't displayed -> add 73 70 } else { 74 71 DataRow row = GetDataRow(variableName); … … 81 78 82 79 //update selection 83 if (selectedRow != null) 84 { 80 if (selectedRow != null) { 85 81 dataTable.SelectedRows.Add(selectedRow); 86 82 pdt.SelectedRows.Add(selectedRow); 83 } 87 84 } 88 }89 85 } 90 86 … … 106 102 protected override void RegisterContentEvents() { 107 103 base.RegisterContentEvents(); 108 Content. ChartLogic.Changed += PreprocessingData_Changed;109 Content. ChartLogic.SelectionChanged += PreprocessingData_SelctionChanged;104 Content.PreprocessingData.Changed += PreprocessingData_Changed; 105 Content.PreprocessingData.SelectionChanged += PreprocessingData_SelctionChanged; 110 106 111 107 } … … 113 109 protected override void DeregisterContentEvents() { 114 110 base.DeregisterContentEvents(); 115 Content. ChartLogic.Changed -= PreprocessingData_Changed;116 Content. ChartLogic.SelectionChanged -= PreprocessingData_SelctionChanged;111 Content.PreprocessingData.Changed -= PreprocessingData_Changed; 112 Content.PreprocessingData.SelectionChanged -= PreprocessingData_SelctionChanged; 117 113 } 118 114 … … 123 119 124 120 private void InitData() { 125 if (Content.VariableItemList == null) 126 { 127 Content.VariableItemList = logic.CreateVariableItemList(); 121 if (Content.VariableItemList == null) { 122 Content.VariableItemList = Content.CreateVariableItemList(); 128 123 } 129 124 checkedItemList.Content = Content.VariableItemList; 130 125 131 126 //Create data tables and data rows 132 dataRows = logic.CreateAllDataRows(chartType);127 dataRows = Content.CreateAllDataRows(chartType); 133 128 dataTable = new PreprocessingDataTable(chartTitle); 134 129 dataTablePerVariable = new List<PreprocessingDataTable>(); 135 130 136 131 //add data rows to data tables according to checked item list 137 foreach (var checkedItem in Content.VariableItemList.CheckedItems) 138 { 132 foreach (var checkedItem in Content.VariableItemList.CheckedItems) { 139 133 string variableName = Content.VariableItemList[checkedItem.Index].Value; 140 134 PreprocessingDataTable d = new PreprocessingDataTable(variableName); … … 155 149 156 150 //update data table selection 157 selectedDataRows = logic.CreateAllSelectedDataRows(chartType);151 selectedDataRows = Content.CreateAllSelectedDataRows(chartType); 158 152 dataTable.SelectedRows.Clear(); 159 153 dataTable.SelectedRows.AddRange(selectedDataRows); … … 188 182 base.OnContentChanged(); 189 183 if (Content != null) { 190 logic = Content.ChartLogic;191 184 InitData(); 192 185 Content.VariableItemList.CheckedItemsChanged += CheckedItemsChanged; … … 199 192 switch (e.Type) { 200 193 case DataPreprocessingChangedEventType.DeleteColumn: 201 RemoveVariable( logic.GetVariableNameByIndex(e.Column));194 RemoveVariable(Content.PreprocessingData.GetVariableName(e.Column)); 202 195 break; 203 196 case DataPreprocessingChangedEventType.AddColumn: 204 AddVariable( logic.GetVariableNameByIndex(e.Column));197 AddVariable(Content.PreprocessingData.GetVariableName(e.Column)); 205 198 break; 206 199 case DataPreprocessingChangedEventType.ChangeColumn: 207 200 case DataPreprocessingChangedEventType.ChangeItem: 208 UpdateDataForVariable( logic.GetVariableNameByIndex(e.Column));201 UpdateDataForVariable(Content.PreprocessingData.GetVariableName(e.Column)); 209 202 break; 210 203 case DataPreprocessingChangedEventType.DeleteRow: … … 212 205 case DataPreprocessingChangedEventType.Any: 213 206 default: 214 207 //TODO: test with transform 215 208 InitData(); 216 209 GenerateChart(); … … 224 217 225 218 private void UpdateDataForVariable(string variableName) { 226 DataRow newRow = logic.CreateDataRow(variableName, chartType);219 DataRow newRow = Content.CreateDataRow(variableName, chartType); 227 220 dataTable.Rows.Remove(variableName); 228 221 dataTable.Rows.Add(newRow); … … 236 229 // add variable to data table and item list 237 230 private void AddVariable(string name) { 238 DataRow row = logic.CreateDataRow(name, chartType);231 DataRow row = Content.CreateDataRow(name, chartType); 239 232 dataTable.Rows.Add(row); 240 233 PreprocessingDataTable d = new PreprocessingDataTable(name); … … 259 252 260 253 private StringValue FindVariableItemList(string name) { 261 foreach (StringValue stringValue in Content.VariableItemList) 262 { 254 foreach (StringValue stringValue in Content.VariableItemList) { 263 255 if (stringValue.Value == name) 264 256 return stringValue; … … 270 262 271 263 ClearTableLayout(); 272 if (Content.AllInOneMode) 273 { 264 if (Content.AllInOneMode) { 274 265 GenerateSingleChartLayout(); 275 266 } else … … 328 319 int columns = GetNrOfMultiChartColumns(checkedItemsCnt); 329 320 int rows = GetNrOfMultiChartRows(checkedItemsCnt, columns); 330 tableLayoutPanel.VerticalScroll.Enabled = true; 331 321 332 322 tableLayoutPanel.ColumnCount = columns; 333 323 tableLayoutPanel.RowCount = rows; … … 336 326 for (int x = 0; x < columns; x++) { 337 327 338 if (rows <= MAX_TABLE_ AUTO_SIZE_ROWS)328 if (rows <= MAX_TABLE_ROWS) 339 329 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns)); 340 330 else … … 345 335 if (x == 0) { 346 336 // fixed chart size when there are more than 3 tables 347 if (rows > MAX_TABLE_ AUTO_SIZE_ROWS)337 if (rows > MAX_TABLE_ROWS) 348 338 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, FIXED_CHART_SIZE)); 349 339 else … … 354 344 PreprocessingDataTable d = enumerator.Current; 355 345 AddDataTableToTableLayout(d, x, y); 356 346 357 347 } 358 348 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.cs
r10987 r10992 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.ComponentModel;4 3 using System.Drawing; 5 4 using System.Linq; 6 using System.Text;7 5 using System.Windows.Forms; 8 6 using HeuristicLab.Analysis; 9 using HeuristicLab.Analysis.Views;10 using HeuristicLab.Collections;11 7 using HeuristicLab.Common; 12 using HeuristicLab.Core;13 8 using HeuristicLab.Core.Views; 14 using HeuristicLab.Data;15 9 using HeuristicLab.DataPreprocessing.Implementations; 16 10 using HeuristicLab.MainForm; … … 47 41 private void addHeaderToTableLayoutPanels() { 48 42 49 List<string> variables = Content. GetVariableNames().ToList();43 List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList(); 50 44 51 45 for (int i = 1; i < variables.Count + 1; i++) { … … 66 60 } 67 61 68 private void GenerateMultiLayout() 69 { 70 List<string> variables = Content.GetVariableNames().ToList(); 62 private void GenerateMultiLayout() { 63 List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList(); 71 64 72 65 tableLayoutPanel.Controls.Clear(); … … 76 69 77 70 //Set row and column count 78 tableLayoutPanel.ColumnCount = variables.Count +1;79 tableLayoutPanel.RowCount = variables.Count +1;71 tableLayoutPanel.ColumnCount = variables.Count + 1; 72 tableLayoutPanel.RowCount = variables.Count + 1; 80 73 81 74 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, HEADER_WIDTH)); 82 75 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, HEADER_HEIGHT)); 83 76 // set column and row layout 84 for (int x = 0; x < variables.Count; x++) 85 { 77 for (int x = 0; x < variables.Count; x++) { 86 78 // auto size 87 79 if (variables.Count <= MAX_AUTO_SIZE_ELEMENTS) { 88 80 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - HEADER_WIDTH) / variables.Count)); 89 81 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, (tableLayoutPanel.Height - HEADER_HEIGHT) / variables.Count)); 90 } 91 // fixed size82 } 83 // fixed size 92 84 else { 93 85 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, FIXED_CHART_WIDTH)); … … 98 90 addHeaderToTableLayoutPanels(); 99 91 addChartsToTableLayoutPanel(); 100 92 101 93 } 102 94 103 95 private void addChartsToTableLayoutPanel() { 104 96 105 List<string> variables = Content. GetVariableNames().ToList();97 List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList(); 106 98 107 99 //set scatter plots and histograms … … 119 111 tableLayoutPanel.Controls.Add(pcv, y, x); 120 112 } 121 //scatter plot113 //scatter plot 122 114 else { 123 115 ScatterPlot scatterPlot = Content.CreateScatterPlot(variables[x - 1], variables[y - 1]); … … 147 139 // only one data row should be in scatter plot 148 140 if (scatterPlot.Rows.Count == 1) { 149 string[] variables = scatterPlot.Rows.ElementAt(0).Name.Split(new string[] {" - "},StringSplitOptions.None); // extract variable names from string141 string[] variables = scatterPlot.Rows.ElementAt(0).Name.Split(new string[] { " - " }, StringSplitOptions.None); // extract variable names from string 150 142 scatterContent.SelectedXVariable = variables[0]; 151 143 scatterContent.SelectedYVariable = variables[1]; … … 161 153 162 154 // set only variable name checked 163 foreach(var checkedItem in histoContent.VariableItemList) 164 { 165 if(checkedItem.Value == variableName) 166 histoContent.VariableItemList.SetItemCheckedState(checkedItem,true); 155 foreach (var checkedItem in histoContent.VariableItemList) { 156 if (checkedItem.Value == variableName) 157 histoContent.VariableItemList.SetItemCheckedState(checkedItem, true); 167 158 else 168 histoContent.VariableItemList.SetItemCheckedState(checkedItem, false);169 159 histoContent.VariableItemList.SetItemCheckedState(checkedItem, false); 160 170 161 } 171 162 } … … 174 165 //open histogram in new tab with new content when double clicked 175 166 private void HistogramDoubleClick(object sender, EventArgs e) { 176 //PreprocessingDataTableView pcv = (PreprocessingDataTableView)sender;177 //HistogramContent histoContent = new HistogramContent(Content,); // create new content178 //histoContent.VariableItemList = logic.CreateVariableItemList();179 //PreprocessingDataTable dataTable = pcv.Content;180 //setVariableItemListFromDataTable(histoContent, dataTable);167 PreprocessingDataTableView pcv = (PreprocessingDataTableView)sender; 168 HistogramContent histoContent = new HistogramContent(Content.PreprocessingData); // create new content 169 histoContent.VariableItemList = Content.CreateVariableItemList(); 170 PreprocessingDataTable dataTable = pcv.Content; 171 setVariableItemListFromDataTable(histoContent, dataTable); 181 172 182 //MainFormManager.MainForm.ShowContent(histoContent, typeof(HistogramView)); // open in new tab173 MainFormManager.MainForm.ShowContent(histoContent, typeof(HistogramView)); // open in new tab 183 174 } 184 175 185 176 186 177 } 187 178 188 179 189 180 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.cs
r10987 r10992 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.ComponentModel;4 using System.Drawing;5 using System.Data;6 3 using System.Linq; 7 using System.Text;8 4 using System.Windows.Forms; 9 5 using HeuristicLab.Analysis; 10 using HeuristicLab.Analysis.Views;11 using HeuristicLab.Collections;12 using HeuristicLab.Core;13 6 using HeuristicLab.Core.Views; 14 using HeuristicLab.Data;15 using HeuristicLab.DataPreprocessing.Implementations;16 7 using HeuristicLab.MainForm; 17 8 … … 33 24 public void InitData() { 34 25 35 IEnumerable<string> variables = Content. GetVariableNames();26 IEnumerable<string> variables = Content.PreprocessingData.GetDoubleVariableNames(); 36 27 37 28 // add variables to combo boxes … … 80 71 } 81 72 82 73 83 74 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj
r10962 r10992 94 94 <Compile Include="Implementations\HistogramContent.cs" /> 95 95 <Compile Include="Implementations\LineChartContent.cs" /> 96 <Compile Include="Implementations\ChartLogic.cs" />97 96 <Compile Include="Implementations\StatisticsContent.cs" /> 98 97 <Compile Include="Implementations\TransformationContent.cs" /> 99 98 <Compile Include="Interfaces\IFilterLogic.cs" /> 100 <Compile Include="Interfaces\IChartLogic.cs" />101 99 <Compile Include="Interfaces\IManipulationLogic.cs" /> 102 100 <Compile Include="Interfaces\ITransformationLogic.cs" /> -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/FilteredPreprocessingData.cs
r10978 r10992 13 13 private ITransactionalPreprocessingData filteredData; 14 14 15 15 public IDictionary<int, IList<int>> Selection { 16 16 get { return originalData.Selection; } 17 17 set { originalData.Selection = value; } … … 228 228 229 229 #endregion 230 231 #region IPreprocessingData Members 232 233 234 public IEnumerable<string> GetDoubleVariableNames() { 235 return originalData.GetDoubleVariableNames(); 236 } 237 238 #endregion 230 239 } 231 240 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/HistogramContent.cs
r10914 r10992 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using System.Drawing; 24 using System.Linq; 23 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Core; 27 using HeuristicLab.DataPreprocessing.Interfaces; 25 28 26 29 namespace HeuristicLab.DataPreprocessing { … … 28 31 public class HistogramContent : PreprocessingChartContent { 29 32 33 public static new Image StaticItemImage { 34 get { return HeuristicLab.Common.Resources.VSImageLibrary.Statistics; } 35 } 36 private const int MAX_DISTINCT_VALUES_FOR_CLASSIFCATION = 20; 37 30 38 private int classifierVariableIndex = 0; 31 32 public HistogramContent(IChartLogic chartlogic)33 : base(chartlogic) {34 AllInOneMode = false;35 }36 37 public HistogramContent(HistogramContent content, Cloner cloner)38 : base(content, cloner) {39 }40 39 41 40 public int ClassifierVariableIndex { … … 45 44 46 45 47 public static new Image StaticItemImage { 48 get { return HeuristicLab.Common.Resources.VSImageLibrary.Statistics; } 46 public HistogramContent(IFilteredPreprocessingData preprocessingData) 47 : base(preprocessingData) { 48 AllInOneMode = false; 49 49 } 50 50 51 public HistogramContent(HistogramContent content, Cloner cloner) 52 : base(content, cloner) { 53 } 51 54 public override IDeepCloneable Clone(Cloner cloner) { 52 55 return new HistogramContent(this, cloner); 53 56 } 57 58 public IEnumerable<string> GetVariableNamesForHistogramClassification() { 59 List<string> doubleVariableNames = new List<string>(); 60 61 //only return variable names from type double 62 for (int i = 0; i < PreprocessingData.Columns; ++i) { 63 if (PreprocessingData.IsType<double>(i)) { 64 double distinctValueCount = PreprocessingData.GetValues<double>(i).GroupBy(x => x).Count(); 65 bool distinctValuesOk = distinctValueCount <= MAX_DISTINCT_VALUES_FOR_CLASSIFCATION; 66 if (distinctValuesOk) 67 doubleVariableNames.Add(PreprocessingData.GetVariableName(i)); 68 } 69 } 70 return doubleVariableNames; 71 } 72 54 73 } 55 74 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/LineChartContent.cs
r10771 r10992 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.DataPreprocessing.Interfaces; 25 26 26 27 namespace HeuristicLab.DataPreprocessing { … … 29 30 public class LineChartContent : PreprocessingChartContent { 30 31 31 public LineChartContent(IChartLogic chartlogic) 32 : base(chartlogic) { 32 public static new Image StaticItemImage { 33 get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; } 34 } 35 36 public LineChartContent(IFilteredPreprocessingData preprocessingData) 37 : base(preprocessingData) { 33 38 } 34 39 35 40 public LineChartContent(LineChartContent content, Cloner cloner) 36 41 : base(content, cloner) { 37 38 42 } 39 40 public static new Image StaticItemImage {41 get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; }42 }43 44 43 public override IDeepCloneable Clone(Cloner cloner) { 45 44 return new LineChartContent(this, cloner); 46 45 } 47 48 46 } 49 47 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingChartContent.cs
r10967 r10992 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using System.Drawing; 25 using HeuristicLab.Analysis; 23 26 using HeuristicLab.Common; 24 27 using HeuristicLab.Core; 25 28 using HeuristicLab.Data; 26 using System; 27 using System.Collections.Generic; 29 using HeuristicLab.DataPreprocessing.Interfaces; 28 30 29 31 namespace HeuristicLab.DataPreprocessing { 30 32 [Item("PreprocessingChart", "Represents a preprocessing chart.")] 31 33 public class PreprocessingChartContent : Item, IViewChartShortcut { 34 public static new Image StaticItemImage { 35 get { return HeuristicLab.Common.Resources.VSImageLibrary.PieChart; } 36 } 32 37 33 38 private bool allInOneMode = true; 39 public bool AllInOneMode { 40 get { return this.allInOneMode; } 41 set { this.allInOneMode = value; } 42 } 34 43 35 44 private ICheckedItemList<StringValue> variableItemList = null; 45 public ICheckedItemList<StringValue> VariableItemList { 46 get { return this.variableItemList; } 47 set { this.variableItemList = value; } 48 } 36 49 50 public IFilteredPreprocessingData PreprocessingData { get; private set; } 37 51 38 private readonly IChartLogic chartLogic; 39 40 41 public PreprocessingChartContent(IChartLogic chartLogic) { 42 this.chartLogic = chartLogic; 52 public PreprocessingChartContent(IFilteredPreprocessingData preprocessingData) { 53 PreprocessingData = preprocessingData; 43 54 } 44 55 45 56 public PreprocessingChartContent(PreprocessingChartContent content, Cloner cloner) 46 57 : base(content, cloner) { 47 48 this.chartLogic = content.chartLogic;49 58 this.allInOneMode = content.allInOneMode; 59 this.PreprocessingData = cloner.Clone<IFilteredPreprocessingData>(PreprocessingData); 60 this.variableItemList = cloner.Clone<ICheckedItemList<StringValue>>(variableItemList); 50 61 } 51 52 public IChartLogic ChartLogic {53 get {54 return chartLogic;55 }56 }57 58 public static new Image StaticItemImage {59 get { return HeuristicLab.Common.Resources.VSImageLibrary.PieChart; }60 }61 62 62 public override IDeepCloneable Clone(Cloner cloner) { 63 63 return new PreprocessingChartContent(this, cloner); 64 64 } 65 65 66 public event DataPreprocessingChangedEventHandler Changed { 67 add { chartLogic.Changed += value; } 68 remove { chartLogic.Changed -= value; } 66 67 public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) { 68 IList<double> values = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableName)); 69 DataRow row = new DataRow(variableName, "", values); 70 row.VisualProperties.ChartType = chartType; 71 return row; 69 72 } 70 73 71 public bool AllInOneMode 72 { 73 get { return this.allInOneMode; } 74 set { this.allInOneMode = value; } 74 public List<DataRow> CreateAllDataRows(DataRowVisualProperties.DataRowChartType chartType) { 75 List<DataRow> dataRows = new List<DataRow>(); 76 foreach (var name in PreprocessingData.GetDoubleVariableNames()) 77 dataRows.Add(CreateDataRow(name, chartType)); 78 return dataRows; 75 79 } 76 80 77 public ICheckedItemList<StringValue> VariableItemList 78 { 79 get { return this.variableItemList; } 80 set { this.variableItemList = value; } 81 public DataRow CreateSelectedDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) { 82 83 IDictionary<int, IList<int>> selection = PreprocessingData.Selection; 84 int variableIndex = PreprocessingData.GetColumnIndex(variableName); 85 86 if (selection.Keys.Contains(variableIndex)) { 87 List<int> selectedIndices = new List<int>(selection[variableIndex]); 88 //need selection with more than 1 value 89 if (selectedIndices.Count < 2) 90 return null; 91 92 selectedIndices.Sort(); 93 int start = selectedIndices[0]; 94 int end = selectedIndices[selectedIndices.Count - 1]; 95 96 DataRow rowSelect = CreateDataRowRange(variableName, start, end, chartType); 97 return rowSelect; 98 } else 99 return null; 81 100 } 101 102 public DataRow CreateDataRowRange(string variableName, int start, int end, DataRowVisualProperties.DataRowChartType chartType) { 103 IList<double> values = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableName)); 104 IList<double> valuesRange = new List<double>(); 105 for (int i = 0; i < values.Count; i++) { 106 if (i >= start && i <= end) 107 valuesRange.Add(values[i]); 108 else 109 valuesRange.Add(Double.NaN); 110 } 111 112 DataRow row = new DataRow(variableName, "", valuesRange); 113 row.VisualProperties.ChartType = chartType; 114 return row; 115 } 116 117 public List<DataRow> CreateAllSelectedDataRows(DataRowVisualProperties.DataRowChartType chartType) { 118 List<DataRow> dataRows = new List<DataRow>(); 119 foreach (var name in PreprocessingData.GetDoubleVariableNames()) { 120 DataRow row = CreateSelectedDataRow(name, chartType); 121 if (row != null) 122 dataRows.Add(row); 123 } 124 return dataRows; 125 } 126 127 128 public ICheckedItemList<StringValue> CreateVariableItemList() { 129 ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>(); 130 foreach (string name in PreprocessingData.GetDoubleVariableNames()) { 131 itemList.Add(new StringValue(name), true); 132 } 133 return new ReadOnlyCheckedItemList<StringValue>(itemList); 134 } 135 136 public event DataPreprocessingChangedEventHandler Changed { 137 add { PreprocessingData.Changed += value; } 138 remove { PreprocessingData.Changed -= value; } 139 } 140 82 141 } 83 142 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingData.cs
r10991 r10992 55 55 } 56 56 57 public IEnumerable<string> GetDoubleVariableNames() { 58 var doubleVariableNames = new List<string>(); 59 for (int i = 0; i < Columns; ++i) { 60 if (IsType<double>(i)) { 61 doubleVariableNames.Add(variableNames[i]); 62 } 63 } 64 return doubleVariableNames; 65 } 66 57 67 public int Columns { 58 68 get { return variableNames.Count; } … … 67 77 get { return selection; } 68 78 set { 69 70 71 72 }79 selection = value; 80 OnSelectionChanged(); 81 } 82 } 73 83 74 84 protected PreprocessingData(PreprocessingData original, Cloner cloner) … … 161 171 162 172 public event DataPreprocessingChangedEventHandler Changed; 163 protected virtual void OnChanged(DataPreprocessingChangedEventType type, int column, int row) 164 { 173 protected virtual void OnChanged(DataPreprocessingChangedEventType type, int column, int row) { 165 174 var listeners = Changed; 166 175 if (listeners != null) listeners(this, new DataPreprocessingChangedEventArgs(type, column, row)); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/ScatterPlotContent.cs
r10987 r10992 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.DataPreprocessing.Interfaces; 27 28 28 29 namespace HeuristicLab.DataPreprocessing { 29 30 30 31 [Item("ScatterPlot", "Represents a scatter plot.")] 31 public class ScatterPlotContent : Item, IViewChartShortcut {32 public class ScatterPlotContent : PreprocessingChartContent { 32 33 public static new Image StaticItemImage { 33 34 get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; } … … 37 38 public string SelectedYVariable { get; set; } 38 39 39 public IPreprocessingContext Context { 40 get; 41 private set; 42 } 43 public ITransactionalPreprocessingData PreprocessingData { 44 get { return Context.Data; } 45 } 46 47 public ScatterPlotContent(IPreprocessingContext context) 48 : base() { 49 this.Context = context; 40 public ScatterPlotContent(IFilteredPreprocessingData preprocessingData) 41 : base(preprocessingData) { 50 42 } 51 43 52 44 public ScatterPlotContent(ScatterPlotContent content, Cloner cloner) 53 45 : base(content, cloner) { 54 this.Context = content.Context;55 46 this.SelectedXVariable = content.SelectedXVariable; 56 47 this.SelectedYVariable = content.SelectedYVariable; … … 60 51 } 61 52 62 public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {63 int columnIndex = PreprocessingData.GetColumnIndex(variableName);64 IList<double> values = PreprocessingData.GetValues<double>(columnIndex);65 DataRow row = new DataRow(variableName, "", values);66 row.VisualProperties.ChartType = chartType;67 return row;68 }69 70 public IEnumerable<string> GetVariableNames() {71 List<string> doubleVariableNames = new List<string>();72 73 //only return variable names from type double74 foreach (string variableName in PreprocessingData.VariableNames) {75 if (PreprocessingData.IsType<double>(PreprocessingData.GetColumnIndex(variableName)))76 doubleVariableNames.Add(variableName);77 }78 79 return doubleVariableNames;80 }81 82 53 public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY) { 83 54 ScatterPlot scatterPlot = new ScatterPlot(); 84 55 85 int xColumnIndex = PreprocessingData.GetColumnIndex(variableNameX); 86 int yColumnIndex = PreprocessingData.GetColumnIndex(variableNameY); 87 88 IList<double> xValues = PreprocessingData.GetValues<double>(xColumnIndex); 89 IList<double> yValues = PreprocessingData.GetValues<double>(yColumnIndex); 56 IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX)); 57 IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY)); 90 58 91 59 List<Point2D<double>> points = new List<Point2D<double>>(); … … 100 68 return scatterPlot; 101 69 } 102 103 70 } 104 71 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Interfaces/IPreprocessingData.cs
r10978 r10992 55 55 56 56 IEnumerable<string> VariableNames { get; } 57 IEnumerable<string> GetDoubleVariableNames(); 57 58 string GetVariableName(int columnIndex); 58 59 int GetColumnIndex(string variableName);
Note: See TracChangeset
for help on using the changeset viewer.