|
|
@ -1,15 +1,16 @@ |
|
|
|
// Load custom shapes into CanvasRenderingContext2D
|
|
|
|
require('./shapes'); |
|
|
|
|
|
|
|
var Emitter = require('emitter-component'); |
|
|
|
var Hammer = require('../module/hammer'); |
|
|
|
var util = require('../util'); |
|
|
|
var DataSet = require('../DataSet'); |
|
|
|
var DataView = require('../DataView'); |
|
|
|
var dotparser = require('./dotparser'); |
|
|
|
var gephiParser = require('./gephiParser'); |
|
|
|
var Images = require('./Images'); |
|
|
|
var Activator = require('../shared/Activator'); |
|
|
|
let Emitter = require('emitter-component'); |
|
|
|
let Hammer = require('../module/hammer'); |
|
|
|
let util = require('../util'); |
|
|
|
let DataSet = require('../DataSet'); |
|
|
|
let DataView = require('../DataView'); |
|
|
|
let dotparser = require('./dotparser'); |
|
|
|
let gephiParser = require('./gephiParser'); |
|
|
|
let Images = require('./Images'); |
|
|
|
let Activator = require('../shared/Activator'); |
|
|
|
let locales = require('./locales'); |
|
|
|
|
|
|
|
import Groups from './modules/Groups'; |
|
|
|
import NodesHandler from './modules/NodesHandler'; |
|
|
@ -28,6 +29,8 @@ import Validator from "./modules/Validator"; |
|
|
|
import {printStyle} from "./modules/Validator"; |
|
|
|
import {allOptions, configureOptions} from './modules/components/AllOptions.js'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @constructor Network |
|
|
|
* Create a network visualization, displaying nodes and edges. |
|
|
@ -47,8 +50,10 @@ function Network(container, data, options) { |
|
|
|
// set constant values
|
|
|
|
this.options = {}; |
|
|
|
this.defaultOptions = { |
|
|
|
locale: 'en', |
|
|
|
locales: locales, |
|
|
|
clickToUse: false |
|
|
|
}; |
|
|
|
} |
|
|
|
util.extend(this.options, this.defaultOptions); |
|
|
|
|
|
|
|
// containers for nodes and edges
|
|
|
@ -93,6 +98,8 @@ function Network(container, data, options) { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bind the event listeners
|
|
|
|
this.bindEventListeners(); |
|
|
|
|
|
|
@ -143,37 +150,50 @@ Network.prototype.setOptions = function (options) { |
|
|
|
console.log('%cErrors have been found in the supplied options object. None of the options will be used.', printStyle); |
|
|
|
} |
|
|
|
|
|
|
|
//this.placeConvenienceOptions(options);
|
|
|
|
// copy the global fields over
|
|
|
|
let fields = ['locale','locales','clickToUse']; |
|
|
|
util.selectiveDeepExtend(fields,this.options, options); |
|
|
|
|
|
|
|
// the hierarchical system can adapt the edges and the physics to it's own options because not all combinations work with the hierarichical system.
|
|
|
|
options = this.layoutEngine.setOptions(options.layout, options); |
|
|
|
|
|
|
|
this.canvas.setOptions(options); // options for canvas are in globals
|
|
|
|
|
|
|
|
// pass the options to the modules
|
|
|
|
this.groups.setOptions(options.groups); |
|
|
|
this.nodesHandler.setOptions(options.nodes); |
|
|
|
this.edgesHandler.setOptions(options.edges); |
|
|
|
this.physics.setOptions(options.physics); |
|
|
|
this.canvas.setOptions(options.canvas); |
|
|
|
this.renderer.setOptions(options.rendering); |
|
|
|
this.view.setOptions(options.view); |
|
|
|
this.manipulation.setOptions(options.manipulation,options); // manipulation uses the locales in the globals
|
|
|
|
|
|
|
|
this.interactionHandler.setOptions(options.interaction); |
|
|
|
this.selectionHandler.setOptions(options.selection); |
|
|
|
this.clustering.setOptions(options.clustering); |
|
|
|
this.manipulation.setOptions(options.manipulation); |
|
|
|
this.renderer.setOptions(options.interaction); // options for rendering are in interaction
|
|
|
|
this.selectionHandler.setOptions(options.interaction); // options for selection are in interaction
|
|
|
|
|
|
|
|
// these two do not have options at the moment, here for completeness
|
|
|
|
//this.view.setOptions(options.view);
|
|
|
|
//this.clustering.setOptions(options.clustering);
|
|
|
|
|
|
|
|
this.configurationSystem.setOptions(options.configure); |
|
|
|
|
|
|
|
// if the configuration system is enabled, copy all options and put them into the config system
|
|
|
|
if (this.configurationSystem.options.enabled === true) { |
|
|
|
let networkOptions = {nodes:{},edges:{},layout:{},interaction:{},manipulation:{},physics:{},selection:{},rendering:{}}; |
|
|
|
let networkOptions = {nodes:{},edges:{},layout:{},interaction:{},manipulation:{},physics:{},global:{}}; |
|
|
|
util.deepExtend(networkOptions.nodes, this.nodesHandler.options); |
|
|
|
util.deepExtend(networkOptions.edges, this.edgesHandler.options); |
|
|
|
util.deepExtend(networkOptions.layout, this.layoutEngine.options); |
|
|
|
// load the selectionHandler and rendere default options in to the interaction group
|
|
|
|
util.deepExtend(networkOptions.interaction, this.selectionHandler.options); |
|
|
|
util.deepExtend(networkOptions.interaction, this.renderer.options); |
|
|
|
|
|
|
|
util.deepExtend(networkOptions.interaction, this.interactionHandler.options); |
|
|
|
util.deepExtend(networkOptions.manipulation, this.manipulation.options); |
|
|
|
util.deepExtend(networkOptions.physics, this.physics.options); |
|
|
|
util.deepExtend(networkOptions.selection, this.selectionHandler.options); |
|
|
|
util.deepExtend(networkOptions.rendering, this.renderer.options); |
|
|
|
|
|
|
|
// load globals into the global object
|
|
|
|
util.deepExtend(networkOptions.global, this.canvas.options); |
|
|
|
util.deepExtend(networkOptions.global, this.options); |
|
|
|
|
|
|
|
this.configurationSystem.setModuleOptions(networkOptions); |
|
|
|
} |
|
|
|
|
|
|
@ -204,25 +224,6 @@ Network.prototype.setOptions = function (options) { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
//
|
|
|
|
///**
|
|
|
|
// *
|
|
|
|
// */
|
|
|
|
//Network.prototype.placeConvenienceOptions = function (options) {
|
|
|
|
// if (options.locale !== undefined) {
|
|
|
|
// if (options.manipulation === undefined) {
|
|
|
|
// options.manipulation = {enabled:false, locale:options.locale};
|
|
|
|
// }
|
|
|
|
// else if (typeof options.manipulation === 'boolean') {
|
|
|
|
// options.manipulation = {enabled: options.manipulation, locale:options.locale};
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// options.manipulation.locale = options.locale;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Update the this.body.nodeIndices with the most recent node index list |
|
|
|