mirror of https://gitee.com/bigwinds/arangodb
GraphViewer: Layouter is now accessible
This commit is contained in:
parent
57ef46e895
commit
6945a99327
|
@ -54,7 +54,6 @@ function GraphViewer(svg, width, height,
|
|||
var self = this,
|
||||
nodeContainer,
|
||||
edgeContainer,
|
||||
layouter,
|
||||
fixedSize,
|
||||
dispatcher,
|
||||
edges = [],
|
||||
|
@ -68,7 +67,7 @@ function GraphViewer(svg, width, height,
|
|||
config.links = edges;
|
||||
config.width = width;
|
||||
config.height = height;
|
||||
layouter = new ForceLayouter(config);
|
||||
self.layouter = new ForceLayouter(config);
|
||||
return;
|
||||
}
|
||||
switch (config.type.toLowerCase()) {
|
||||
|
@ -77,7 +76,7 @@ function GraphViewer(svg, width, height,
|
|||
config.links = edges;
|
||||
config.width = width;
|
||||
config.height = height;
|
||||
layouter = new ForceLayouter(config);
|
||||
self.layouter = new ForceLayouter(config);
|
||||
break;
|
||||
default:
|
||||
throw "Sorry unknown layout type.";
|
||||
|
@ -93,7 +92,7 @@ function GraphViewer(svg, width, height,
|
|||
self.edgeShaper = new EdgeShaper(edgeContainer, esConf);
|
||||
nodeContainer = svg.append("svg:g");
|
||||
self.nodeShaper = new NodeShaper(nodeContainer, nsConf, idFunc);
|
||||
layouter.setCombinedUpdateFunction(self.nodeShaper, self.edgeShaper);
|
||||
self.layouter.setCombinedUpdateFunction(self.nodeShaper, self.edgeShaper);
|
||||
};
|
||||
|
||||
switch (adapterConfig.type.toLowerCase()) {
|
||||
|
@ -124,10 +123,10 @@ function GraphViewer(svg, width, height,
|
|||
parseConfig(config || {});
|
||||
|
||||
self.start = function() {
|
||||
layouter.stop();
|
||||
self.layouter.stop();
|
||||
self.edgeShaper.drawEdges(edges);
|
||||
self.nodeShaper.drawNodes(nodes);
|
||||
layouter.start();
|
||||
self.layouter.start();
|
||||
};
|
||||
|
||||
self.loadGraph = function(nodeId) {
|
||||
|
@ -163,7 +162,7 @@ function GraphViewer(svg, width, height,
|
|||
reshapeNode: self.nodeShaper.reshapeNode
|
||||
},
|
||||
drag: {
|
||||
layouter: layouter
|
||||
layouter: self.layouter
|
||||
},
|
||||
nodeEditor: {
|
||||
nodes: nodes,
|
||||
|
|
|
@ -140,6 +140,10 @@ describe("Graph Viewer", function() {
|
|||
expect(viewer.adapter).toBeDefined();
|
||||
});
|
||||
|
||||
it('should offer the layouter', function() {
|
||||
expect(viewer.layouter).toBeDefined();
|
||||
});
|
||||
|
||||
it('should offer the complete config for the event dispatcher', function() {
|
||||
expect(viewer.dispatcherConfig).toBeDefined();
|
||||
expect(viewer.dispatcherConfig).toEqual({
|
||||
|
|
Loading…
Reference in New Issue