Comparing version 2.0.0-alpha24 to 2.0.0-alpha25
@@ -41,3 +41,2 @@ "use strict"; | ||
// in anti-collision step | ||
// TODO: minSize to be displayed | ||
// TOOD: document a little bit more so future people can understand this mess | ||
@@ -61,11 +60,19 @@ | ||
camera = params.camera, | ||
userCell = params.cell, | ||
dimensions = params.dimensions, | ||
displayedLabels = params.displayedLabels, | ||
visibleNodes = params.visibleNodes, | ||
dimensions = params.dimensions, | ||
graph = params.graph; | ||
_params$fontSize = params.fontSize, | ||
fontSize = _params$fontSize === void 0 ? 14 : _params$fontSize, | ||
graph = params.graph, | ||
_params$renderedSizeT = params.renderedSizeThreshold, | ||
renderedSizeThreshold = _params$renderedSizeT === void 0 ? -Infinity : _params$renderedSizeT, | ||
visibleNodes = params.visibleNodes; | ||
var cameraState = camera.getState(), | ||
previousCameraState = camera.getPreviousState(); | ||
var previousCamera = new _camera["default"](); | ||
previousCamera.setState(previousCameraState); // Camera hasn't moved? | ||
previousCamera.setState(previousCameraState); // TODO: should factorize. This same code is used quite a lot throughout the codebase | ||
// TODO: POW RATIO is currently default 0.5 and harcoded | ||
var sizeRatio = Math.pow(cameraState.ratio, 0.5); // Camera hasn't moved? | ||
var still = cameraState.x === previousCameraState.x && cameraState.y === previousCameraState.y && cameraState.ratio === previousCameraState.ratio; // State | ||
@@ -85,3 +92,4 @@ | ||
var cell = cameraState.ratio >= 1.3 ? DEFAULT_UNZOOMED_CELL : DEFAULT_CELL; | ||
var cell = userCell ? userCell : DEFAULT_CELL; | ||
if (cameraState.ratio >= 1.3) cell = DEFAULT_UNZOOMED_CELL; | ||
var cwr = dimensions.width % cell.width; | ||
@@ -107,4 +115,6 @@ var cellWidth = cell.width + cwr / Math.floor(dimensions.width / cell.width); | ||
var node = visibleNodes[i], | ||
nodeData = cache[node]; // Finding our node's cell in the grid | ||
nodeData = cache[node]; // We filter nodes having a rendered size less than a certain thresold | ||
if (nodeData.size / sizeRatio < renderedSizeThreshold) continue; // Finding our node's cell in the grid | ||
var pos = camera.graphToViewport(dimensions, nodeData.x, nodeData.y); // Node is not actually visible on screen | ||
@@ -209,6 +219,9 @@ // NOTE: can optimize margin on the right side (only if we know where the labels go) | ||
p2 = camera.graphToViewport(dimensions, d2.x, d2.y); | ||
var c = collision(p1.x, p1.y, d1.label.length * 8, 14, p2.x, p2.y, d2.label.length * 8, 14); | ||
var c = collision( // First abstract bbox | ||
p1.x, p1.y, d1.label.length * 8, fontSize, // Second abstract bbox | ||
p2.x, p2.y, d2.label.length * 8, fontSize); | ||
if (c) { | ||
// NOTE: add degree as tie-breaker here if required in the future | ||
// NOTE: add final stable tie-breaker using node key if required | ||
if (d1.size < d2.size) collisions.add(_n);else collisions.add(_n2); | ||
@@ -215,0 +228,0 @@ } |
{ | ||
"name": "sigma", | ||
"version": "2.0.0-alpha24", | ||
"version": "2.0.0-alpha25", | ||
"description": "A JavaScript library dedicated to graph drawing.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://sigmajs.org", |
@@ -42,3 +42,3 @@ "use strict"; | ||
var _arrow = _interopRequireDefault(require("./programs/arrow")); | ||
var _settings = require("./settings"); | ||
@@ -71,25 +71,2 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
/** | ||
* Defaults. | ||
*/ | ||
var DEFAULT_SETTINGS = { | ||
// Performance | ||
hideEdgesOnMove: false, | ||
hideLabelsOnMove: false, | ||
renderLabels: true, | ||
// Component rendering | ||
defaultNodeColor: '#999', | ||
defaultNodeType: 'circle', | ||
defaultEdgeColor: '#ccc', | ||
defaultEdgeType: 'line', | ||
labelFont: 'Arial', | ||
labelSize: 14, | ||
labelWeight: 'normal', | ||
// Reducers | ||
nodeReducer: null, | ||
edgeReducer: null, | ||
// Features | ||
zIndex: false | ||
}; | ||
/** | ||
* Main class. | ||
@@ -115,3 +92,4 @@ * | ||
settings = settings || {}; | ||
_this.settings = (0, _utils.assign)({}, DEFAULT_SETTINGS, settings); // Validating | ||
_this.settings = (0, _utils.assign)({}, _settings.WEBGL_RENDERER_DEFAULT_SETTINGS, settings); | ||
(0, _settings.validateWebglRendererSettings)(_this.settings); // Validating | ||
@@ -750,11 +728,14 @@ if (!(0, _isGraph["default"])(graph)) throw new Error('sigma/renderers/webgl: invalid graph instance.'); | ||
var gridSettings = this.settings.labelGrid; | ||
var labelsToDisplay = (0, _labels.labelsToDisplayFromGrid)({ | ||
cache: this.nodeDataCache, | ||
camera: this.camera, | ||
cell: gridSettings.cell, | ||
dimensions: this, | ||
displayedLabels: this.displayedLabels, | ||
visibleNodes: visibleNodes, | ||
dimensions: this, | ||
graph: this.graph | ||
fontSize: this.settings.labelSize, | ||
graph: this.graph, | ||
renderedSizeThreshold: gridSettings.renderedSizeThreshold, | ||
visibleNodes: visibleNodes | ||
}); // Drawing labels | ||
// TODO: POW RATIO is currently default 0.5 and harcoded | ||
@@ -770,8 +751,6 @@ var context = this.contexts.labels; | ||
y = _this$camera$graphToV.y; // TODO: we can cache the labels we need to render until the camera's ratio changes | ||
// TODO: this should be computed in the canvas components? | ||
var size = data.size / sizeRatio; // TODO: this is the label threshold hardcoded | ||
// if (size < 8) | ||
// continue; | ||
var size = data.size / sizeRatio; | ||
(0, _label["default"])(context, { | ||
@@ -778,0 +757,0 @@ label: data.label, |
33
utils.js
@@ -6,4 +6,7 @@ "use strict"; | ||
}); | ||
exports.isPlainObject = isPlainObject; | ||
exports.assign = assign; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
/** | ||
@@ -17,4 +20,13 @@ * Sigma.js Utils | ||
/** | ||
* Very simple Object.assign-like function. | ||
* Checks whether the given value is a plain object. | ||
* | ||
* @param {mixed} value - Target value. | ||
* @return {boolean} | ||
*/ | ||
function isPlainObject(value) { | ||
return _typeof(value) === 'object' && value !== null && value.constructor === Object; | ||
} | ||
/** | ||
* Very simple recursive Object.assign-like function. | ||
* | ||
* @param {object} target - First object. | ||
@@ -24,14 +36,17 @@ * @param {object} [...objects] - Objects to merge. | ||
*/ | ||
function assign(target) { | ||
target = target || {}; | ||
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
objects[_key - 1] = arguments[_key]; | ||
} | ||
for (var i = 0, l = arguments.length <= 1 ? 0 : arguments.length - 1; i < l; i++) { | ||
var o = i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1]; | ||
if (!o) continue; | ||
for (var i = 0, l = objects.length; i < l; i++) { | ||
if (!objects[i]) continue; | ||
for (var k in objects[i]) { | ||
target[k] = objects[i][k]; | ||
for (var k in o) { | ||
if (isPlainObject(o[k])) { | ||
target[k] = assign(target[k], o[k]); | ||
} else { | ||
target[k] = o[k]; | ||
} | ||
} | ||
@@ -38,0 +53,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
906250
57
3872