Changeset 10992 for branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingChartContent.cs
- Timestamp:
- 06/11/14 15:06:24 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.