/// <summary>
        /// Change tree depth
        /// </summary>
        /// <param name="depth"></param>
        /// <param name="method"></param>
        private void ChangeDepth(int depth, AnswerSheetAnalyzer.ClassificationFeature method)
        {
            this.answerGroupDataList.Clear();
            List<AnswerSheetGroup> ansGroupList = null;
            switch (method)
            {
                case AnswerSheetAnalyzer.ClassificationFeature.Proposed:
                    ansGroupList = this.analyzer.HierarchicalResult.GetGroupedAnswerSheets(depth);
                    break;
                case AnswerSheetAnalyzer.ClassificationFeature.AnswerTime:
                    ansGroupList = this.analyzer.HierarchicalResultAnswerTime.GetGroupedAnswerSheets(depth);
                    break;
            }
            foreach (AnswerSheetGroup g in ansGroupList)
            {
                this.answerGroupDataList.Add(new AnswerGroupItemData(g, this.visualizer, this));
            }

            // sort group by average answer time
            this.answerGroupDataList = new ObservableCollection<AnswerGroupItemData>(this.answerGroupDataList.OrderBy(n => n.AnswerGroupData.GetAverageAnswerTime()));

            this.GroupedAnswerSheetControl.ItemsSource = this.answerGroupDataList;
            this.cbDepth.SelectedIndex = depth;

            // show answer time heatmap
            SetAnswerTimeHeatmap();
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            this.analyzer = new AnswerSheetAnalyzer();
            this.visualizer = new AnswerSheetVisualizer(analyzer);
        }
 /// <summary>
 /// Initialization with the result
 /// </summary>
 /// <param name="analysis"></param>
 /// <param name="c"></param>
 public AnswerGroupWindow(AnswerSheetAnalyzer a, AnswerSheetVisualizer v)
     : this()
 {
     this.analyzer = a;
     this.visualizer = v;
     this.currentMethod = AnswerSheetAnalyzer.ClassificationFeature.Proposed;
     ChangeMethod(this.currentMethod);
 }
        /// <summary>
        /// Initialization with analyzer
        /// </summary>
        /// <param name="analysis"></param>
        public StrokeComparisonWindow(AnswerSheetAnalyzer a)
            : this()
        {
            this.analyzer = a;

            List<StrokeComparisonResult> results = this.analyzer.GetVisualizedStrokeComparisonExamples();
            foreach (StrokeComparisonResult res in results)
            {
                StrokeComparisonItemData item = new StrokeComparisonItemData();

                // draw stroke
                double scale = 0.0;
                Rect s1bb = res.Stroke1.BoundingBox;
                Rect s2bb = res.Stroke2.BoundingBox;
                double maxSize = (new double[] { s1bb.Width, s1bb.Height, s2bb.Width, s2bb.Height }).Max();
                scale = Config.OutputStrokeCanvasSize / maxSize;
                Point s1offset = new Point((Config.OutputStrokeCanvasSize / scale - s1bb.Width) / 2.0, (Config.OutputStrokeCanvasSize / scale - s1bb.Height) / 2.0);
                Point s2offset = new Point((Config.OutputStrokeCanvasSize / scale - s2bb.Width) / 2.0, (Config.OutputStrokeCanvasSize / scale - s2bb.Height) / 2.0);

                item.Strokes1.Add(res.Stroke1.GetStrokeObject(scale: scale, offset: s1offset, isOrigin: true));
                item.Strokes2.Add(res.Stroke2.GetStrokeObject(scale: scale, offset: s2offset, isOrigin: true));
                
                // draw sampled coordinates
                item.ResultCanvasCollection = new ObservableCollection<UIElement>();
                Stroke ss1 = res.SampledStroke1.GetStrokeObject(scale: scale, offset: s1offset, isOrigin: true);
                Stroke ss2 = res.SampledStroke2.GetStrokeObject(scale: scale, offset: s2offset, isOrigin: true);
                foreach (StylusPoint p in ss1.StylusPoints)
                {
                    Ellipse e = new Ellipse();
                    e.StrokeThickness = 0.0;
                    e.Fill = Brushes.Blue;
                    e.Width = 5.0;
                    e.Height = 5.0;
                    Canvas.SetLeft(e, p.X - (e.Width / 2.0));
                    Canvas.SetTop(e, p.Y - (e.Height / 2.0));
                    item.ResultCanvasCollection.Add(e);
                }
                foreach (StylusPoint p in ss2.StylusPoints)
                {
                    Ellipse e = new Ellipse();
                    e.StrokeThickness = 0.0;
                    e.Fill = Brushes.Blue;
                    e.Width = 5.0;
                    e.Height = 5.0;
                    Canvas.SetLeft(e, p.X - (e.Width / 2.0) + Config.OutputStrokeCanvasSize);
                    Canvas.SetTop(e, p.Y - (e.Height / 2.0));
                    item.ResultCanvasCollection.Add(e);
                }

                // visualize matching results
                for (int i = 0, ilen = res.Results.MatchingList.Count; i < ilen; i++)
                {
                    List<int[]> matchings = res.Results.MatchingList;
                    if (matchings[i][0] != -1 && matchings[i][1] != -1)
                    {
                        // draw matching connector
                        Line l = new Line();
                        l.Stroke = Brushes.Red;
                        l.StrokeThickness = 1;
                        l.X1 = ss1.StylusPoints[matchings[i][0]].X;
                        l.Y1 = ss1.StylusPoints[matchings[i][0]].Y;
                        l.X2 = ss2.StylusPoints[matchings[i][1]].X + Config.OutputStrokeCanvasSize;
                        l.Y2 = ss2.StylusPoints[matchings[i][1]].Y;
                        l.HorizontalAlignment = HorizontalAlignment.Left;
                        l.VerticalAlignment = VerticalAlignment.Center;
                        item.ResultCanvasCollection.Add(l);
                    }
                }

                // similarity score
                item.DistanceScore = res.Results.Distance;
                ContentControl totalDistanceContent = new ContentControl();
                Canvas.SetLeft(totalDistanceContent, 0.0);
                Canvas.SetTop(totalDistanceContent, 0.0);
                TextBlock txtBlock = new TextBlock();
                txtBlock.Text = res.Results.Distance.ToString("F2");
                txtBlock.Foreground = Brushes.Red;
                txtBlock.FontSize = 16;
                totalDistanceContent.Content = txtBlock;
                item.ResultCanvasCollection.Add(totalDistanceContent);


                this.StrokeComparisonDataList.Add(item);
            }

            // sort by score
            this.StrokeComparisonDataList = new ObservableCollection<StrokeComparisonItemData>(this.StrokeComparisonDataList.OrderBy(n => n.DistanceScore));

            this.StrokeComparisonsControl.ItemsSource = this.StrokeComparisonDataList;
        }
        /// <summary>
        /// Initialization with analyer
        /// </summary>
        /// <param name="analysis"></param>
        public StepComparisonWindow(AnswerSheetAnalyzer a)
            : this()
        {
            this.analyzer = a;

            List<StepComparisonResult> results = this.analyzer.GetVisualizedStepComparisonExamples();
            foreach (StepComparisonResult res in results)
            {
                StepComparisonitemData item = new StepComparisonitemData();

                // draw stroke
                double scale1 = Config.OutputStepCanvasHeight / res.Step1.GetBounds().Height;
                double scale2 = Config.OutputStepCanvasHeight / res.Step2.GetBounds().Height;
                List<Stroke> strokes1 = res.Step1.GetStrokeObjects(scale: scale1, isOrigin: true, sort: true);
                List<Stroke> strokes2 = res.Step2.GetStrokeObjects(scale: scale2, isOrigin: true, sort: true);
                item.Strokes1.Add(new StrokeCollection(strokes1));
                item.Strokes2.Add(new StrokeCollection(strokes2));

                // draw coordinates
                foreach (Stroke s in strokes1)
                {
                    Ellipse e = new Ellipse();
                    e.StrokeThickness = 0.0;
                    e.Fill = Brushes.Blue;
                    e.Width = 5.0;
                    e.Height = 5.0;
                    Canvas.SetLeft(e, s.StylusPoints[0].X - (e.Width / 2.0));
                    Canvas.SetTop(e, s.StylusPoints[0].Y - (e.Height / 2.0));
                    item.ResultCanvasCollection.Add(e);
                }
                foreach (Stroke s in strokes2)
                {
                    Ellipse e = new Ellipse();
                    e.StrokeThickness = 0.0;
                    e.Fill = Brushes.Blue;
                    e.Width = 5.0;
                    e.Height = 5.0;
                    Canvas.SetLeft(e, s.StylusPoints[0].X - (e.Width / 2.0));
                    Canvas.SetTop(e, s.StylusPoints[0].Y + Config.OutputStepCanvasHeight - (e.Height / 2.0));
                    item.ResultCanvasCollection.Add(e);
                }

                // visualize matching results
                for (int i = 0, ilen = res.Results.MatchingList.Count; i < ilen; i++)
                {
                    List<int[]> matchings = res.Results.MatchingList;
                    if (matchings[i][0] != -1 && matchings[i][1] != -1)
                    {
                        // draw matching connector
                        Line l = new Line();
                        l.Stroke = Brushes.Red;
                        l.StrokeThickness = 1;
                        l.X1 = strokes1[matchings[i][0]].StylusPoints[0].X;
                        l.Y1 = strokes1[matchings[i][0]].StylusPoints[0].Y;
                        l.X2 = strokes2[matchings[i][1]].StylusPoints[0].X;
                        l.Y2 = strokes2[matchings[i][1]].StylusPoints[0].Y + Config.OutputStepCanvasHeight;
                        l.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                        l.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                        item.ResultCanvasCollection.Add(l);
                    }
                }

                // similarity score
                item.DistanceScore = res.Results.Distance;
                ContentControl totalDistanceContent = new ContentControl();
                Canvas.SetLeft(totalDistanceContent, 800.0);
                Canvas.SetTop(totalDistanceContent, 0.0);
                TextBlock txtBlock = new TextBlock();
                txtBlock.Text = res.Results.Distance.ToString("F2");
                txtBlock.Foreground = Brushes.Red;
                txtBlock.FontSize = 18;
                totalDistanceContent.Content = txtBlock;
                item.ResultCanvasCollection.Add(totalDistanceContent);
                
                this.StepComparisonDataList.Add(item);
            }

            // sort by score
            this.StepComparisonDataList = new ObservableCollection<StepComparisonitemData>(this.StepComparisonDataList.OrderBy(n => n.DistanceScore));

            this.StepComparisonControl.ItemsSource = this.StepComparisonDataList;
        }
 public AnswerSheetVisualizer(AnswerSheetAnalyzer a)
 {
     this.analyzer = a;
 }
        /// <summary>
        /// Change clustering method
        /// </summary>
        /// <param name="method"></param>
        private void ChangeMethod(AnswerSheetAnalyzer.ClassificationFeature method)
        {
            if (this.cbDepth == null)
            {
                return;
            }

            this.cbDepth.Items.Clear();
            for (int i = 0, ilen = this.analyzer.GetClusterTreeHeight(method); i <= ilen; i++)
            {
                this.cbDepth.Items.Add(i.ToString());
            }

            switch (method)
            {
                case AnswerSheetAnalyzer.ClassificationFeature.Proposed:
                    ChangeDepth(this.analyzer.HierarchicalResult.GetOptimalTreeDepth(), this.currentMethod);
                    break;
                case AnswerSheetAnalyzer.ClassificationFeature.AnswerTime:
                    ChangeDepth(this.analyzer.HierarchicalResultAnswerTime.GetOptimalTreeDepth(), this.currentMethod);
                    break;
            }
        }