Changeset 4808 for trunk/sources/HeuristicLab.Optimization.Views/3.3
- Timestamp:
- 11/16/10 13:51:54 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs
r4799 r4808 580 580 581 581 #region automatic coloring 582 private static Color[] colors;583 protected static Color[] Colors {584 get {585 if (colors == null) InitializeColors();586 return colors;587 }588 }589 private static void InitializeColors() {590 colors = new Color[256];591 int stepWidth = (256 * 4) / colors.Length;592 int currentValue;593 int currentClass;594 for (int i = 0; i < colors.Length; i++) {595 currentValue = (i * stepWidth) % 256;596 currentClass = (i * stepWidth) / 256;597 switch (currentClass) {598 case 0: { colors[i] = Color.FromArgb(0, currentValue, 255); break; } // blue -> cyan599 case 1: { colors[i] = Color.FromArgb(0, 255, 255 - currentValue); break; } // cyan -> green600 case 2: { colors[i] = Color.FromArgb(currentValue, 255, 0); break; } // green -> yellow601 case 3: { colors[i] = Color.FromArgb(255, 255 - currentValue, 0); break; } // yellow -> red602 }603 }604 }605 606 582 private void colorXAxisButton_Click(object sender, EventArgs e) { 607 583 double minValue = chart.Series[0].Points.Min(p => p.XValue); 608 584 double maxValue = chart.Series[0].Points.Max(p => p.XValue); 609 585 foreach (DataPoint point in chart.Series[0].Points) { 610 int colorIndex = (int)((Color s.Length- 1) * (point.XValue - minValue) / (maxValue - minValue));586 int colorIndex = (int)((ColorGradient.Colors.Count - 1) * (point.XValue - minValue) / (maxValue - minValue)); 611 587 IRun run = point.Tag as IRun; 612 if (run != null) 613 run.Color = Colors[colorIndex]; 588 if (run != null) run.Color = ColorGradient.Colors[colorIndex]; 614 589 } 615 590 } … … 619 594 double maxValue = chart.Series[0].Points.Max(p => p.YValues[0]); 620 595 foreach (DataPoint point in chart.Series[0].Points) { 621 int colorIndex = (int)((Color s.Length- 1) * (point.YValues[0] - minValue) / (maxValue - minValue));596 int colorIndex = (int)((ColorGradient.Colors.Count - 1) * (point.YValues[0] - minValue) / (maxValue - minValue)); 622 597 IRun run = point.Tag as IRun; 623 if (run != null) 624 run.Color = Colors[colorIndex]; 598 if (run != null) run.Color = ColorGradient.Colors[colorIndex]; 625 599 } 626 600 }
Note: See TracChangeset
for help on using the changeset viewer.