Changeset 1983
- Timestamp:
- 05/31/09 21:26:27 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.Test/3.2/LineChartTests.cs
r1982 r1983 219 219 220 220 [Test] 221 public void TestInsertValuesInDataRow() { 221 public void TestAddValueToDataRow() { 222 LineChartTestForm f = new LineChartTestForm(model); 223 224 IDataRow row = new DataRow(); 225 row.AddValue(0); 226 row.AddValue(10); 227 row.AddValue(-5); 228 229 model.AddDataRow(row); 230 231 f.ShowDialog(); 232 } 233 234 [Test] 235 public void TestAddValuesToDataRow() { 236 LineChartTestForm f = new LineChartTestForm(model); 237 238 IDataRow row = new DataRow(); 239 row.AddValues(new double[] {0, 10, -5}); 240 241 model.AddDataRow(row); 242 243 f.ShowDialog(); 244 } 245 246 [Test] 247 public void TestInsertValueInDataRow() { 222 248 LineChartTestForm f = new LineChartTestForm(model); 223 249 … … 228 254 row.AddValue(10, 1); 229 255 row.AddValue(10, 2); 256 257 model.AddDataRow(row); 258 259 f.ShowDialog(); 260 } 261 262 [Test] 263 public void TestInsertValuesInDataRow() { 264 LineChartTestForm f = new LineChartTestForm(model); 265 266 IDataRow row = new DataRow(); 267 row.AddValue(0); 268 row.AddValue(5); 269 270 row.AddValues(new double[] {10, 10}, 1); 271 272 model.AddDataRow(row); 273 274 f.ShowDialog(); 275 } 276 277 [Test] 278 public void TestModifyValueInDataRow() { 279 LineChartTestForm f = new LineChartTestForm(model); 280 281 IDataRow row = new DataRow(); 282 row.AddValue(0); 283 row.AddValue(100); 284 row.AddValue(0); 285 286 row.ModifyValue(5, 1); 287 288 model.AddDataRow(row); 289 290 f.ShowDialog(); 291 } 292 293 [Test] 294 public void TestModifyValuesInDataRow() { 295 LineChartTestForm f = new LineChartTestForm(model); 296 297 IDataRow row = new DataRow(); 298 row.AddValue(0); 299 row.AddValue(100); 300 row.AddValue(100); 301 row.AddValue(0); 302 303 row.ModifyValues(new double[] {5, 5}, 1); 230 304 231 305 model.AddDataRow(row); -
trunk/sources/HeuristicLab.Visualization/3.2/DataRow.cs
r1982 r1983 2 2 using System.Drawing; 3 3 using System.Collections.Generic; 4 using HeuristicLab.Visualization.LabelProvider;5 4 6 5 namespace HeuristicLab.Visualization { … … 76 75 77 76 public override void AddValues(double[] values, int index) { 78 int j = index; 79 80 //check if index to start changes is valid 81 if (index >=0 && (index + values.Length) < dataRow.Count) { 82 foreach (double d in values) { 83 dataRow.Insert(j, d); 84 j++; 77 if (index >= 0 && index < dataRow.Count) { 78 for (int i = 0; i < values.Length; i++) { 79 double value = values[i]; 80 UpdateMinMaxValue(value); 81 dataRow.Insert(index + i, value); 85 82 } 86 83 OnValuesChanged(values, index, Action.Added); … … 93 90 //check if index is valid 94 91 if (index >= 0 && index < dataRow.Count) { 92 UpdateMinMaxValue(value, index); // bad runtime but works 95 93 dataRow[index] = value; 96 94 OnValueChanged(value, index, Action.Modified); … … 101 99 102 100 public override void ModifyValues(double[] values, int index) { 103 int startInd = index;104 int modInd = index;105 106 101 //check if index to start modification is valid 107 if (startInd >=0 && startInd + values.Length < dataRow.Count) { 108 foreach (double d in values) { 109 dataRow[modInd] = d; 110 modInd++; 102 if (index >= 0 && index + values.Length < dataRow.Count) { 103 for (int i = 0; i < values.Length; i++) { 104 double value = values[i]; 105 UpdateMinMaxValue(value, index + i); // bad runtime but works 106 dataRow[index+i] = value; 111 107 } 112 OnValuesChanged(values, startInd, Action.Modified);108 OnValuesChanged(values, index, Action.Modified); 113 109 } else { 114 110 throw new IndexOutOfRangeException(); … … 169 165 } 170 166 167 private void UpdateMinMaxValue(double newValue, int oldValueIndex) { 168 if (minValue != dataRow[oldValueIndex] && maxValue != dataRow[oldValueIndex]) 169 UpdateMinMaxValue(newValue); 170 else { 171 minValue = double.MaxValue; 172 maxValue = double.MinValue; 173 174 for (int i = 0; i < dataRow.Count; i++) { 175 double value = oldValueIndex != i ? dataRow[i] : newValue; 176 UpdateMinMaxValue(value); 177 } 178 } 179 } 180 171 181 private void UpdateMinMaxValue(double value) { 172 182 maxValue = Math.Max(value, maxValue);
Note: See TracChangeset
for help on using the changeset viewer.