Exemplo n.º 1
0
    public CleanSceneData.ImportDataStructure CosmosDBStructure_TO_ImportDataStructure(GraphsonToGremlin.CosmosDbStructure data)
    {
        CleanSceneData.ImportDataStructure newStructure = new CleanSceneData.ImportDataStructure();

        newStructure.vertices = new List <CleanSceneData.Vertex>();
        newStructure.edges    = new List <CleanSceneData.Edge>();

        if (data.vertices != null && data.vertices.Any())
        {
            foreach (GraphsonToGremlin.Vertex v in data.vertices)
            {
                CleanSceneData.Vertex newV = BridgeToGraphson.ConvertGraphVertexToSceneNode(v);
                newStructure.vertices.Add(newV);
            }
        }

        if (data.edges != null && data.edges.Any())
        {
            foreach (GraphsonToGremlin.Edge e in data.edges)
            {
                CleanSceneData.Edge newE = BridgeToGraphson.ConvertGraphEdgeToSceneEdge(e);

                newStructure.edges.Add(newE);
            }
        }
        return(newStructure);
    }
Exemplo n.º 2
0
    public static CleanSceneData.Vertex ConvertGraphVertexToSceneNode(GraphsonToGremlin.Vertex graphV)
    {
        CleanSceneData.Vertex sceneV = new CleanSceneData.Vertex();

        sceneV.color = UnityEngine.Color.white;
        sceneV.label = graphV.label;
        sceneV.type  = graphV.type;
        sceneV.x     = UnityEngine.Random.Range(-100, 100);
        sceneV.y     = UnityEngine.Random.Range(-100, 100);

        sceneV.instanceID = graphV.id;

        //newV.connections[0].

        sceneV.properties = new Dictionary <string, string>();
        foreach (GraphsonToGremlin.Property p in graphV.property.properties)
        {
            sceneV.properties.Add(p.propertyNames, p.value);
        }

        return(sceneV);
    }
Exemplo n.º 3
0
    public void GenerateScene(CleanSceneData.ImportDataStructure data)
    {
        if (data == null)
        {
            return;
        }

        Dictionary <string, GameObject> nodesToInstanceID = new Dictionary <string, GameObject>();

        if (data.vertices.Any())
        {
            // Iterate through all vertices
            for (int i = 0; i < data.vertices.Count; i++)
            {
                CleanSceneData.Vertex v = data.vertices[i];

                GameObject nodeObj = em.CreateNode(new Vector2(v.x, v.y));
                Node       n       = nodeObj.GetComponent <Node>();

                n.label          = v.label;
                n.propertiesDict = v.properties;
                n.x     = v.x;
                n.y     = v.y;
                n.color = v.color;

                n.SetVisualLabel();
                n.ShowDialogBubble();

                n.ShowNodeColor();

                bool status = int.TryParse(v.instanceID, out n.instanceID);
                nodesToInstanceID.Add(v.instanceID, nodeObj);
            }
        }

        if (data.edges.Any())
        {
            // Iterate through all edges
            for (int i = 0; i < data.edges.Count; i++)
            {
                CleanSceneData.Edge e = data.edges[i];

                if (nodesToInstanceID.ContainsKey(e.fromInstanceID) && nodesToInstanceID.ContainsKey(e.toInstanceID))
                {
                    GameObject nodeFrom = nodesToInstanceID[e.fromInstanceID];
                    GameObject nodeTo   = nodesToInstanceID[e.toInstanceID];

                    LineRenderer line     = em.CreateEdge(nodeFrom, nodeTo);
                    Connect      lineData = line.GetComponent <Connect>();
                    lineData.from           = nodeFrom;
                    lineData.to             = nodeTo;
                    lineData.label          = e.label;
                    lineData.propertiesDict = e.properties;

                    em.UpdateNewEdge(line, nodeFrom, nodeTo);
                }
                else
                {
                    print("Could not find instance id for the objects connected to this edge");
                }
            }
        }
    }