فهرست منبع

Node type conversion (#773)

Lutz Roeder 4 سال پیش
والد
کامیت
d29b6e650c
2فایلهای تغییر یافته به همراه8 افزوده شده و 12 حذف شده
  1. 3 7
      source/view-grapher.js
  2. 5 5
      source/view.js

+ 3 - 7
source/view-grapher.js

@@ -5,18 +5,14 @@ var dagre = dagre || require('dagre');
 
 grapher.Graph = class {
 
-    constructor(compound) {
+    constructor(compound, options) {
+        this._isCompound = compound;
+        this._options = options;
         this._nodes = new Map();
         this._edges = new Map();
         this._children = {};
         this._children['\x00'] = {};
         this._parent = {};
-        this._isCompound = compound;
-    }
-
-    setGraph(options) {
-        this._options = options;
-        return this;
     }
 
     graph() {

+ 5 - 5
source/view.js

@@ -541,7 +541,7 @@ view.View = class {
                     options.ranker = 'longest-path';
                 }
 
-                const viewGraph = new view.Graph(this, groups, options);
+                const viewGraph = new view.Graph(this, model, groups, options);
 
                 const clusters = new Set();
                 const clusterParentMap = new Map();
@@ -941,12 +941,12 @@ view.View = class {
 
 view.Graph = class extends grapher.Graph {
 
-    constructor(view, compound, options) {
-        super(compound);
+    constructor(view, model, compound, options) {
+        super(compound, options);
         this.view = view;
+        this.model = model;
         this._arguments = new Map();
         this._nodeKey = 0;
-        this.setGraph(options);
     }
 
     createNode(node) {
@@ -1018,7 +1018,7 @@ view.Node = class extends grapher.Node {
             styles.push('node-item-type-' + category.toLowerCase());
         }
         if (typeof type.name !== 'string' || !type.name.split) { // #416
-            const format = this.context.view.model && this.context.view.model.format ? this.context.view.model.format : '?';
+            const format = this.context.model && this.context.model.format ? this.context.model.format : '?';
             throw new view.Error("Unknown node type '" + JSON.stringify(type.name) + "' in format '" + format + "'.");
         }
         const content = this.context.view.showNames && (node.name || node.location) ? (node.name || node.location) : type.name.split('.').pop();