Changeset 3524
- Timestamp:
- 04/25/10 16:27:17 (15 years ago)
- 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 63 63 this.xJitterlabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 64 64 this.xJitterlabel.AutoSize = true; 65 this.xJitterlabel.Location = new System.Drawing.Point( 460, 308);65 this.xJitterlabel.Location = new System.Drawing.Point(569, 308); 66 66 this.xJitterlabel.Name = "xJitterlabel"; 67 67 this.xJitterlabel.Size = new System.Drawing.Size(32, 13); … … 72 72 // 73 73 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); 75 75 this.xTrackBar.Maximum = 100; 76 76 this.xTrackBar.Name = "xTrackBar"; … … 84 84 this.xAxisLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 85 85 this.xAxisLabel.AutoSize = true; 86 this.xAxisLabel.Location = new System.Drawing.Point( 211, 307);86 this.xAxisLabel.Location = new System.Drawing.Point(320, 307); 87 87 this.xAxisLabel.Name = "xAxisLabel"; 88 88 this.xAxisLabel.Size = new System.Drawing.Size(15, 13); … … 96 96 this.xAxisComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 97 97 this.xAxisComboBox.FormattingEnabled = true; 98 this.xAxisComboBox.Location = new System.Drawing.Point( 232, 305);98 this.xAxisComboBox.Location = new System.Drawing.Point(341, 305); 99 99 this.xAxisComboBox.Name = "xAxisComboBox"; 100 100 this.xAxisComboBox.Size = new System.Drawing.Size(221, 21); … … 138 138 this.sizeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 139 139 this.sizeComboBox.FormattingEnabled = true; 140 this.sizeComboBox.Location = new System.Drawing.Point(4 39, 3);140 this.sizeComboBox.Location = new System.Drawing.Point(448, 3); 141 141 this.sizeComboBox.Name = "sizeComboBox"; 142 this.sizeComboBox.Size = new System.Drawing.Size( 121, 21);142 this.sizeComboBox.Size = new System.Drawing.Size(221, 21); 143 143 this.sizeComboBox.TabIndex = 14; 144 144 this.sizeComboBox.SelectedIndexChanged += new System.EventHandler(this.AxisComboBox_SelectedIndexChanged); … … 148 148 this.sizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 149 149 this.sizeLabel.AutoSize = true; 150 this.sizeLabel.Location = new System.Drawing.Point(3 69, 6);150 this.sizeLabel.Location = new System.Drawing.Point(378, 6); 151 151 this.sizeLabel.Name = "sizeLabel"; 152 152 this.sizeLabel.Size = new System.Drawing.Size(66, 13); 153 153 this.sizeLabel.TabIndex = 15; 154 154 this.sizeLabel.Text = "Bubble Size:"; 155 this.sizeLabel.Click += new System.EventHandler(this.sizeLabel_Click); 155 156 // 156 157 // chart … … 165 166 series1.ChartArea = "ChartArea1"; 166 167 series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bubble; 167 series1.CustomProperties = "BubbleM axSize=0";168 series1.CustomProperties = "BubbleMinSize=2, BubbleMaxSize=7"; 168 169 series1.IsVisibleInLegend = false; 169 170 series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; … … 171 172 series1.YValuesPerPoint = 2; 172 173 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); 174 175 this.chart.TabIndex = 16; 175 this.chart.Text = "chart 1";176 this.chart.Text = "chart"; 176 177 this.chart.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chart_MouseUp); 177 178 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); … … 252 253 this.Controls.Add(this.yTrackBar); 253 254 this.Name = "RunCollectionBubbleChartView"; 254 this.Size = new System.Drawing.Size( 565, 332);255 this.Size = new System.Drawing.Size(674, 332); 255 256 ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).EndInit(); 256 257 ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).EndInit(); -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs
r3499 r3524 39 39 [Content(typeof(RunCollection), false)] 40 40 public partial class RunCollectionBubbleChartView : AsynchronousContentView { 41 private const string constantLabel = "constant"; 41 private enum SizeDimension { Constant = 0 } 42 private enum AxisDimension { Index = 0 } 43 42 44 private Dictionary<int, Dictionary<object, double>> categoricalMapping; 43 45 private Dictionary<IRun, double> xJitter; … … 59 61 this.colorButton.Image = this.GenerateImage(16, 16, this.colorDialog.Color); 60 62 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;68 63 69 64 this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; … … 156 151 this.sizeComboBox.Items.Clear(); 157 152 if (Content != null) { 153 string[] additionalAxisDimension = Enum.GetNames(typeof(AxisDimension)); 154 this.xAxisComboBox.Items.AddRange(additionalAxisDimension); 158 155 this.xAxisComboBox.Items.AddRange(Matrix.ColumnNames.ToArray()); 156 this.yAxisComboBox.Items.AddRange(additionalAxisDimension); 159 157 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); 161 160 this.sizeComboBox.Items.AddRange(Matrix.ColumnNames.ToArray()); 161 this.sizeComboBox.SelectedItem = SizeDimension.Constant.ToString(); 162 162 } 163 163 } … … 186 186 Series series = this.chart.Series[0]; 187 187 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); 191 190 if (xValue.HasValue && yValue.HasValue) { 192 if (sizeComboBox.SelectedIndex > 0) 193 sizeValue = GetValue(row, sizeComboBox.SelectedIndex - 1); 191 sizeValue = GetValue(run, (string)sizeComboBox.SelectedItem); 194 192 xValue = xValue.Value + xValue.Value * GetXJitter(Content.ElementAt(row)) * xJitterFactor; 195 193 yValue = yValue.Value + yValue.Value * GetYJitter(Content.ElementAt(row)) * yJitterFactor; … … 202 200 } 203 201 } 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)) 206 204 return null; 207 205 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) { 223 232 if (!this.categoricalMapping.ContainsKey(dimension)) 224 233 this.categoricalMapping[dimension] = new Dictionary<object, double>(); 225 if (!this.categoricalMapping[dimension].ContainsKey( c)) {234 if (!this.categoricalMapping[dimension].ContainsKey(value)) { 226 235 if (this.categoricalMapping[dimension].Values.Count == 0) 227 this.categoricalMapping[dimension][ c] = 1.0;236 this.categoricalMapping[dimension][value] = 1.0; 228 237 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 235 270 private IRun draggedRun; 236 271 private void chart_MouseDown(object sender, MouseEventArgs e) { … … 306 341 } 307 342 } 308 string newTooltipText ;343 string newTooltipText = string.Empty; 309 344 string oldTooltipText; 310 345 if (h.ChartElementType == ChartElementType.DataPoint) { 311 346 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 317 350 oldTooltipText = this.tooltip.GetToolTip(chart); 318 351 if (newTooltipText != oldTooltipText) 319 352 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; 320 372 } 321 373 #endregion … … 384 436 } 385 437 #endregion 438 439 private void sizeLabel_Click(object sender, EventArgs e) { 440 441 } 386 442 } 387 443 }
Note: See TracChangeset
for help on using the changeset viewer.