Ejemplo n.º 1
0
 private static Vertex ConvertTextVertexToUIRVertex(TextVertex textVertex, Vector2 offset)
 {
     return(new Vertex
     {
         position = new Vector3(textVertex.position.x + offset.x, textVertex.position.y + offset.y, UIRUtility.k_MeshPosZ),
         uv = textVertex.uv0,
         tint = textVertex.color,
         idsFlags = new Color32(0, 0, 0, (byte)VertexFlags.IsText) // same flag for both text engines
     });
 }
Ejemplo n.º 2
0
 private static Vertex ConvertTextVertexToUIRVertex(TextVertex textVertex, Vector2 offset)
 {
     return(new Vertex
     {
         position = new Vector3(textVertex.position.x + offset.x, textVertex.position.y + offset.y, UIRUtility.k_MeshPosZ),
         uv = textVertex.uv0,
         tint = textVertex.color,
         flags = (float)VertexFlags.IsText
     });
 }
Ejemplo n.º 3
0
        // inspiré de https://en.wikipedia.org/wiki/Trie#Algorithms
        public void Insert(string str, string value)
        {
            CodePointIndexedString cpi = new CodePointIndexedString(str);
            IVertex node      = graph.SearchNode("")[0];
            int     i         = 0;
            int     stopIndex = cpi.Length - 1;

            while (i <= stopIndex)
            {
                IEdge link = GetLabeledEdge(node, cpi.AtIndex(i));
                if (link != null)
                {
                    node = link.GetLinkedObjects().Where(o => o.ObjectId != node.ObjectId).First() as IVertex;
                    if (i == stopIndex)
                    {
                        Annotation nodeValue = new Annotation()
                        {
                            Key = "id", Value = value
                        };
                        graph.AddAnnotation(node, nodeValue);
                    }
                    i++;
                }
                else
                {
                    break;
                }
            }

            while (i <= stopIndex)
            {
                string  currentChar = cpi.AtIndex(i);
                IVertex newNode     = new TextVertex(cpi.Substring(0, i + 1));
                graph.AddVertex(newNode);
                Annotation edgeLabel = new Annotation()
                {
                    Key = "label", Value = currentChar
                };
                IEdge edge = graph.CreateEdge(trieLink, node, newNode);
                graph.AddAnnotation(edge, edgeLabel);
                node = newNode;

                if (i == stopIndex)
                {
                    Annotation nodeValue = new Annotation()
                    {
                        Key = "id", Value = value
                    };
                    graph.AddAnnotation(node, nodeValue);
                }
                i++;
            }
        }
Ejemplo n.º 4
0
        public Trie()
        {
            TextVertex root = new TextVertex("");

            graph.AddVertex(root);
        }