Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3524


Ignore:
Timestamp:
04/25/10 16:27:17 (15 years ago)
Author:
mkommend
Message:

implemented reviewer comments (ticket #970)

Location:
trunk/sources/HeuristicLab.Optimization.Views/3.3
Files:
2 edited

Legend:

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

    r3499 r3524  
    6363      this.xJitterlabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    6464      this.xJitterlabel.AutoSize = true;
    65       this.xJitterlabel.Location = new System.Drawing.Point(460, 308);
     65      this.xJitterlabel.Location = new System.Drawing.Point(569, 308);
    6666      this.xJitterlabel.Name = "xJitterlabel";
    6767      this.xJitterlabel.Size = new System.Drawing.Size(32, 13);
     
    7272      //
    7373      this.xTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    74       this.xTrackBar.Location = new System.Drawing.Point(498, 305);
     74      this.xTrackBar.Location = new System.Drawing.Point(607, 305);
    7575      this.xTrackBar.Maximum = 100;
    7676      this.xTrackBar.Name = "xTrackBar";
     
    8484      this.xAxisLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    8585      this.xAxisLabel.AutoSize = true;
    86       this.xAxisLabel.Location = new System.Drawing.Point(211, 307);
     86      this.xAxisLabel.Location = new System.Drawing.Point(320, 307);
    8787      this.xAxisLabel.Name = "xAxisLabel";
    8888      this.xAxisLabel.Size = new System.Drawing.Size(15, 13);
     
    9696      this.xAxisComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    9797      this.xAxisComboBox.FormattingEnabled = true;
    98       this.xAxisComboBox.Location = new System.Drawing.Point(232, 305);
     98      this.xAxisComboBox.Location = new System.Drawing.Point(341, 305);
    9999      this.xAxisComboBox.Name = "xAxisComboBox";
    100100      this.xAxisComboBox.Size = new System.Drawing.Size(221, 21);
     
    138138      this.sizeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    139139      this.sizeComboBox.FormattingEnabled = true;
    140       this.sizeComboBox.Location = new System.Drawing.Point(439, 3);
     140      this.sizeComboBox.Location = new System.Drawing.Point(448, 3);
    141141      this.sizeComboBox.Name = "sizeComboBox";
    142       this.sizeComboBox.Size = new System.Drawing.Size(121, 21);
     142      this.sizeComboBox.Size = new System.Drawing.Size(221, 21);
    143143      this.sizeComboBox.TabIndex = 14;
    144144      this.sizeComboBox.SelectedIndexChanged += new System.EventHandler(this.AxisComboBox_SelectedIndexChanged);
     
    148148      this.sizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    149149      this.sizeLabel.AutoSize = true;
    150       this.sizeLabel.Location = new System.Drawing.Point(369, 6);
     150      this.sizeLabel.Location = new System.Drawing.Point(378, 6);
    151151      this.sizeLabel.Name = "sizeLabel";
    152152      this.sizeLabel.Size = new System.Drawing.Size(66, 13);
    153153      this.sizeLabel.TabIndex = 15;
    154154      this.sizeLabel.Text = "Bubble Size:";
     155      this.sizeLabel.Click += new System.EventHandler(this.sizeLabel_Click);
    155156      //
    156157      // chart
     
    165166      series1.ChartArea = "ChartArea1";
    166167      series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bubble;
    167       series1.CustomProperties = "BubbleMaxSize=0";
     168      series1.CustomProperties = "BubbleMinSize=2, BubbleMaxSize=7";
    168169      series1.IsVisibleInLegend = false;
    169170      series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
     
    171172      series1.YValuesPerPoint = 2;
    172173      this.chart.Series.Add(series1);
    173       this.chart.Size = new System.Drawing.Size(554, 261);
     174      this.chart.Size = new System.Drawing.Size(663, 261);
    174175      this.chart.TabIndex = 16;
    175       this.chart.Text = "chart1";
     176      this.chart.Text = "chart";
    176177      this.chart.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chart_MouseUp);
    177178      this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
     
    252253      this.Controls.Add(this.yTrackBar);
    253254      this.Name = "RunCollectionBubbleChartView";
    254       this.Size = new System.Drawing.Size(565, 332);
     255      this.Size = new System.Drawing.Size(674, 332);
    255256      ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).EndInit();
    256257      ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).EndInit();
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs

    r3499 r3524  
    3939  [Content(typeof(RunCollection), false)]
    4040  public partial class RunCollectionBubbleChartView : AsynchronousContentView {
    41     private const string constantLabel = "constant";
     41    private enum SizeDimension { Constant = 0 }
     42    private enum AxisDimension { Index = 0 }
     43
    4244    private Dictionary<int, Dictionary<object, double>> categoricalMapping;
    4345    private Dictionary<IRun, double> xJitter;
     
    5961      this.colorButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color);
    6062      this.isSelecting = false;
    61 
    62       this.chart.Series[0]["BubbleMaxSize"] = "0";
    63       this.chart.Series[0]["BubbleMaxScale"] = "Auto";
    64       this.chart.Series[0]["BubbleMinScale"] = "Auto";
    65       this.chart.Series[0].SmartLabelStyle.Enabled = true;
    66       this.chart.Series[0].SmartLabelStyle.IsMarkerOverlappingAllowed = false;
    67       this.chart.Series[0].SmartLabelStyle.IsOverlappedHidden = true;
    6863
    6964      this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
     
    156151      this.sizeComboBox.Items.Clear();
    157152      if (Content != null) {
     153        string[] additionalAxisDimension = Enum.GetNames(typeof(AxisDimension));
     154        this.xAxisComboBox.Items.AddRange(additionalAxisDimension);
    158155        this.xAxisComboBox.Items.AddRange(Matrix.ColumnNames.ToArray());
     156        this.yAxisComboBox.Items.AddRange(additionalAxisDimension);
    159157        this.yAxisComboBox.Items.AddRange(Matrix.ColumnNames.ToArray());
    160         this.sizeComboBox.Items.Add(constantLabel);
     158        string[] additionalSizeDimension = Enum.GetNames(typeof(SizeDimension));
     159        this.sizeComboBox.Items.AddRange(additionalSizeDimension);
    161160        this.sizeComboBox.Items.AddRange(Matrix.ColumnNames.ToArray());
     161        this.sizeComboBox.SelectedItem = SizeDimension.Constant.ToString();
    162162      }
    163163    }
     
    186186      Series series = this.chart.Series[0];
    187187      int row = this.Content.ToList().IndexOf(run);
    188       xValue = GetValue(row, xAxisComboBox.SelectedIndex);
    189       yValue = GetValue(row, yAxisComboBox.SelectedIndex);
    190       sizeValue = 1.0;
     188      xValue = GetValue(run, (string)xAxisComboBox.SelectedItem);
     189      yValue = GetValue(run, (string)yAxisComboBox.SelectedItem);
    191190      if (xValue.HasValue && yValue.HasValue) {
    192         if (sizeComboBox.SelectedIndex > 0)
    193           sizeValue = GetValue(row, sizeComboBox.SelectedIndex - 1);
     191       sizeValue = GetValue(run, (string)sizeComboBox.SelectedItem);
    194192        xValue = xValue.Value + xValue.Value * GetXJitter(Content.ElementAt(row)) * xJitterFactor;
    195193        yValue = yValue.Value + yValue.Value * GetYJitter(Content.ElementAt(row)) * yJitterFactor;
     
    202200      }
    203201    }
    204     private double? GetValue(int row, int column) {
    205       if (column < 0 || row < 0)
     202    private double? GetValue(IRun run, string columnName) {
     203      if (run == null || string.IsNullOrEmpty(columnName))
    206204        return null;
    207205
    208       IItem value = Content.GetValue(row, column);
    209       DoubleValue doubleValue = value as DoubleValue;
    210       IntValue intValue = value as IntValue;
    211       double ret;
    212 
    213       if (doubleValue != null)
    214         ret = doubleValue.Value;
    215       else if (intValue != null)
    216         ret = intValue.Value;
    217       else
    218         ret = GetCategoricalValue(column, Matrix.GetValue(row, column));
    219 
    220       return ret;
    221     }
    222     private double GetCategoricalValue(int dimension, object c) {
     206      if (Enum.IsDefined(typeof(AxisDimension), columnName)) {
     207        AxisDimension axisDimension = (AxisDimension)Enum.Parse(typeof(AxisDimension), columnName);
     208        return GetValue(run, axisDimension);
     209      } else if (Enum.IsDefined(typeof(SizeDimension), columnName)) {
     210        SizeDimension sizeDimension = (SizeDimension)Enum.Parse(typeof(SizeDimension), columnName);
     211        return GetValue(run, sizeDimension);
     212      } else {
     213        int columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName);
     214        IItem value = Content.GetValue(run, columnIndex);
     215        if (value == null)
     216          return null;
     217
     218        DoubleValue doubleValue = value as DoubleValue;
     219        IntValue intValue = value as IntValue;
     220        double ret;
     221        if (doubleValue != null)
     222          ret = doubleValue.Value;
     223        else if (intValue != null)
     224          ret = intValue.Value;
     225        else
     226          ret = GetCategoricalValue(columnIndex, value.ToString());
     227
     228        return ret;
     229      }
     230    }
     231    private double GetCategoricalValue(int dimension, string value) {
    223232      if (!this.categoricalMapping.ContainsKey(dimension))
    224233        this.categoricalMapping[dimension] = new Dictionary<object, double>();
    225       if (!this.categoricalMapping[dimension].ContainsKey(c)) {
     234      if (!this.categoricalMapping[dimension].ContainsKey(value)) {
    226235        if (this.categoricalMapping[dimension].Values.Count == 0)
    227           this.categoricalMapping[dimension][c] = 1.0;
     236          this.categoricalMapping[dimension][value] = 1.0;
    228237        else
    229           this.categoricalMapping[dimension][c] = this.categoricalMapping[dimension].Values.Max() + 1.0;
    230       }
    231       return this.categoricalMapping[dimension][c];
    232     }
    233 
    234     #region drag and drop
     238          this.categoricalMapping[dimension][value] = this.categoricalMapping[dimension].Values.Max() + 1.0;
     239      }
     240      return this.categoricalMapping[dimension][value];
     241    }
     242    private double GetValue(IRun run, AxisDimension axisDimension) {
     243      double value = double.NaN;
     244      switch (axisDimension) {
     245        case AxisDimension.Index: {
     246            value = Content.ToList().IndexOf(run);
     247            break;
     248          }
     249        default: {
     250            throw new ArgumentException("No handling strategy for " + axisDimension.ToString() + " is defined.");
     251          }
     252      }
     253      return value;
     254    }
     255    private double GetValue(IRun run, SizeDimension sizeDimension) {
     256      double value = double.NaN;
     257      switch (sizeDimension) {
     258        case SizeDimension.Constant: {
     259            value = 2;
     260            break;
     261          }
     262        default: {
     263            throw new ArgumentException("No handling strategy for " + sizeDimension.ToString() + " is defined.");
     264          }
     265      }
     266      return value;
     267    }
     268
     269    #region drag and drop and tooltip
    235270    private IRun draggedRun;
    236271    private void chart_MouseDown(object sender, MouseEventArgs e) {
     
    306341        }
    307342      }
    308       string newTooltipText;
     343      string newTooltipText = string.Empty;
    309344      string oldTooltipText;
    310345      if (h.ChartElementType == ChartElementType.DataPoint) {
    311346        IRun run = (IRun)((DataPoint)h.Object).Tag;
    312         newTooltipText = run.Name + System.Environment.NewLine;
    313         newTooltipText += xAxisComboBox.SelectedItem + " : " + Content.GetValue(run, xAxisComboBox.SelectedIndex).ToString() + Environment.NewLine;
    314         newTooltipText += yAxisComboBox.SelectedItem + " : " + Content.GetValue(run, yAxisComboBox.SelectedIndex).ToString() + Environment.NewLine; ;
    315       } else
    316         newTooltipText = string.Empty;
     347        newTooltipText = BuildTooltip(run);
     348      }
     349
    317350      oldTooltipText = this.tooltip.GetToolTip(chart);
    318351      if (newTooltipText != oldTooltipText)
    319352        this.tooltip.SetToolTip(chart, newTooltipText);
     353    }
     354
     355    private string BuildTooltip(IRun run) {
     356      string tooltip;
     357      tooltip = run.Name + System.Environment.NewLine;
     358
     359      double? xValue = this.GetValue(run, (string)xAxisComboBox.SelectedItem);
     360      double? yValue = this.GetValue(run, (string)yAxisComboBox.SelectedItem);
     361      double? sizeValue = this.GetValue(run, (string)sizeComboBox.SelectedItem);
     362
     363      string xString = xValue == null ? string.Empty : xValue.Value.ToString();
     364      string yString = yValue == null ? string.Empty : yValue.Value.ToString();
     365      string sizeString = sizeValue == null ? string.Empty : sizeValue.Value.ToString();
     366
     367      tooltip += xAxisComboBox.SelectedItem + " : " + xString + Environment.NewLine;
     368      tooltip += yAxisComboBox.SelectedItem + " : " + yString + Environment.NewLine;
     369      tooltip += sizeComboBox.SelectedItem + " : " + sizeString + Environment.NewLine;
     370
     371      return tooltip;
    320372    }
    321373    #endregion
     
    384436    }
    385437    #endregion
     438
     439    private void sizeLabel_Click(object sender, EventArgs e) {
     440
     441    }
    386442  }
    387443}
Note: See TracChangeset for help on using the changeset viewer.