public static NodeMapData GetNode(ScriptableNodeMapData scriptableNode) { NodeMapData node; if (scriptableNode is ScriptableIconNodeMapData) { ScriptableIconNodeMapData scriptableIconNode = (ScriptableIconNodeMapData)scriptableNode; IconNodeMapData iconNode = new IconNodeMapData(scriptableIconNode.Id); if (!String.IsNullOrEmpty(scriptableIconNode.ImageSource)) { Uri imageSourceUri = new Uri(scriptableIconNode.ImageSource); iconNode.ImageSource = imageSourceUri; } node = iconNode; } else { node = new TextNodeMapData(scriptableNode.Id); } // Properties node.Description = scriptableNode.Description; node.Label = scriptableNode.Label; node.Dimension = GetDimension(scriptableNode.Dimension); node.Position = GetPosition(scriptableNode.Position); node.IsHidden = scriptableNode.IsHidden; node.BackgroundColor = GetColor(scriptableNode.BackgroundColor); node.SelectionColor = GetColor(scriptableNode.SelectionColor); // Attributes foreach (KeyValuePair <string, ScriptableAttributeMapData> kvp in scriptableNode.Attributes) { ScriptableAttributeMapData scriptableAttribute = kvp.Value; AttributeMapData attribute = new AttributeMapData(scriptableAttribute.Name, scriptableAttribute.Value); attribute.SemanticType = (SemanticType)scriptableAttribute.SemanticType; attribute.SimilarityMeasure = scriptableAttribute.SimilarityMeasure; attribute.IsHidden = scriptableAttribute.IsHidden; node.Attributes.Add(kvp.Key, attribute); } return(node); }
/// <summary> /// Maps a <see cref="ScriptableNodeMapData"/> object from a <see cref="NodeMapData"/> object /// </summary> /// <param name="node">The <see cref="NodeMapData"/> object to map from</param> /// <returns>A <see cref="ScriptableNodeMapData"/> object mapped from from a <see cref="NodeMapData"/> object</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="node"/> is null</exception> public static ScriptableNodeMapData GetNode(NodeMapData node) { if (node == null) { throw new ArgumentNullException("node"); } ScriptableNodeMapData scriptableNode = new ScriptableNodeMapData { BackgroundColor = node.BackgroundColor.ToString(), Description = node.Description, Dimension = new ScriptableSize(node.Dimension.Height, node.Dimension.Width), Id = node.Id, IsHidden = node.IsHidden, Label = node.Label, Position = new ScriptablePoint(node.Position.X, node.Position.Y), SelectionColor = node.SelectionColor.ToString() }; foreach (KeyValuePair <string, AttributeMapData> kvp in node.Attributes) { AttributeMapData attributeMapData = kvp.Value; ScriptableAttributeMapData scriptableAttributeData = new ScriptableAttributeMapData { IsHidden = attributeMapData.IsHidden, Name = attributeMapData.Name, SemanticType = (int)attributeMapData.SemanticType, SimilarityMeasure = attributeMapData.SimilarityMeasure, Value = attributeMapData.Value }; scriptableNode.Attributes.Add(kvp.Key, scriptableAttributeData); } return(scriptableNode); }
public static EdgeMapData GetEdge(ScriptableEdgeMapData scriptableEdge) { EdgeMapData edge = new EdgeMapData(scriptableEdge.Source, scriptableEdge.Target); // Properties edge.Type = (EdgeType)Enum.Parse(typeof(EdgeType), scriptableEdge.Type, false); edge.Thickness = scriptableEdge.Thickness; edge.Color = GetColor(scriptableEdge.Color); edge.Label = scriptableEdge.Label; edge.IsLabelTextUnderlined = scriptableEdge.IsLabelTextUnderlined; edge.LabelBackgroundColor = GetColor(scriptableEdge.LabelBackgroundColor); edge.LabelForegroundColor = GetColor(scriptableEdge.LabelForegroundColor); edge.LabelFontStyle = GetFontStyle(scriptableEdge.LabelFontStyle); edge.LabelFontWeight = GetFontWeight(scriptableEdge.LabelFontWeight); if (!String.IsNullOrEmpty(scriptableEdge.LabelFont)) { FontFamily fontFamily = new FontFamily(scriptableEdge.LabelFont); edge.LabelFont = fontFamily; } edge.Weight = scriptableEdge.Weight; // Attributes foreach (KeyValuePair <string, ScriptableAttributeMapData> kvp in scriptableEdge.Attributes) { ScriptableAttributeMapData scriptableAttribute = kvp.Value; AttributeMapData attribute = new AttributeMapData(scriptableAttribute.Name, scriptableAttribute.Value); attribute.SemanticType = (SemanticType)scriptableAttribute.SemanticType; attribute.SimilarityMeasure = scriptableAttribute.SimilarityMeasure; attribute.IsHidden = scriptableAttribute.IsHidden; edge.Attributes.Add(kvp.Key, attribute); } return(edge); }