From a5151bf65aca5c332981c6805b5f9777f398a17b Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Wed, 7 Jan 2015 15:39:16 +0100 Subject: [PATCH] - Added getBoundingBox method. --- HISTORY.md | 1 + dist/vis.js | 7 +++++++ docs/network.html | 6 ++++++ lib/network/Network.js | 7 +++++++ 4 files changed, 21 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 4c8558f9..cd0d87d1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -22,6 +22,7 @@ http://visjs.org - Fixed error in repulsion physics model. - Improved physics handling for smoother network simulation. - Fixed infinite loop when an image can not be found and no brokenImage is provided. +- Added getBoundingBox method. ### Graph2d diff --git a/dist/vis.js b/dist/vis.js index 8717afcd..26449283 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -25134,6 +25134,13 @@ return /******/ (function(modules) { // webpackBootstrap return this.DOMtoCanvas({x: 0.5 * this.frame.canvas.clientWidth, y: 0.5 * this.frame.canvas.clientHeight}); }; + + Network.prototype.getBoundingBox = function(nodeId) { + if (this.nodes[nodeId] !== undefined) { + return this.nodes[nodeId].boundingBox; + } + } + module.exports = Network; diff --git a/docs/network.html b/docs/network.html index 44d5f400..4d729591 100644 --- a/docs/network.html +++ b/docs/network.html @@ -2155,6 +2155,12 @@ var options = { Returns the x and y coodinates of the center of the screen (in canvas space). + + getBoundingBox() + Object + Returns a bounding box for the node including label in the format: {top:Number,left:Number,right:Number,bottom:Number}. These values are in canvas space. + + getSelection() Array of ids diff --git a/lib/network/Network.js b/lib/network/Network.js index c6fdb8e4..7b3fccaf 100644 --- a/lib/network/Network.js +++ b/lib/network/Network.js @@ -2649,4 +2649,11 @@ Network.prototype.getCenterCoordinates = function () { return this.DOMtoCanvas({x: 0.5 * this.frame.canvas.clientWidth, y: 0.5 * this.frame.canvas.clientHeight}); }; + +Network.prototype.getBoundingBox = function(nodeId) { + if (this.nodes[nodeId] !== undefined) { + return this.nodes[nodeId].boundingBox; + } +} + module.exports = Network;