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; }
public void AddNode(ScriptableNodeMapData scriptableNode) { NodeMapData objNode = ScriptableMapper.GetNode(scriptableNode); GraphComponents graphComponents = GraphManager.Instance.DefaultGraphComponentsInstance; MappingExtensions.AddNode(graphComponents, CreationType.Live, objNode); }
/// <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; }