Changeset 10999
- Timestamp:
- 06/11/14 15:28:12 (10 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs
r10992 r10999 46 46 private const string DEFAULT_CHART_TITLE = "Chart"; 47 47 private const int FIXED_CHART_SIZE = 300; 48 private const int MAX_TABLE_ ROWS = 3;48 private const int MAX_TABLE_AUTO_SIZE_ROWS = 3; 49 49 50 50 public IEnumerable<double> Classification { get; set; } … … 326 326 for (int x = 0; x < columns; x++) { 327 327 328 if (rows <= MAX_TABLE_ ROWS)328 if (rows <= MAX_TABLE_AUTO_SIZE_ROWS) 329 329 tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns)); 330 330 else … … 335 335 if (x == 0) { 336 336 // fixed chart size when there are more than 3 tables 337 if (rows > MAX_TABLE_ ROWS)337 if (rows > MAX_TABLE_AUTO_SIZE_ROWS) 338 338 tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, FIXED_CHART_SIZE)); 339 339 else -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/DataCompletenessChartContent.cs
r10967 r10999 1 using HeuristicLab.Common; 1 using System.Drawing; 2 using HeuristicLab.Common; 2 3 using HeuristicLab.Core; 3 using System;4 using System.Collections.Generic;5 using System.Drawing;6 using System.Linq;7 using System.Text;8 4 9 namespace HeuristicLab.DataPreprocessing 10 { 5 namespace HeuristicLab.DataPreprocessing { 11 6 [Item("DataCompletenessChart", "Represents a datacompleteness chart.")] 12 public class DataCompletenessChartContent : Item, IViewChartShortcut 13 { 14 private readonly DataGridLogic dataGridLogic; 15 private readonly SearchLogic searchLogic; 7 public class DataCompletenessChartContent : Item, IViewChartShortcut { 16 8 17 public DataCompletenessChartContent(DataGridLogic dataGridLogic, SearchLogic searchLogic) 18 { 19 this.dataGridLogic = dataGridLogic; 20 this.searchLogic = searchLogic; 9 public static new Image StaticItemImage { 10 get { return HeuristicLab.Common.Resources.VSImageLibrary.EditBrightnessContrast; } 11 } 12 13 public IDataGridLogic DataGridLogic { get; private set; } 14 public ISearchLogic SearchLogic { get; private set; } 15 16 public DataCompletenessChartContent(DataGridLogic dataGridLogic, SearchLogic searchLogic) { 17 DataGridLogic = dataGridLogic; 18 SearchLogic = searchLogic; 21 19 } 22 20 23 21 public DataCompletenessChartContent(DataCompletenessChartContent content, Cloner cloner) 24 : base(content, cloner) 25 { 26 this.dataGridLogic = content.dataGridLogic; 27 this.searchLogic = content.searchLogic; 22 : base(content, cloner) { 23 DataGridLogic = content.DataGridLogic; 24 SearchLogic = content.SearchLogic; 28 25 } 29 26 30 public IDataGridLogic DataGridLogic 31 { 32 get 33 { 34 return dataGridLogic; 35 } 36 } 37 38 public ISearchLogic SearchLogic 39 { 40 get 41 { 42 return searchLogic; 43 } 44 } 45 46 public static new Image StaticItemImage 47 { 48 get { return HeuristicLab.Common.Resources.VSImageLibrary.EditBrightnessContrast; } 49 } 50 51 public override IDeepCloneable Clone(Cloner cloner) 52 { 27 public override IDeepCloneable Clone(Cloner cloner) { 53 28 return new DataCompletenessChartContent(this, cloner); 54 29 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/DataGridContent.cs
r10977 r10999 31 31 public class DataGridContent : Item, IViewShortcut, IDataGridContent { 32 32 33 public static new Image StaticItemImage { 34 get { return HeuristicLab.Common.Resources.VSImageLibrary.Table; } 35 } 36 33 37 public IManipulationLogic ManipulationLogic { get; private set; } 34 38 public IDataGridLogic DataGridLogic { get; private set; } 35 39 public IFilterLogic FilterLogic { get; private set; } 36 37 public static new Image StaticItemImage {38 get { return HeuristicLab.Common.Resources.VSImageLibrary.Table; }39 }40 40 41 41 public int Rows { … … 98 98 99 99 } 100 101 100 public override IDeepCloneable Clone(Cloner cloner) { 102 101 return new DataGridContent(this, cloner); … … 115 114 remove { DataGridLogic.Changed -= value; } 116 115 } 117 118 116 119 117 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/DataGridLogic.cs
r10978 r10999 29 29 public class DataGridLogic : IDataGridLogic { 30 30 31 private ITransactionalPreprocessingData preprocessingData;31 private ITransactionalPreprocessingData PreprocessingData { get; private set; } 32 32 private IEnumerable<string> rowNames; 33 34 public DataGridLogic(ITransactionalPreprocessingData preprocessingData) {35 this.preprocessingData = preprocessingData;36 createRowNames();37 }38 39 private void createRowNames() {40 rowNames = Enumerable.Range(1, Rows).Select(n => n.ToString());41 }42 33 43 34 public int Rows { 44 35 get { 45 return preprocessingData.Rows;36 return PreprocessingData.Rows; 46 37 } 47 38 } … … 49 40 public int Columns { 50 41 get { 51 return preprocessingData.Columns;42 return PreprocessingData.Columns; 52 43 } 53 44 } … … 55 46 public IEnumerable<string> ColumnNames { 56 47 get { 57 return preprocessingData.VariableNames;48 return PreprocessingData.VariableNames; 58 49 } 59 50 } … … 65 56 } 66 57 58 public DataGridLogic(ITransactionalPreprocessingData preprocessingData) { 59 PreprocessingData = preprocessingData; 60 createRowNames(); 61 } 62 63 private void createRowNames() { 64 rowNames = Enumerable.Range(1, Rows).Select(n => n.ToString()); 65 } 66 67 68 67 69 public bool Validate(string value, out string errorMessage, int columnIndex) { 68 if (columnIndex < 0 || columnIndex > preprocessingData.VariableNames.Count()) {70 if (columnIndex < 0 || columnIndex > PreprocessingData.VariableNames.Count()) { 69 71 throw new ArgumentOutOfRangeException("column index is out of range"); 70 72 } … … 72 74 bool valid = false; 73 75 errorMessage = string.Empty; 74 if ( preprocessingData.IsType<double>(columnIndex)) {76 if (PreprocessingData.IsType<double>(columnIndex)) { 75 77 double val; 76 78 valid = double.TryParse(value, out val); … … 78 80 errorMessage = "Invalid Value (Valid Value Format: \"" + FormatPatterns.GetDoubleFormatPattern() + "\")"; 79 81 } 80 } else if ( preprocessingData.IsType<string>(columnIndex)) {82 } else if (PreprocessingData.IsType<string>(columnIndex)) { 81 83 valid = value != null; 82 84 if (!valid) { 83 85 errorMessage = "Invalid Value (string must not be null)"; 84 86 } 85 } else if ( preprocessingData.IsType<DateTime>(columnIndex)) {87 } else if (PreprocessingData.IsType<DateTime>(columnIndex)) { 86 88 DateTime date; 87 89 valid = DateTime.TryParse(value, out date); … … 97 99 98 100 public string GetValue(int columnIndex, int rowIndex) { 99 return preprocessingData.GetCellAsString(columnIndex, rowIndex);101 return PreprocessingData.GetCellAsString(columnIndex, rowIndex); 100 102 } 101 103 102 104 public bool SetValue(string value, int columnIndex, int rowIndex) { 103 105 bool valid = false; 104 if ( preprocessingData.IsType<double>(columnIndex)) {106 if (PreprocessingData.IsType<double>(columnIndex)) { 105 107 double val; 106 108 valid = double.TryParse(value, out val); 107 109 SetValueIfValid(columnIndex, rowIndex, valid, val); 108 } else if ( preprocessingData.IsType<string>(columnIndex)) {110 } else if (PreprocessingData.IsType<string>(columnIndex)) { 109 111 valid = value != null; 110 112 SetValueIfValid(columnIndex, rowIndex, valid, value); 111 } else if ( preprocessingData.IsType<DateTime>(columnIndex)) {113 } else if (PreprocessingData.IsType<DateTime>(columnIndex)) { 112 114 DateTime date; 113 115 valid = DateTime.TryParse(value, out date); … … 121 123 private void SetValueIfValid<T>(int columnIndex, int rowIndex, bool valid, T value) { 122 124 if (valid) { 123 preprocessingData.SetCell<T>(columnIndex, rowIndex, value);125 PreprocessingData.SetCell<T>(columnIndex, rowIndex, value); 124 126 } 125 127 } 126 128 127 129 public void DeleteRow(List<int> rows) { 128 preprocessingData.InTransaction(() => {130 PreprocessingData.InTransaction(() => { 129 131 foreach (int rowIndex in rows) { 130 preprocessingData.DeleteRow(rowIndex);132 PreprocessingData.DeleteRow(rowIndex); 131 133 } 132 134 }); … … 135 137 136 138 public event DataPreprocessingChangedEventHandler Changed { 137 add { preprocessingData.Changed += value; }138 remove { preprocessingData.Changed -= value; }139 add { PreprocessingData.Changed += value; } 140 remove { PreprocessingData.Changed -= value; } 139 141 } 140 142 141 143 public bool AreAllStringColumns(IEnumerable<int> columnIndices) { 142 return columnIndices.All(x => preprocessingData.IsType<string>(x));144 return columnIndices.All(x => PreprocessingData.IsType<string>(x)); 143 145 } 144 146 145 147 146 148 public void SetSelection(IDictionary<int, IList<int>> selection) { 147 preprocessingData.Selection = selection;149 PreprocessingData.Selection = selection; 148 150 } 149 151 150 152 public IDictionary<int, IList<int>> GetSelection() { 151 return preprocessingData.Selection;153 return PreprocessingData.Selection; 152 154 } 153 155 public void ClearSelection() { 154 preprocessingData.ClearSelection();156 PreprocessingData.ClearSelection(); 155 157 } 156 158 157 159 public event EventHandler SelectionChanged { 158 add { preprocessingData.SelectionChanged += value; }159 remove { preprocessingData.SelectionChanged -= value; }160 add { PreprocessingData.SelectionChanged += value; } 161 remove { PreprocessingData.SelectionChanged -= value; } 160 162 } 161 163 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/Filter/ComparisonFilter.cs
r10947 r10999 31 31 public class ComparisonFilter : ComparisonConstraint, IFilter { 32 32 33 34 35 protected ComparisonFilter(bool deserializing) : base(deserializing) {36 37 }38 39 protected ComparisonFilter(ComparisonFilter original, Cloner cloner)40 : base(original, cloner) {41 constraintColumn = original.constraintColumn;42 }43 public override IDeepCloneable Clone(Cloner cloner) {44 return new ComparisonFilter(this, cloner);45 }46 47 public ComparisonFilter() : base() { }48 public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData)49 : base(constrainedValue, constraintOperation, constraintData) {50 }51 52 public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData, bool active)53 : base(constrainedValue, constraintOperation, constraintData, active) {54 }55 56 57 33 public override string ItemName { 58 34 get { return "ComparisonFilter"; } … … 77 53 } 78 54 55 public ComparisonFilter() : base() { } 56 protected ComparisonFilter(bool deserializing) : base(deserializing) { } 57 58 public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData) 59 : base(constrainedValue, constraintOperation, constraintData) { 60 } 61 62 public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData, bool active) 63 : base(constrainedValue, constraintOperation, constraintData, active) { 64 } 65 66 protected ComparisonFilter(ComparisonFilter original, Cloner cloner) 67 : base(original, cloner) { 68 constraintColumn = original.constraintColumn; 69 } 70 public override IDeepCloneable Clone(Cloner cloner) { 71 return new ComparisonFilter(this, cloner); 72 } 79 73 80 74 private int constraintColumn; … … 92 86 } 93 87 } 94 95 88 96 89 public new bool[] Check() { … … 121 114 } 122 115 123 public event EventHandler ConstraintColumnChanged;124 protected virtual void OnConstraintColumnChanged() {125 EventHandler handler = ConstraintColumnChanged;126 if (handler != null)127 handler(this, EventArgs.Empty);128 }129 130 116 public override string ToString() { 131 117 string s = string.Empty; … … 144 130 return s; 145 131 } 132 133 public event EventHandler ConstraintColumnChanged; 134 protected virtual void OnConstraintColumnChanged() { 135 EventHandler handler = ConstraintColumnChanged; 136 if (handler != null) 137 handler(this, EventArgs.Empty); 138 } 146 139 } 147 140 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/FilterContent.cs
r10964 r10999 29 29 public class FilterContent : Item, IViewShortcut { 30 30 31 private ICheckedItemCollection<IFilter> filters = new CheckedItemCollection<IFilter>();32 33 31 public static new Image StaticItemImage { 34 32 get { return HeuristicLab.Common.Resources.VSImageLibrary.Filter; } 35 33 } 36 34 37 private readonly IFilterLogic filterLogic;35 private ICheckedItemCollection<IFilter> filters = new CheckedItemCollection<IFilter>(); 38 36 39 public bool isAndCombination = true; 40 41 42 public IFilterLogic FilterLogic { 43 get { 44 return filterLogic; 45 } 46 } 37 public IFilterLogic FilterLogic { get; private set; } 47 38 48 39 public ICheckedItemCollection<IFilter> Filters { … … 55 46 } 56 47 48 private bool isAndCombination = true; 57 49 public bool IsAndCombination { 58 50 get { … … 64 56 } 65 57 66 public FilterContent(IFilterLogic theFilterLogic) {67 filterLogic = theFilterLogic;58 public FilterContent(IFilterLogic filterLogic) { 59 FilterLogic = filterLogic; 68 60 } 69 61 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/FilterLogic.cs
r10939 r10999 27 27 namespace HeuristicLab.DataPreprocessing { 28 28 public class FilterLogic : IFilterLogic { 29 private IFilteredPreprocessingData preprocessingData; 29 30 public IFilteredPreprocessingData PreprocessingData { get; private set; } 31 32 public bool IsFiltered { 33 get { 34 return PreprocessingData.IsFiltered; 35 } 36 } 30 37 31 38 public FilterLogic(IFilteredPreprocessingData preprocessingData) { 32 this.preprocessingData = preprocessingData;39 PreprocessingData = preprocessingData; 33 40 } 34 41 … … 37 44 38 45 if (activeFilters.Count == 0) { 39 return CreateBoolArray( preprocessingData.Rows, false);46 return CreateBoolArray(PreprocessingData.Rows, false); 40 47 } 41 48 return GetActiveFilterResult(activeFilters, isAndCombination); … … 43 50 44 51 private bool[] GetActiveFilterResult(IList<IFilter> activeFilters, bool isAndCombination) { 45 bool[] result = CreateBoolArray( preprocessingData.Rows, !isAndCombination);52 bool[] result = CreateBoolArray(PreprocessingData.Rows, !isAndCombination); 46 53 47 54 foreach (IFilter filter in activeFilters) { … … 58 65 if (activeFilters.Count > 0) { 59 66 var result = GetActiveFilterResult(activeFilters, isAndCombination); 60 preprocessingData.SetFilter(result);67 PreprocessingData.SetFilter(result); 61 68 return result; 62 69 } else { 63 return CreateBoolArray( preprocessingData.Rows, false);70 return CreateBoolArray(PreprocessingData.Rows, false); 64 71 } 65 72 } … … 74 81 75 82 public void Apply(IList<IFilter> filters, bool isAndCombination) { 76 preprocessingData.PersistFilter();83 PreprocessingData.PersistFilter(); 77 84 Reset(); 78 85 } 79 86 80 87 public void Reset() { 81 preprocessingData.ResetFilter(); 82 } 83 84 public bool IsFiltered { 85 get { 86 return preprocessingData.IsFiltered; 87 } 88 } 89 90 public IPreprocessingData PreprocessingData { 91 get { return preprocessingData; } 88 PreprocessingData.ResetFilter(); 92 89 } 93 90 94 91 public event EventHandler FilterChanged { 95 add { preprocessingData.FilterChanged += value; }96 remove { preprocessingData.FilterChanged -= value; }92 add { PreprocessingData.FilterChanged += value; } 93 remove { PreprocessingData.FilterChanged -= value; } 97 94 } 98 95 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/FilteredPreprocessingData.cs
r10992 r10999 13 13 private ITransactionalPreprocessingData filteredData; 14 14 15 public IntRange TrainingPartition { 16 get { return originalData.TrainingPartition; } 17 } 18 19 public IntRange TestPartition { 20 get { return originalData.TestPartition; } 21 } 22 23 public IList<ITransformation> Transformations { 24 get { return originalData.Transformations; } 25 } 26 27 public IEnumerable<string> VariableNames { 28 get { return ActiveData.VariableNames; } 29 } 30 15 31 public IDictionary<int, IList<int>> Selection { 16 32 get { return originalData.Selection; } 17 33 set { originalData.Selection = value; } 34 } 35 36 public int Columns { 37 get { return ActiveData.Columns; } 38 } 39 40 public int Rows { 41 get { return ActiveData.Rows; } 42 } 43 44 public ITransactionalPreprocessingData ActiveData { 45 get { return IsFiltered ? filteredData : originalData; } 46 } 47 48 public bool IsUndoAvailable { 49 get { return IsFiltered ? false : originalData.IsUndoAvailable; } 50 } 51 52 public bool IsFiltered { 53 get { return filteredData != null; } 54 } 55 56 57 public FilteredPreprocessingData(ITransactionalPreprocessingData preporcessingData) 58 : base() { 59 originalData = preporcessingData; 60 filteredData = null; 18 61 } 19 62 … … 23 66 filteredData = original.filteredData; 24 67 } 25 26 public FilteredPreprocessingData(ITransactionalPreprocessingData preporcessingData)27 : base() {28 originalData = preporcessingData;29 filteredData = null;30 }31 32 68 public override IDeepCloneable Clone(Cloner cloner) { 33 69 return new FilteredPreprocessingData(this, cloner); … … 91 127 } 92 128 93 public IntRange TrainingPartition {94 get { return originalData.TrainingPartition; }95 }96 97 public IntRange TestPartition {98 get { return originalData.TestPartition; }99 }100 101 public IList<ITransformation> Transformations {102 get { return originalData.Transformations; }103 }104 105 public IEnumerable<string> VariableNames {106 get { return ActiveData.VariableNames; }107 }108 109 129 public string GetVariableName(int columnIndex) { 110 130 return ActiveData.GetVariableName(columnIndex); … … 117 137 public bool IsType<T>(int columnIndex) { 118 138 return originalData.IsType<T>(columnIndex); 119 }120 121 public int Columns {122 get { return ActiveData.Columns; }123 }124 125 public int Rows {126 get { return ActiveData.Rows; }127 139 } 128 140 … … 171 183 } 172 184 173 public ITransactionalPreprocessingData ActiveData { 174 get { return IsFiltered ? filteredData : originalData; } 175 } 176 177 178 public bool IsUndoAvailable { 179 get { return IsFiltered ? false : originalData.IsUndoAvailable; } 180 } 181 182 183 public bool IsFiltered { 184 get { return filteredData != null; } 185 public void Undo() { 186 if (IsFiltered) 187 throw new InvalidOperationException("Undo not possible while data is filtered"); 188 189 originalData.Undo(); 190 } 191 192 public void InTransaction(Action action, DataPreprocessingChangedEventType type = DataPreprocessingChangedEventType.Any) { 193 if (IsFiltered) 194 throw new InvalidOperationException("Transaction not possible while data is filtered"); 195 originalData.InTransaction(action, type); 196 } 197 198 public void BeginTransaction(DataPreprocessingChangedEventType type) { 199 if (IsFiltered) 200 throw new InvalidOperationException("Transaction not possible while data is filtered"); 201 originalData.BeginTransaction(type); 202 } 203 204 public void EndTransaction() { 205 originalData.EndTransaction(); 206 } 207 208 public IEnumerable<string> GetDoubleVariableNames() { 209 return originalData.GetDoubleVariableNames(); 210 } 211 212 public void ClearSelection() { 213 originalData.ClearSelection(); 185 214 } 186 215 … … 190 219 } 191 220 192 193 public void Undo() {194 if (IsFiltered)195 throw new InvalidOperationException("Undo not possible while data is filtered");196 197 originalData.Undo();198 }199 200 public void InTransaction(Action action, DataPreprocessingChangedEventType type = DataPreprocessingChangedEventType.Any) {201 if (IsFiltered)202 throw new InvalidOperationException("Transaction not possible while data is filtered");203 originalData.InTransaction(action, type);204 }205 206 public void BeginTransaction(DataPreprocessingChangedEventType type) {207 if (IsFiltered)208 throw new InvalidOperationException("Transaction not possible while data is filtered");209 originalData.BeginTransaction(type);210 }211 212 public void EndTransaction() {213 originalData.EndTransaction();214 }215 216 public event EventHandler FilterChanged;217 218 #region IPreprocessingData Members219 220 public void ClearSelection() {221 originalData.ClearSelection();222 }223 224 221 public event EventHandler SelectionChanged { 225 222 add { originalData.SelectionChanged += value; } … … 227 224 } 228 225 229 #endregion 230 231 #region IPreprocessingData Members 232 233 234 public IEnumerable<string> GetDoubleVariableNames() { 235 return originalData.GetDoubleVariableNames(); 236 } 237 238 #endregion 226 public event EventHandler FilterChanged; 239 227 } 240 228 }
Note: See TracChangeset
for help on using the changeset viewer.