예제 #1
0
        private static SourceCodeEntitiesFile getSourceFileByGaze(GazeData gd,
                                                                  SourceCodeEntitiesFileCollection scefc)
        {
            SourceCodeEntitiesFile scef = null;

            foreach (SourceCodeEntitiesFile cur_scef in scefc)
            {
                if (gd.filename == cur_scef.FileName)
                {
                    scef = cur_scef;
                    break;
                }
            }
            return(scef);
        }
예제 #2
0
 private static bool isInEntity(GazeData gd, SourceCodeEntity sce)
 {
     if (gd.line > sce.LineStart && gd.line < sce.LineEnd)
     {
         return(true);
     }
     else if (gd.line == sce.LineStart)
     {
         return(gd.col >= sce.ColumnStart);
     }
     else if (gd.line == sce.LineEnd)
     {
         return(gd.col <= sce.ColumnEnd);
     }
     else
     {
         return(false);
     }
 }
예제 #3
0
        private static GazeResults runSingle(string in_filename)
        {
            XmlDocument         document    = new XmlDocument();
            List <GazeData>     gazes       = new List <GazeData>();
            TrackingEnvironment environment = new TrackingEnvironment();
            //bool isFirstGaze = true;
            double firstTimestamp = 0;
            double lastTimestamp  = 0;

            try
            {
                document.Load(in_filename);
                XPathNavigator    navigator = document.CreateNavigator();
                XPathNodeIterator iterator  = (XPathNodeIterator)
                                              navigator.Evaluate("itrace-records/environment/*");
                while (iterator.MoveNext())
                {
                    XPathNavigator element = iterator.Current;
                    switch (element.Name)
                    {
                    case "screen-size":
                        string width  = element.GetAttribute("width", "");
                        string height = element.GetAttribute("height", "");
                        if (width != String.Empty && height != String.Empty)
                        {
                            environment.screen_width  = Convert.ToInt32(width);
                            environment.screen_height = Convert.ToInt32(height);
                        }
                        break;

                    case "line-height":
                        string line_height = element.Value;
                        if (line_height != String.Empty)
                        {
                            environment.line_height = Convert.ToInt32(line_height);
                        }
                        break;

                    case "font-height":
                        string font_height = element.Value;
                        if (font_height != String.Empty)
                        {
                            environment.font_height = Convert.ToInt32(font_height);
                        }
                        break;
                    }
                }
                iterator = (XPathNodeIterator)
                           navigator.Evaluate("itrace-records/gazes/response");
                while (iterator.MoveNext())
                {
                    XPathNavigator element          = iterator.Current;
                    String         filename         = element.GetAttribute("file", "");
                    String         line             = element.GetAttribute("line", "");
                    String         col              = element.GetAttribute("col", "");
                    String         x                = element.GetAttribute("x", "");
                    String         y                = element.GetAttribute("y", "");
                    String         timestamp        = element.GetAttribute("timestamp", "");
                    String         left_validation  = element.GetAttribute("left-validation", "");
                    String         right_validation =
                        element.GetAttribute("right-validation", "");
                    if (filename != String.Empty && line != String.Empty &&
                        col != String.Empty && x != String.Empty && y != String.Empty &&
                        timestamp != String.Empty && left_validation != String.Empty &&
                        right_validation != String.Empty)
                    {
                        GazeData gaze_data = new GazeData();
                        gaze_data.filename = filename;
                        gaze_data.line     = Convert.ToInt32(line);
                        gaze_data.col      = Convert.ToInt32(col);
                        gaze_data.x        = Convert.ToInt32(x);
                        gaze_data.y        = Convert.ToInt32(y);
                        //set start time to zero by subtracting off the first timestamp from each gaze

                        /*
                         * if (isFirstGaze)
                         * {
                         *      firstTimestamp = Convert.ToDecimal(timestamp);
                         *      isFirstGaze = false;
                         * }
                         */
                        gaze_data.timestamp        = Convert.ToDouble(timestamp) - firstTimestamp;
                        gaze_data.left_validation  = Convert.ToDouble(left_validation);
                        gaze_data.right_validation = Convert.ToDouble(right_validation);
                        gazes.Add(gaze_data);
                    }
                }
                //normalize timestamp data
                firstTimestamp = gazes[0].timestamp;
                lastTimestamp  = gazes[gazes.Count - 1].timestamp;
                //Console.WriteLine(firstTimestamp);
                //Console.WriteLine(lastTimestamp);
                for (int i = 0; i < gazes.Count; i++)
                {
                    gazes[i].timestamp = (gazes[i].timestamp - firstTimestamp) / (lastTimestamp - firstTimestamp);
                    //Console.WriteLine(gazes[i].timestamp);
                }
                return(new GazeResults(gazes, environment));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #4
0
 private static GazeResults runSingle(string in_filename)
 {
     XmlDocument document = new XmlDocument();
       List<GazeData> gazes = new List<GazeData>();
       TrackingEnvironment environment = new TrackingEnvironment();
       //bool isFirstGaze = true;
       double firstTimestamp = 0;
       double lastTimestamp = 0;
       try
       {
     document.Load(in_filename);
     XPathNavigator navigator = document.CreateNavigator();
     XPathNodeIterator iterator = (XPathNodeIterator)
       navigator.Evaluate("itrace-records/environment/*");
     while (iterator.MoveNext())
     {
       XPathNavigator element = iterator.Current;
       switch (element.Name)
       {
     case "screen-size":
       string width = element.GetAttribute("width", "");
       string height = element.GetAttribute("height", "");
       if (width != String.Empty && height != String.Empty)
       {
         environment.screen_width = Convert.ToInt32(width);
         environment.screen_height = Convert.ToInt32(height);
       }
       break;
     case "line-height":
       string line_height = element.Value;
       if (line_height != String.Empty)
         environment.line_height = Convert.ToInt32(line_height);
       break;
     case "font-height":
       string font_height = element.Value;
       if (font_height != String.Empty)
         environment.font_height = Convert.ToInt32(font_height);
       break;
       }
     }
     iterator = (XPathNodeIterator)
       navigator.Evaluate("itrace-records/gazes/response");
     while (iterator.MoveNext())
     {
       XPathNavigator element = iterator.Current;
       String filename = element.GetAttribute("file", "");
       String line = element.GetAttribute("line", "");
       String col = element.GetAttribute("col", "");
       String x = element.GetAttribute("x", "");
       String y = element.GetAttribute("y", "");
       String timestamp = element.GetAttribute("timestamp", "");
       String left_validation = element.GetAttribute("left-validation", "");
       String right_validation =
     element.GetAttribute("right-validation", "");
       if (filename != String.Empty && line != String.Empty &&
     col != String.Empty && x != String.Empty && y != String.Empty &&
     timestamp != String.Empty && left_validation != String.Empty &&
     right_validation != String.Empty)
       {
     GazeData gaze_data = new GazeData();
     gaze_data.filename = filename;
     gaze_data.line = Convert.ToInt32(line);
     gaze_data.col = Convert.ToInt32(col);
     gaze_data.x = Convert.ToInt32(x);
     gaze_data.y = Convert.ToInt32(y);
     //set start time to zero by subtracting off the first timestamp from each gaze
     /*
     if (isFirstGaze)
     {
         firstTimestamp = Convert.ToDecimal(timestamp);
         isFirstGaze = false;
     }
     */
     gaze_data.timestamp = Convert.ToDouble(timestamp) - firstTimestamp;
     gaze_data.left_validation = Convert.ToDouble(left_validation);
     gaze_data.right_validation = Convert.ToDouble(right_validation);
     gazes.Add(gaze_data);
       }
     }
     //normalize timestamp data
     firstTimestamp = gazes[0].timestamp;
     lastTimestamp = gazes[gazes.Count - 1].timestamp;
     //Console.WriteLine(firstTimestamp);
     //Console.WriteLine(lastTimestamp);
     for (int i = 0; i < gazes.Count; i++)
     {
     gazes[i].timestamp = ( gazes[i].timestamp - firstTimestamp ) / ( lastTimestamp - firstTimestamp );
     //Console.WriteLine(gazes[i].timestamp);
     }
     return new GazeResults(gazes, environment);
       }
       catch (Exception e)
       {
     throw e;
       }
 }