diff --git a/html/admin/js/graphViewer/graph/communityNode.js b/html/admin/js/graphViewer/graph/communityNode.js
index 09a83833ef..dabdc332a7 100644
--- a/html/admin/js/graphViewer/graph/communityNode.js
+++ b/html/admin/js/graphViewer/graph/communityNode.js
@@ -1,5 +1,5 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
-/*global _ */
+/*global _, document*/
////////////////////////////////////////////////////////////////////////////////
/// @brief Graph functionality
///
@@ -36,6 +36,8 @@ function CommunityNode(initial) {
var
+ myRect,
+
////////////////////////////////////
// Private variables //
////////////////////////////////////
@@ -204,8 +206,26 @@ function CommunityNode(initial) {
},
shapeAll = function(g, shapeFunc, colourMapper) {
+
+ /*
+ myRect = g.append(testee)
+ .attr("rx", "8")
+ .attr("ry", "8")
+ .attr("fill", "none")
+ .attr("stroke", "black");
+ */
+ myRect = g.append("rect");
addShape(g, shapeFunc, colourMapper);
addLabel(g, colourMapper);
+ var bbox = document.getElementById(self._id).getBBox();
+ myRect.attr("width", bbox.width + 10) // Set width
+ .attr("height", bbox.height + 10) // Set height
+ .attr("x", bbox.x - 5)
+ .attr("y", bbox.y - 5)
+ .attr("rx", "8")
+ .attr("ry", "8")
+ .attr("fill", "none")
+ .attr("stroke", "black");
};
////////////////////////////////////
diff --git a/html/admin/js/graphViewer/jasmine_test/specCommunityNode/communityNodeSpec.js b/html/admin/js/graphViewer/jasmine_test/specCommunityNode/communityNodeSpec.js
index 91a5e1ac4f..57061d98e5 100644
--- a/html/admin/js/graphViewer/jasmine_test/specCommunityNode/communityNodeSpec.js
+++ b/html/admin/js/graphViewer/jasmine_test/specCommunityNode/communityNodeSpec.js
@@ -2,6 +2,7 @@
/*global beforeEach, afterEach */
/*global describe, it, expect, spyOn */
/*global helper*/
+/*global document*/
/*global CommunityNode*/
////////////////////////////////////////////////////////////////////////////////
@@ -246,11 +247,16 @@
describe('shaping functionality', function() {
- var tSpan1, tSpan2, text, g, shaper, colourMapper;
+ var tSpan1, tSpan2, text, g, shaper, colourMapper, box, boxRect;
beforeEach(function() {
var first = true;
-
+ box = {
+ x: -10,
+ y: -10,
+ width: 20,
+ height: 20
+ };
tSpan1 = {
attr: function() {
return this;
@@ -267,6 +273,11 @@
return this;
}
};
+ boxRect = {
+ attr: function() {
+ return this;
+ }
+ };
text = {
attr: function() {
return this;
@@ -287,8 +298,13 @@
attr: function() {
return this;
},
- append: function() {
- return text;
+ append: function(type) {
+ if (type === "text") {
+ return text;
+ }
+ if (type === "rect") {
+ return boxRect;
+ }
}
};
shaper = {
@@ -299,6 +315,14 @@
return "black";
}
};
+
+ spyOn(document, "getElementById").andCallFake(function() {
+ return {
+ getBBox: function() {
+ return box;
+ }
+ };
+ });
});
it('should initially contain the required attributes for shaping', function() {
@@ -394,6 +418,24 @@
expect(tSpan2.text).wasCalledWith("label");
});
+ it('should print the bounding box correctly', function() {
+ var c = new CommunityNode(nodes.slice(0, 2));
+ spyOn(g, "append").andCallThrough();
+ spyOn(boxRect, "attr").andCallThrough();
+
+ c.shape(g, shaper.shapeFunc, colourMapper);
+
+ expect(g.append).wasCalledWith("rect");
+ expect(boxRect.attr).wasCalledWith("width", box.width + 10);
+ expect(boxRect.attr).wasCalledWith("height", box.height + 10);
+ expect(boxRect.attr).wasCalledWith("x", box.x - 5);
+ expect(boxRect.attr).wasCalledWith("y", box.y - 5);
+ expect(boxRect.attr).wasCalledWith("rx", "8");
+ expect(boxRect.attr).wasCalledWith("ry", "8");
+ expect(boxRect.attr).wasCalledWith("fill", "none");
+ expect(boxRect.attr).wasCalledWith("stroke", "black");
+ });
+
});
describe('edge functionality', function() {