Ejemplo n.º 1
0
        public NetworkGraphViewModel(IProjectService projectService, IImageExportService imageExportService, IGraphService graphService)
            : base("Network Graph")
        {
            _projectService     = projectService;
            _imageExportService = imageExportService;
            _graphService       = graphService;

            _projectService.ProjectOpened += _projectService_ProjectOpened;

            Messenger.Default.Register <ComparisonPerformedMessage>(this, msg =>
            {
                if (_projectService.AreAllVarietiesCompared)
                {
                    Graph = _graphService.GenerateNetworkGraph(_similarityMetric);
                }
            });
            Messenger.Default.Register <DomainModelChangedMessage>(this, msg =>
            {
                if (msg.AffectsComparison)
                {
                    Graph = null;
                }
            });
            Messenger.Default.Register <PerformingComparisonMessage>(this, msg => Graph = null);

            TaskAreas.Add(new TaskAreaCommandGroupViewModel("Similarity metric",
                                                            new TaskAreaCommandViewModel("Lexical", new RelayCommand(() => SimilarityMetric  = SimilarityMetric.Lexical)),
                                                            new TaskAreaCommandViewModel("Phonetic", new RelayCommand(() => SimilarityMetric = SimilarityMetric.Phonetic))));
            TaskAreas.Add(new TaskAreaItemsViewModel("Other tasks",
                                                     new TaskAreaCommandViewModel("Export graph", new RelayCommand(Export, CanExport))));
            _similarityScoreFilter = 0.7;
        }
Ejemplo n.º 2
0
        public bool ExportNetworkGraph(object ownerViewModel, SimilarityMetric similarityMetric, double scoreFilter)
        {
            FileDialogResult result = _dialogService.ShowSaveFileDialog("Export Network Graph", this, new FileType("PNG image", ".png"));

            if (result.IsValid)
            {
                IBidirectionalGraph <NetworkGraphVertex, NetworkGraphEdge> graph = _graphService.GenerateNetworkGraph(similarityMetric);

                var graphLayout = new NetworkGraphLayout
                {
                    IsAnimationEnabled    = false,
                    CreationTransition    = null,
                    DestructionTransition = null,
                    LayoutAlgorithmType   = "StressMajorization",
                    LayoutParameters      = new StressMajorizationLayoutParameters {
                        WeightAdjustment = 1.0
                    },
                    OverlapRemovalAlgorithmType = "FSA",
                    OverlapRemovalParameters    = new OverlapRemovalParameters {
                        HorizontalGap = 2, VerticalGap = 2
                    },
                    Graph        = graph,
                    Background   = Brushes.White,
                    WeightFilter = scoreFilter
                };
                SaveElement(graphLayout, result.FileName, null);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public NetworkGraphViewModel(IProjectService projectService, IImageExportService imageExportService, IGraphService graphService)
            : base("Network Graph")
        {
            _projectService = projectService;
            _imageExportService = imageExportService;
            _graphService = graphService;

            _projectService.ProjectOpened += _projectService_ProjectOpened;

            Messenger.Default.Register<ComparisonPerformedMessage>(this, msg =>
            {
                if (_projectService.AreAllVarietiesCompared)
                    Graph = _graphService.GenerateNetworkGraph(_similarityMetric);
            });
            Messenger.Default.Register<DomainModelChangedMessage>(this, msg =>
            {
                if (msg.AffectsComparison)
                    Graph = null;
            });
            Messenger.Default.Register<PerformingComparisonMessage>(this, msg => Graph = null);

            TaskAreas.Add(new TaskAreaCommandGroupViewModel("Similarity metric",
                new TaskAreaCommandViewModel("Lexical", new RelayCommand(() => SimilarityMetric = SimilarityMetric.Lexical)),
                new TaskAreaCommandViewModel("Phonetic", new RelayCommand(() => SimilarityMetric = SimilarityMetric.Phonetic))));
            TaskAreas.Add(new TaskAreaItemsViewModel("Other tasks",
                new TaskAreaCommandViewModel("Export graph", new RelayCommand(Export, CanExport))));
            _similarityScoreFilter = 0.7;
        }
Ejemplo n.º 4
0
 private void _projectService_ProjectOpened(object sender, EventArgs e)
 {
     Graph = _projectService.AreAllVarietiesCompared ? _graphService.GenerateNetworkGraph(_similarityMetric) : null;
 }