Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 846 was 761, checked in by mstoeger, 16 years ago

changed interface between model and view (#316)

File size: 5.1 KB
RevLine 
[680]1using System;
2using System.Collections.Generic;
[726]3using System.Xml;
4using HeuristicLab.Core;
[680]5
[685]6namespace HeuristicLab.Visualization{
[761]7  public delegate void DataRowAddedHandler(IDataRow row);
8  public delegate void DataRowRemovedHandler(IDataRow row);
[685]9
[761]10  public delegate void ModelChangedHandler();
[685]11
[761]12  public class ChartDataRowsModel : ChartDataModelBase, IChartDataRowsModel {
13    private string title;
14    private string xAxisLabel;
15    private string yAxisLabel;
[726]16
[761]17    public void AddLabel(string label) {
18      throw new NotImplementedException();
19      // TODO ModelChangedEvent auslösen
20    }
[726]21
[761]22    public void AddLabel(string label, int index) {
23      throw new NotImplementedException();
24      // TODO ModelChangedEvent auslösen
[685]25    }
26
[761]27    public void AddLabels(string[] labels) {
28      throw new NotImplementedException();
29      // TODO ModelChangedEvent auslösen
30    }
[685]31
[761]32    public void AddLabels(string[] labels, int index) {
33      throw new NotImplementedException();
34      // TODO ModelChangedEvent auslösen
35    }
[726]36
[761]37    public void ModifyLabel(string label, int index) {
38      throw new NotImplementedException();
39      // TODO ModelChangedEvent auslösen
40    }
[726]41
[761]42    public void ModifyLabels(string[] labels, int index) {
43      throw new NotImplementedException();
44      // TODO ModelChangedEvent auslösen
[685]45    }
46
[761]47    public void RemoveLabel(int index) {
48      throw new NotImplementedException();
49      // TODO ModelChangedEvent auslösen
50    }
[685]51
[761]52    public void RemoveLabels(int index, int count) {
53      throw new NotImplementedException();
54      // TODO ModelChangedEvent auslösen
55    }
[727]56
[761]57    public string Title {
58      get { return title; }
59      set {
60        title = value;
61        OnModelChanged();
[728]62      }
[761]63    }
[728]64
[761]65    public string XAxisLabel {
66      get { return xAxisLabel; }
67      set {
68        xAxisLabel = value;
69        OnModelChanged();
70      }
[685]71    }
72
[761]73    public string YAxisLabel {
74      get { return yAxisLabel; }
75      set {
76        yAxisLabel = value;
77        OnModelChanged();
78      }
[726]79    }
80
[761]81    public event ModelChangedHandler ModelChanged;
[697]82
[761]83    protected void OnModelChanged() {
84      if (ModelChanged != null) {
85        ModelChanged();
[697]86      }
87    }
88
[761]89    private readonly List<IDataRow> rows = new List<IDataRow>();
90   
91    public static IDataRow CreateDataRow() {
92      throw new NotImplementedException();
93    }
[726]94
[761]95    public void AddDataRow(IDataRow row) {
96      rows.Add(row);
97      OnDataRowAdded(row);
[697]98    }
[726]99
[761]100    public void RemoveDataRow(IDataRow row) {
101      rows.Remove(row);
102      OnDataRowRemoved(row);
103    }
[726]104
[761]105    public event DataRowAddedHandler DataRowAdded;
[726]106
[761]107    protected void OnDataRowAdded(IDataRow row) {
108      if (DataRowAdded != null) {
109        DataRowAdded(row);
110      }
111    }
[726]112
[761]113    public event DataRowRemovedHandler DataRowRemoved;
[727]114
[761]115    protected void OnDataRowRemoved(IDataRow row) {
116      if (DataRowRemoved != null) {
117        DataRowRemoved(row);
[726]118      }
[761]119    }
[726]120
[761]121    public override IView CreateView() {
122      return new LineChart(this); //when LineChart is implemented
[726]123    }
124
[761]125    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
126      throw new NotImplementedException();
[726]127
[761]128//      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
129//
130//      foreach (ChartDataRowsModelColumn column in Columns){
131//        XmlNode columnElement = document.CreateNode(XmlNodeType.Element, "column", null);
132//
133//        XmlAttribute idAttr = document.CreateAttribute("id");
134//        idAttr.Value = (column.ColumnId).ToString();
135//        columnElement.Attributes.Append(idAttr);
136//
137//        for (int i = 0; i < column.Values.Length; i++){
138//          if (i == 0){
139//            columnElement.InnerText += column.Values[i].ToString(CultureInfo.InvariantCulture.NumberFormat);
140//          } else{
141//            columnElement.InnerText += ";" + column.Values[i].ToString(CultureInfo.InvariantCulture.NumberFormat);
142//          }
143//        }
144//        node.AppendChild(columnElement);
145//      }
146//     
147//      return node;
148    }
149
150
[731]151   
[726]152    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
[761]153      throw new NotImplementedException();
[731]154
[761]155//      base.Populate(node, restoredObjects);
156//
157//      foreach (XmlNode column in node.ChildNodes){
158//        XmlAttributeCollection attrs = column.Attributes;
159//        XmlAttribute rowIdAttr = (XmlAttribute)attrs.GetNamedItem("id");
160//        int rowId = int.Parse(rowIdAttr.Value);
161//        AddDataRow(rowId);
162//        string[] tokens = column.InnerText.Split(';');
163//        double[] data = new double[tokens.Length];
164//        for (int i = 0; i < data.Length; i++){
165//          if (tokens[i].Length != 0){
166//            if (
167//              double.TryParse(tokens[i], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out data[i]) ==
168//              false){
169//              throw new FormatException("Can't parse " + tokens[i] + " as double value.");
170//            }
171//          }
172//        }
173//        Columns[rowId-1].Values = data;
174//      }
[726]175    }
[680]176  }
[761]177}
Note: See TracBrowser for help on using the repository browser.