Changeset 1424


Ignore:
Timestamp:
03/25/09 19:00:02 (10 years ago)
Author:
gkronber
Message:

Fixed tooltip bug in CEDMA BubbleChart. #543 (MouseDrag events in CEDMA BubbleChart cause 100% CPU utilization)

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Charting/BubbleChart.cs

    r1287 r1424  
    118118      double maxSize = 1;
    119119      double minSize = 1;
    120       try {
    121         if (sizeDimension != null && results.OrdinalVariables.Contains(sizeDimension)) {
    122           var sizes = records
    123             .Select(x => Convert.ToDouble(x.Get(sizeDimension)))
    124             .Where(size => !double.IsInfinity(size) && size != double.MaxValue && size != double.MinValue)
    125             .OrderBy(r => r);
    126           minSize = sizes.ElementAt((int)(sizes.Count() * 0.1));
    127           maxSize = sizes.ElementAt((int)(sizes.Count() * 0.9));
    128         }
    129       }
    130       catch (InvalidCastException) {
     120      if (sizeDimension != null && results.OrdinalVariables.Contains(sizeDimension)) {
     121        var sizes = records
     122          .Select(x => Convert.ToDouble(x.Get(sizeDimension)))
     123          .Where(size => !double.IsInfinity(size) && size != double.MaxValue && size != double.MinValue)
     124          .OrderBy(r => r);
     125        minSize = sizes.ElementAt((int)(sizes.Count() * 0.1));
     126        maxSize = sizes.ElementAt((int)(sizes.Count() * 0.9));
     127      } else {
    131128        minSize = 1;
    132129        maxSize = 1;
     
    142139        double x, y;
    143140        int size;
    144         try {
     141        if (results.OrdinalVariables.Contains(xDimension)) {
    145142          x = Convert.ToDouble(r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor;
     143        } else if (results.CategoricalVariables.Contains(xDimension)) {
     144          x = results.IndexOfCategoricalValue(xDimension, r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor;
     145        } else {
     146          x = double.NaN;
     147        }
     148        if (results.OrdinalVariables.Contains(yDimension)) {
    146149          y = Convert.ToDouble(r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor;
    147           size = CalculateSize(Convert.ToDouble(r.Get(sizeDimension)), minSize, maxSize);
    148         }
    149         catch (InvalidCastException) {
    150           x = double.NaN;
     150        } else if (results.CategoricalVariables.Contains(yDimension)) {
     151          y = results.IndexOfCategoricalValue(yDimension, r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor;
     152        } else {
    151153          y = double.NaN;
    152           size = minBubbleSize;
    153         }
     154        }
     155        size = CalculateSize(Convert.ToDouble(r.Get(sizeDimension)), minSize, maxSize);
     156
    154157        if (double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN;
    155158        if (double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN;
     
    221224    }
    222225
    223 
    224226    public override void MouseDrag(Point start, Point end, MouseButtons button) {
    225227      if (button == MouseButtons.Left && Mode == ChartMode.Select) {
     
    251253      if (button == MouseButtons.Left) {
    252254        ResultsEntry r = GetResultsEntry(point);
    253         if (r != null) r.ToggleSelected();
    254         results.FireChanged();
     255        if (r != null) {
     256          r.ToggleSelected();
     257          results.FireChanged();
     258        }
    255259      } else {
    256260        base.MouseClick(point, button);
  • trunk/sources/HeuristicLab.CEDMA.Core/Results.cs

    r1417 r1424  
    137137        .ToArray();
    138138    }
     139
     140    public double IndexOfCategoricalValue(string variable, object value) {
     141      return 1.0; // TODO
     142    }
    139143  }
    140144}
  • trunk/sources/HeuristicLab.CEDMA.Core/ResultsEntry.cs

    r1417 r1424  
    3737
    3838    private bool selected = false;
    39     public bool Selected { 
     39    public bool Selected {
    4040      get { return selected; }
    41       set { selected = value; } 
     41      set { selected = value; }
    4242    }
    4343
    4444    private string uri;
    45     public string Uri { 
     45    public string Uri {
    4646      get { return uri; }
    4747      set { uri = value; }
     
    6464      StringBuilder b = new StringBuilder();
    6565      foreach (KeyValuePair<string, object> v in values) {
    66         b.Append(v.Key).Append(" = ").Append(v.Value).AppendLine();
     66        string val = v.Value.ToString();
     67        if (val.Length > 40) val = val.Substring(0, 38) + "...";
     68        b.Append(v.Key).Append(" = ").Append(val).AppendLine();
    6769      }
    6870      return b.ToString();
    6971    }
    70 
    71     //internal void OpenModel() {
    72     //  resultList.OpenModel(this);
    73     //}
    74 
    75     //internal void OpenGeneratingAlgorithm() {
    76     //  resultList.OpenAlgorithm(this);
    77     //}
    7872  }
    7973}
Note: See TracChangeset for help on using the changeset viewer.