Changeset 15674
- Timestamp:
- 01/30/18 14:00:03 (7 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.cs
r15667 r15674 32 32 [Content(typeof(IClassificationSolution))] 33 33 public partial class ClassificationSolutionVariableImpactsView : DataAnalysisSolutionEvaluationView { 34 private enum SortingCriteria { 35 ImpactValue, 36 Occurrence, 37 VariableName 38 } 39 34 40 private Dictionary<string, double> rawVariableImpacts = new Dictionary<string, double>(); 35 41 … … 46 52 47 53 //Little workaround. If you fill the ComboBox-Items in the other partial class, the UI-Designer will moan. 48 this.sortByComboBox.Items.AddRange(Enum.GetValues(typeof( ClassificationSolutionVariableImpactsCalculator.SortingCriteria)).Cast<object>().ToArray());49 this.sortByComboBox.SelectedItem = ClassificationSolutionVariableImpactsCalculator.SortingCriteria.ImpactValue;54 this.sortByComboBox.Items.AddRange(Enum.GetValues(typeof(SortingCriteria)).Cast<object>().ToArray()); 55 this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue; 50 56 51 57 this.dataPartitionComboBox.SelectedIndex = 0; … … 96 102 //Update the default ordering (asc,desc), but remove the eventHandler beforehand (otherwise the data would be ordered twice) 97 103 ascendingCheckBox.CheckedChanged -= ascendingCheckBox_CheckedChanged; 98 switch (( ClassificationSolutionVariableImpactsCalculator.SortingCriteria)sortByComboBox.SelectedItem) {99 case ClassificationSolutionVariableImpactsCalculator.SortingCriteria.ImpactValue:104 switch ((SortingCriteria)sortByComboBox.SelectedItem) { 105 case SortingCriteria.ImpactValue: 100 106 ascendingCheckBox.Checked = false; 101 107 break; 102 case ClassificationSolutionVariableImpactsCalculator.SortingCriteria.Occurrence:108 case SortingCriteria.Occurrence: 103 109 ascendingCheckBox.Checked = true; 104 110 break; 105 case ClassificationSolutionVariableImpactsCalculator.SortingCriteria.VariableName:111 case SortingCriteria.VariableName: 106 112 ascendingCheckBox.Checked = true; 107 113 break; 108 114 default: 109 throw new Exception("Cannot interpret SortingCriteria");115 throw new NotImplementedException("Ordering for selected SortingCriteria not implemented"); 110 116 } 111 117 ascendingCheckBox.CheckedChanged += ascendingCheckBox_CheckedChanged; … … 121 127 #region Helper Methods 122 128 private void UpdateVariableImpacts() { 123 if (Content == null || replacementComboBox.SelectedIndex < 0 124 || factorVarReplComboBox.SelectedIndex < 0 125 || dataPartitionComboBox.SelectedIndex < 0) return; 129 if (Content == null) { return; } 130 if (replacementComboBox.SelectedIndex < 0) { return; } 131 if (dataPartitionComboBox.SelectedIndex < 0) { return; } 132 if (factorVarReplComboBox.SelectedIndex < 0) { return; } 133 134 variableImactsArrayView.Caption = Content.Name + " Variable Impacts"; 135 126 136 var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm; 127 variableImactsArrayView.Caption = Content.Name + " Variable Impacts"; 128 var replMethod = 129 (ClassificationSolutionVariableImpactsCalculator.ReplacementMethodEnum) 130 replacementComboBox.Items[replacementComboBox.SelectedIndex]; 131 var factorReplMethod = 132 (ClassificationSolutionVariableImpactsCalculator.FactorReplacementMethodEnum) 133 factorVarReplComboBox.Items[factorVarReplComboBox.SelectedIndex]; 134 var dataPartition = 135 (ClassificationSolutionVariableImpactsCalculator.DataPartitionEnum)dataPartitionComboBox.SelectedItem; 137 var replMethod = (ClassificationSolutionVariableImpactsCalculator.ReplacementMethodEnum)replacementComboBox.Items[replacementComboBox.SelectedIndex]; 138 var factorReplMethod = (ClassificationSolutionVariableImpactsCalculator.FactorReplacementMethodEnum)factorVarReplComboBox.Items[factorVarReplComboBox.SelectedIndex]; 139 var dataPartition = (ClassificationSolutionVariableImpactsCalculator.DataPartitionEnum)dataPartitionComboBox.SelectedItem; 136 140 137 141 Task.Factory.StartNew(() => { … … 146 150 rawVariableImpacts.Clear(); 147 151 originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(v, impacts.First(vv => vv.Item1 == v).Item2)); 152 UpdateDataOrdering(); 148 153 } finally { 149 154 mainForm.RemoveOperationProgressFromView(this); 150 UpdateDataOrdering();151 155 } 152 156 }); … … 159 163 private void UpdateDataOrdering() { 160 164 //Check if valid sortingCriteria is selected and data exists 161 if (sortByComboBox.SelectedIndex == -1 || rawVariableImpacts == null || !rawVariableImpacts.Any()) { return; } 165 if (sortByComboBox.SelectedIndex == -1) { return; } 166 if (rawVariableImpacts == null) { return; } 167 if (!rawVariableImpacts.Any()) { return; } 162 168 163 var selectedItem = ( ClassificationSolutionVariableImpactsCalculator.SortingCriteria)sortByComboBox.SelectedItem;169 var selectedItem = (SortingCriteria)sortByComboBox.SelectedItem; 164 170 bool ascending = ascendingCheckBox.Checked; 165 171 … … 168 174 //Sort accordingly 169 175 switch (selectedItem) { 170 case ClassificationSolutionVariableImpactsCalculator.SortingCriteria.ImpactValue:171 orderedEntries = ascending ? rawVariableImpacts.OrderBy(v => v.Value) : rawVariableImpacts.OrderByDescending(v => v.Value);176 case SortingCriteria.ImpactValue: 177 orderedEntries = rawVariableImpacts.OrderBy(v => v.Value); 172 178 break; 173 case ClassificationSolutionVariableImpactsCalculator.SortingCriteria.Occurrence:174 orderedEntries = ascending ? rawVariableImpacts : rawVariableImpacts.Reverse();179 case SortingCriteria.Occurrence: 180 orderedEntries = rawVariableImpacts; 175 181 break; 176 case ClassificationSolutionVariableImpactsCalculator.SortingCriteria.VariableName:177 orderedEntries = ascending ? rawVariableImpacts.OrderBy(v => v.Key, new NaturalStringComparer()) : rawVariableImpacts.OrderByDescending(v => v.Key, new NaturalStringComparer());182 case SortingCriteria.VariableName: 183 orderedEntries = rawVariableImpacts.OrderBy(v => v.Key, new NaturalStringComparer()); 178 184 break; 179 185 default: 180 throw new Exception("Cannot interpret SortingCriteria");186 throw new NotImplementedException("Ordering for selected SortingCriteria not implemented"); 181 187 } 188 189 if (!ascending) { orderedEntries = orderedEntries.Reverse(); } 182 190 183 191 //Write the data back -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionVariableImpactsCalculator.cs
r15667 r15674 51 51 Test, 52 52 All 53 }54 55 public enum SortingCriteria {56 ImpactValue,57 Occurrence,58 VariableName59 53 } 60 54
Note: See TracChangeset
for help on using the changeset viewer.