Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/ChartDataRowsModel.cs @ 929

Last change on this file since 929 was 864, checked in by cbahner, 16 years ago

#318 implemented interfaces + new datarowdummy model

File size: 3.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Globalization;
4using System.Xml;
5using HeuristicLab.Core;
6
7namespace HeuristicLab.Visualization{
8  public delegate void DataRowAddedHandler(IDataRow row);
9  public delegate void DataRowRemovedHandler(IDataRow row);
10  public delegate void ModelChangedHandler();
11
12  public class ChartDataRowsModel : ChartDataModelBase, IChartDataRowsModel{
13    private string title;
14    private string xAxisLabel;
15
16    private readonly List<IDataRow> rows = new List<IDataRow>();
17    private readonly List<string> xLabels = new List<string>();
18
19    public List<string> XLabels{
20      get { return xLabels; }
21    }
22
23    public List<IDataRow> Rows{
24      get { return rows; }
25    }
26
27    public string Title {
28      get { return title; }
29      set {
30        title = value;
31        OnModelChanged();
32      }
33    }
34    public string XAxisLabel {
35      get { return xAxisLabel; }
36      set {
37        xAxisLabel = value;
38        OnModelChanged();
39      }
40    }
41
42    public override IView CreateView() {
43      return new LineChart(this);
44    }
45
46    public void AddLabel(string label) {
47      xLabels.Add(label);
48      OnModelChanged();
49    }
50
51    public void AddLabel(string label, int index) {
52      xLabels[index] = label;
53      OnModelChanged();
54    }
55
56    public void AddLabels(string[] labels) {
57      foreach (var s in labels){
58        AddLabel(s);
59      }
60      //OnModelChanged();
61    }
62
63    public void AddLabels(string[] labels, int index) {
64      int i = 0;
65      foreach (var s in labels){
66        AddLabel(s, index + i);
67        i++;
68      }
69      //OnModelChanged();
70    }
71
72    public void ModifyLabel(string label, int index) {
73      xLabels[index] = label;
74      OnModelChanged();
75    }
76
77    public void ModifyLabels(string[] labels, int index) {
78      int i = 0;
79      foreach (var s in labels){
80        ModifyLabel(s, index + i);
81        i++;
82      }
83      //OnModelChanged();
84    }
85
86    public void RemoveLabel(int index) {
87      xLabels.RemoveAt(index);
88      OnModelChanged();
89    }
90
91    public void RemoveLabels(int index, int count) {
92      for (int i = index; i < index + count; i++ ){
93        RemoveLabel(i);
94      }
95      //OnModelChanged();
96    }
97
98    public void AddDataRow(IDataRow row) {
99      rows.Add(row);
100      OnDataRowAdded(row);
101    }
102
103    public void RemoveDataRow(IDataRow row) {
104      rows.Remove(row);
105      OnDataRowRemoved(row);
106    }
107
108    public event ModelChangedHandler ModelChanged;
109
110    protected void OnModelChanged() {
111      if (ModelChanged != null) {
112        ModelChanged();
113      }
114    }
115
116    public event DataRowAddedHandler DataRowAdded;
117
118    protected void OnDataRowAdded(IDataRow row) {
119      if (DataRowAdded != null) {
120        DataRowAdded(row);
121      }
122    }
123
124    public event DataRowRemovedHandler DataRowRemoved;
125
126    protected void OnDataRowRemoved(IDataRow row) {
127      if (DataRowRemoved != null) {
128        DataRowRemoved(row);
129      }
130    }
131
132    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
133      throw new NotImplementedException();
134     
135    }
136
137    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
138      throw new NotImplementedException();
139
140    }
141  }
142}
Note: See TracBrowser for help on using the repository browser.