Esempio n. 1
0
 //Get the nodes corresponding to the following strokes
 public Nodes getNodes(Strokes strokes)
 {
     Nodes found = new Nodes();
     for(int i=0; i<strokes.Count; i++)
     {
         Node a = getNode(strokes[i]);
         if(a != null)
         {
             found.Add(a);
         }
     }
     return found;
 }
Esempio n. 2
0
        /* Determines whether the following stroke could be interpreted as
         * an edge (or edges) and if so, returns all the consecutive nodes that the
         * stroke has gone through in order.
         */
        public static Nodes ifEdgeGetNodes(Stroke s, Graph g)
        {
            Point[] sPoints = s.GetPoints();
            Nodes strokeHitNodes = new Nodes();
            Node prev = null;
            for(int i=0; i<sPoints.Length; i++)
            {
                for(int j=0; j<g.Nodes.Length(); j++)
                {
                    Node n = g.Nodes[j];
                    Rectangle r = n.Stroke.GetBoundingBox();

                    if(s.HitTest(n.CenterPoint,Math.Max(r.Width/2, r.Height/2)) && r.Contains(sPoints[i]) && !n.Equals(prev))
                    {
                        strokeHitNodes.Add(n);
                        prev = n;
                        break;
                    }
                }
            }
            //If stroke hit one or less nodes, it is clearly not an edge.
            if(strokeHitNodes.Length() < 2)
            {
                return null;
            }
            return strokeHitNodes;
        }