Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8832


Ignore:
Timestamp:
10/22/12 18:53:05 (10 years ago)
Author:
gkronber
Message:

#1918 suggested fix for strange method SetAutomaticUpdateOfAxis(). Exception is gone but don't know if originally intended functionality is still intact.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs

    r8738 r8832  
    263263      xTrackBar.Value = 0;
    264264      yTrackBar.Value = 0;
    265       SetAutomaticUpdateOfAxis(xAxis, true);
    266       SetAutomaticUpdateOfAxis(yAxis, true);
    267265    }
    268266
     
    284282    }
    285283
     284
     285    private class AxisParameters {
     286      public double min, max, majorGridInterval, majorTickMarkInterval, labelStyleInterval;
     287    }
    286288    private void UpdateDataPointJitter() {
    287289      var xAxis = this.chart.ChartAreas[0].AxisX;
    288290      var yAxis = this.chart.ChartAreas[0].AxisY;
    289       SetAutomaticUpdateOfAxis(xAxis, false);
    290       SetAutomaticUpdateOfAxis(yAxis, false);
     291
     292
     293      // disable automatic update of axis
     294      var disabledParameters = new AxisParameters();
     295      disabledParameters.min = disabledParameters.max = disabledParameters.majorGridInterval = disabledParameters.majorTickMarkInterval = disabledParameters.labelStyleInterval = double.NaN;
     296
     297      AxisParameters savedXParameters, savedYParameters;
     298      savedXParameters = SetAxisParameters(xAxis, disabledParameters);
     299      savedYParameters = SetAxisParameters(yAxis, disabledParameters);
    291300
    292301      foreach (DataPoint point in chart.Series[0].Points) {
     
    296305
    297306        if (!xJitterFactor.IsAlmost(0.0))
    298           xValue += 0.1 * GetXJitter(run) * xJitterFactor * (xAxis.Maximum - xAxis.Minimum);
     307          xValue += 0.1 * GetXJitter(run) * xJitterFactor * (savedXParameters.max - savedXParameters.min);
    299308        if (!yJitterFactor.IsAlmost(0.0))
    300           yValue += 0.1 * GetYJitter(run) * yJitterFactor * (yAxis.Maximum - yAxis.Minimum);
     309          yValue += 0.1 * GetYJitter(run) * yJitterFactor * (savedYParameters.max - savedYParameters.min);
    301310
    302311        point.XValue = xValue;
    303312        point.YValues[0] = yValue;
    304313      }
    305     }
    306 
    307     private void SetAutomaticUpdateOfAxis(Axis axis, bool enabled) {
    308       if (enabled) {
    309         axis.Maximum = double.NaN;
    310         axis.Minimum = double.NaN;
    311         axis.MajorGrid.Interval = double.NaN;
    312         axis.MajorTickMark.Interval = double.NaN;
    313         axis.LabelStyle.Interval = double.NaN;
    314       } else {
    315         axis.Minimum = axis.Minimum;
    316         axis.Maximum = axis.Maximum;
    317         axis.MajorGrid.Interval = axis.MajorGrid.Interval;
    318         axis.MajorTickMark.Interval = axis.MajorTickMark.Interval;
    319         axis.LabelStyle.Interval = axis.LabelStyle.Interval;
    320       }
    321 
     314      SetAxisParameters(xAxis, savedXParameters);
     315      SetAxisParameters(yAxis, savedYParameters);
     316    }
     317
     318    private AxisParameters SetAxisParameters(Axis axis, AxisParameters @new) {
     319      var old = new AxisParameters();
     320      old.min = axis.Minimum;
     321      old.max = axis.Maximum;
     322      old.majorGridInterval = axis.MajorGrid.Interval;
     323      old.majorTickMarkInterval = axis.MajorTickMark.Interval;
     324      old.labelStyleInterval = axis.LabelStyle.Interval;
     325
     326      axis.Maximum = @new.max;
     327      axis.Minimum = @new.min;
     328      axis.MajorGrid.Interval = @new.majorGridInterval;
     329      axis.MajorTickMark.Interval = @new.majorTickMarkInterval;
     330      axis.LabelStyle.Interval = @new.labelStyleInterval;
     331      return old;
    322332    }
    323333
Note: See TracChangeset for help on using the changeset viewer.