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,
|
var self = this,
|
||||||
nodeContainer,
|
nodeContainer,
|
||||||
edgeContainer,
|
edgeContainer,
|
||||||
layouter,
|
|
||||||
fixedSize,
|
fixedSize,
|
||||||
dispatcher,
|
dispatcher,
|
||||||
edges = [],
|
edges = [],
|
||||||
|
@ -68,7 +67,7 @@ function GraphViewer(svg, width, height,
|
||||||
config.links = edges;
|
config.links = edges;
|
||||||
config.width = width;
|
config.width = width;
|
||||||
config.height = height;
|
config.height = height;
|
||||||
layouter = new ForceLayouter(config);
|
self.layouter = new ForceLayouter(config);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (config.type.toLowerCase()) {
|
switch (config.type.toLowerCase()) {
|
||||||
|
@ -77,7 +76,7 @@ function GraphViewer(svg, width, height,
|
||||||
config.links = edges;
|
config.links = edges;
|
||||||
config.width = width;
|
config.width = width;
|
||||||
config.height = height;
|
config.height = height;
|
||||||
layouter = new ForceLayouter(config);
|
self.layouter = new ForceLayouter(config);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw "Sorry unknown layout type.";
|
throw "Sorry unknown layout type.";
|
||||||
|
@ -93,7 +92,7 @@ function GraphViewer(svg, width, height,
|
||||||
self.edgeShaper = new EdgeShaper(edgeContainer, esConf);
|
self.edgeShaper = new EdgeShaper(edgeContainer, esConf);
|
||||||
nodeContainer = svg.append("svg:g");
|
nodeContainer = svg.append("svg:g");
|
||||||
self.nodeShaper = new NodeShaper(nodeContainer, nsConf, idFunc);
|
self.nodeShaper = new NodeShaper(nodeContainer, nsConf, idFunc);
|
||||||
layouter.setCombinedUpdateFunction(self.nodeShaper, self.edgeShaper);
|
self.layouter.setCombinedUpdateFunction(self.nodeShaper, self.edgeShaper);
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (adapterConfig.type.toLowerCase()) {
|
switch (adapterConfig.type.toLowerCase()) {
|
||||||
|
@ -124,10 +123,10 @@ function GraphViewer(svg, width, height,
|
||||||
parseConfig(config || {});
|
parseConfig(config || {});
|
||||||
|
|
||||||
self.start = function() {
|
self.start = function() {
|
||||||
layouter.stop();
|
self.layouter.stop();
|
||||||
self.edgeShaper.drawEdges(edges);
|
self.edgeShaper.drawEdges(edges);
|
||||||
self.nodeShaper.drawNodes(nodes);
|
self.nodeShaper.drawNodes(nodes);
|
||||||
layouter.start();
|
self.layouter.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
self.loadGraph = function(nodeId) {
|
self.loadGraph = function(nodeId) {
|
||||||
|
@ -163,7 +162,7 @@ function GraphViewer(svg, width, height,
|
||||||
reshapeNode: self.nodeShaper.reshapeNode
|
reshapeNode: self.nodeShaper.reshapeNode
|
||||||
},
|
},
|
||||||
drag: {
|
drag: {
|
||||||
layouter: layouter
|
layouter: self.layouter
|
||||||
},
|
},
|
||||||
nodeEditor: {
|
nodeEditor: {
|
||||||
nodes: nodes,
|
nodes: nodes,
|
||||||
|
|
|
@ -140,6 +140,10 @@ describe("Graph Viewer", function() {
|
||||||
expect(viewer.adapter).toBeDefined();
|
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() {
|
it('should offer the complete config for the event dispatcher', function() {
|
||||||
expect(viewer.dispatcherConfig).toBeDefined();
|
expect(viewer.dispatcherConfig).toBeDefined();
|
||||||
expect(viewer.dispatcherConfig).toEqual({
|
expect(viewer.dispatcherConfig).toEqual({
|
||||||
|
|
Loading…
Reference in New Issue