Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/27/14 16:33:17 (10 years ago)
Author:
bburlacu
Message:

#1772: Adjusted namespace in Plugin.cs.frame for HeuristicLab.EvolutionTracking.Views. Simplified DirectedGraph and GenealogyGraph API. Added public events for the Vertex content (so that the graph itself can be notified when the content changes and can adjust it's content-to-vertex map. Adjusted instrumented operators code to reflect api changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/DirectedGraph/Vertex.cs

    r10890 r10897  
    3030  [StorableClass]
    3131  public class Vertex : Item, IVertex {
     32    public event EventHandler PreContentChanged;
     33    protected virtual void OnPreContentChanged(object sender, EventArgs args) {
     34      var changed = PreContentChanged;
     35      if (changed != null) {
     36        changed(sender, args);
     37      }
     38    }
     39
     40    public event EventHandler PostContentChanged;
     41    protected virtual void OnPostContentChanged(object sender, EventArgs args) {
     42      var changed = PostContentChanged;
     43      if (changed != null) {
     44        changed(sender, args);
     45      }
     46    }
     47
    3248    [Storable]
    3349    private string id;
     50
    3451    public string Id {
    3552      get { return id; }
    36       set { id = value; }
    3753    }
     54
    3855    [Storable]
    39     private string label;
    40     public string Label { get { return label; } set { label = value; } }
     56    public string Label { get; set; }
     57
    4158    [Storable]
    42     private double weight;
    43     public double Weight { get { return weight; } set { weight = value; } }
     59    public double Weight { get; set; }
     60
     61    [Storable]
     62    protected object content;
     63    public object Content {
     64      get { return content; }
     65      set {
     66        OnPreContentChanged(this, EventArgs.Empty);
     67        content = value;
     68        OnPostContentChanged(this, EventArgs.Empty);
     69      }
     70    }
     71
    4472    [Storable]
    4573    private List<IArc> inArcs;
     
    4876      set { inArcs = value.ToList(); }
    4977    }
     78
    5079    [Storable]
    5180    private List<IArc> outArcs;
     
    5483      set { outArcs = value.ToList(); }
    5584    }
    56     [Storable]
    57     public object Content { get; set; }
    5885
    5986    [StorableConstructor]
     
    6491    }
    6592
     93    public Vertex(object content)
     94      : this() {
     95      this.content = content;
     96    }
     97
    6698    protected Vertex(Vertex original, Cloner cloner)
    6799      : base(original, cloner) {
    68       Id = Guid.NewGuid().ToString();
     100      id = Guid.NewGuid().ToString();
     101      content = original.content;
    69102      Label = original.Label;
     103      Weight = original.Weight;
    70104      inArcs = new List<IArc>(original.inArcs);
    71105      outArcs = new List<IArc>(original.outArcs);
     
    79113    protected void AfterDeserialization() {
    80114      if (Id == null) {
    81         Id = Guid.NewGuid().ToString();
     115        id = Guid.NewGuid().ToString();
    82116      }
    83117    }
     
    117151    protected Vertex(Vertex<T> original, Cloner cloner)
    118152      : base(original, cloner) {
    119       Content = original.Content; // not sure if to Clone()
    120153    }
    121154
Note: See TracChangeset for help on using the changeset viewer.