Changeset 1385 for trunk/sources/HeuristicLab.Visualization/LabelProvider
- Timestamp:
- 03/21/09 10:07:16 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Visualization/LabelProvider
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/LabelProvider/ContinuousLabelProvider.cs
r1194 r1385 1 1 using System.Globalization; 2 using System.Xml; 2 3 3 4 namespace HeuristicLab.Visualization.LabelProvider { … … 14 15 return value.ToString(format, CultureInfo.InvariantCulture); 15 16 } 17 18 public XmlNode GetLabelProviderXmlNode() 19 { 20 XmlDocument Xdoc = new XmlDocument(); 21 22 XmlNode lblProvInfo = Xdoc.CreateNode(XmlNodeType.Element, "LabelProvider", null); 23 lblProvInfo.InnerText = "ContinuousLabelProvider"; 24 25 XmlAttribute idFormat = Xdoc.CreateAttribute("format"); 26 idFormat.Value = this.format; 27 28 lblProvInfo.Attributes.Append(idFormat); 29 30 return lblProvInfo; 31 } 32 33 public ILabelProvider PopulateLabelProviderXmlNode(XmlNode node) { 34 var labelProvider = new ContinuousLabelProvider(node.SelectSingleNode("//LabelProvider").Attributes[0].Value); 35 return labelProvider; 36 } 16 37 } 17 38 } -
trunk/sources/HeuristicLab.Visualization/LabelProvider/DiscreteLabelProvider.cs
r1194 r1385 1 1 using System; 2 using System.Xml; 2 3 3 4 namespace HeuristicLab.Visualization.LabelProvider { … … 12 13 return string.Empty; 13 14 } 15 16 public XmlNode GetLabelProviderXmlNode() 17 { 18 XmlDocument Xdoc = new XmlDocument(); 19 20 XmlNode lblProvInfo = Xdoc.CreateNode(XmlNodeType.Element, "LabelProvider", null); 21 lblProvInfo.InnerText = "DiscreteLabelProvider"; 22 23 return lblProvInfo; 24 } 25 26 public ILabelProvider PopulateLabelProviderXmlNode(XmlNode node) { 27 var labelProvider = new DiscreteLabelProvider(); 28 return labelProvider; 29 } 14 30 } 15 31 } -
trunk/sources/HeuristicLab.Visualization/LabelProvider/ILabelProvider.cs
r1194 r1385 1 using System.Xml; 2 1 3 namespace HeuristicLab.Visualization.LabelProvider { 2 4 public interface ILabelProvider { 3 5 string GetLabel(double value); 6 XmlNode GetLabelProviderXmlNode(); 7 ILabelProvider PopulateLabelProviderXmlNode(XmlNode node); 4 8 } 5 9 } -
trunk/sources/HeuristicLab.Visualization/LabelProvider/StringLabelProvider.cs
r1194 r1385 2 2 using System.Collections.Generic; 3 3 using HeuristicLab.Visualization.LabelProvider; 4 using System.Xml; 4 5 5 6 namespace HeuristicLab.Visualization.LabelProvider { … … 26 27 return string.Empty; 27 28 } 29 30 public XmlNode GetLabelProviderXmlNode() { 31 XmlDocument Xdoc = new XmlDocument(); 32 33 XmlNode lblProvInfo = Xdoc.CreateNode(XmlNodeType.Element, "LabelProvider", null); 34 lblProvInfo.InnerText = "StringLabelProvider"; 35 36 foreach (KeyValuePair<int, string> pair in labels) 37 { 38 XmlNode strLbl = Xdoc.CreateNode(XmlNodeType.Element, "String", null); 39 40 XmlAttribute idStrLbl = Xdoc.CreateAttribute("id"); 41 idStrLbl.Value = pair.Key.ToString(); 42 strLbl.Attributes.Append(idStrLbl); 43 44 strLbl.InnerText = pair.Value; 45 lblProvInfo.AppendChild(strLbl); 46 } 47 return lblProvInfo; 48 } 49 50 public ILabelProvider PopulateLabelProviderXmlNode(XmlNode node) { 51 var labelProvider = new StringLabelProvider(); 52 53 foreach (XmlNode strLbl in node.SelectNodes("//String")) 54 { 55 labelProvider.SetLabel(int.Parse(strLbl.Attributes[0].Value), strLbl.InnerText); 56 } 57 return labelProvider; 58 } 28 59 } 29 60 }
Note: See TracChangeset
for help on using the changeset viewer.