Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Charting/3.3/VisualMatrixRow.cs @ 2301

Last change on this file since 2301 was 2299, checked in by mkommend, 15 years ago

added ctor with !xJitter and !yJitter for VisualMatrixRow (ticket #723)

File size: 2.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using HeuristicLab.SparseMatrix;
7
8namespace HeuristicLab.CEDMA.Charting {
9  public class VisualMatrixRow : ItemBase {
10    private static Random random = new Random();
11    private Dictionary<string, object> dict;
12
13    public VisualMatrixRow() {
14      this.dict = new Dictionary<string, object>();
15      this.visible = true;
16      this.selected = false;
17      this.xJitter = random.NextDouble() * 2.0 - 1.0;
18      this.yJitter = random.NextDouble() * 2.0 - 1.0;
19    }
20
21    public VisualMatrixRow(double xJitter, double yJitter) {
22      this.dict = new Dictionary<string, object>();
23      this.visible = true;
24      this.selected = false;
25      this.xJitter = xJitter;
26      this.yJitter = yJitter;
27    }
28
29    public VisualMatrixRow(MatrixRow row)
30      : this() {
31      foreach (KeyValuePair<string, object> value in row.Values)
32        dict[value.Key] = value.Value;
33    }
34
35    private bool visible;
36    public bool Visible {
37      get { return this.visible; }
38      set { this.visible = value; }
39    }
40
41    private bool selected;
42    public bool Selected {
43      get { return this.selected; }
44      set { this.selected = value; }
45    }
46
47    private double xJitter;
48    public double XJitter {
49      get { return xJitter; }
50    }
51
52    private double yJitter;
53    public double YJitter {
54      get { return yJitter; }
55    }
56
57    public object Get(string name) {
58      if (!dict.ContainsKey(name))
59        return null;
60      return dict[name];
61    }
62
63    public void Set(string name, object value) {
64      this.dict[name] = value;
65    }
66
67    public IEnumerable<KeyValuePair<string, object>> Values {
68      get { return dict; }
69    }
70
71    public void ToggleSelected() {
72      selected = !selected;
73    }
74
75    public string GetToolTipText() {
76      StringBuilder b = new StringBuilder();
77      foreach (KeyValuePair<string, object> v in dict) {
78        if (v.Value is string || v.Value is double || v.Value is int) {
79          string val = v.Value.ToString();
80          if (val.Length > 40) val = val.Substring(0, 38) + "...";
81          b.Append(v.Key).Append(" = ").Append(val).AppendLine();
82        }
83      }
84      return b.ToString();
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.