alcatel/static/libraries/nco/cartographie.js
author Nicolas Sauret <nicolas.sauret@iri.centrepompidou.fr>
Fri, 18 Apr 2014 14:31:58 +0200
changeset 51 79833eaa394a
parent 27 8ca7f2cea729
permissions -rw-r--r--
set up second level for navigation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
     1
function Carte(parametres, articles, links) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
     2
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
     3
	var object = this;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
     4
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
     5
	this.parametres = {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
     6
		// Module dimensions and caracteristics
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
     7
		width: 1440,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
     8
		height: 800,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
     9
		top: 50,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    10
		left: -240,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    11
		name: null,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    12
		boxID: "box",
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    13
		selectorID: "carto",
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    14
		canvasID: "canvas",
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    15
		info: "infos",
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    16
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    17
		couleurs: null,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    18
		relations: null,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    19
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    20
		// How to deal with the data
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    21
		isPositions: false,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    22
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    23
		charge: -30,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    24
		gravity: .13,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    25
		theta: 3,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    26
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    27
		// Node rendering
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    28
		nodeSizeInterval: [3, 15],
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    29
		log: false,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    30
		exp: false,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    31
		layerStyle: {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    32
			opacity: 0.6
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    33
		},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    34
		handle_len_rate: 2.2,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    35
		maxDistance: 35,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    36
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    37
		scaleInterval: [0.5, 10],
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    38
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    39
		infobulleHtml: function(node) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    40
			return node.titre + "<p>cluster: " + node.group +"</p>";
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    41
		},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    42
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    43
		activerZoom: true,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    44
		activerNodeZoom: true,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    45
		activerInfobulle: true,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    46
		zoomNode: false,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    47
		logZoomNode: false,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    48
		logZoomNodeParameter: 2
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    49
	};
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    50
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    51
	this.beginDate = new Date(); 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    52
	this.etendre(parametres);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    53
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    54
	if (null==this.parametres.name) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    55
		this.parametres.name = this.parametres.selectorID;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    56
	}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    57
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    58
	//création du contenant sur la page, si inexistant
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    59
	if (null == (document.getElementById(this.parametres.boxID))) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    60
		d3.select('.content').append('div')
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    61
			.attr("id", this.parametres.boxID)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    62
			.classed("gallery", true)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    63
			.style("position", "absolute")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    64
			.style("border", "1 px dashed");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    65
	}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    66
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    67
	d3.select('#' + this.parametres.boxID)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    68
		.style("width", this.parametres.width)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    69
		.style("height", this.parametres.height)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    70
		.style("position", "absolute")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    71
		.style("top", this.parametres.top)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    72
		.style("left", this.parametres.left)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    73
		.style("overflow", "hidden")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    74
		.style('z-index', 0);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    75
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    76
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    77
	if (null == (document.getElementById(this.parametres.selectorID))) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    78
		d3.select('.gallery').append('div')
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    79
			.attr("id", this.parametres.selectorID);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    80
	}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    81
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    82
	d3.select('#' + this.parametres.selectorID)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    83
		.attr("width", this.parametres.width)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    84
		.attr("height", this.parametres.height)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    85
		.style("position", "absolute")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    86
		.style('z-index', 2);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    87
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    88
	// Create drag interaction with the module
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    89
	this.drag = d3.behavior.drag()
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    90
	    .on("dragstart", function(d, i) {object.dragstart(d, i, object);})
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    91
	    .on("drag", object.dragmove)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    92
	    .on("dragend", function(d, i) {object.dragend(d, i, object);});
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    93
		   
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    94
	this.static = false;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    95
    
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    96
    if (this.parametres.activerNodeZoom) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    97
    		this.nodeMouseover = function(node) { 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    98
    			var scale = object.getScale(object.rect);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
    99
				object.grow(node, scale); 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   100
			};
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   101
			
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   102
			this.nodeMouseout = function(node) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   103
				var radius = object.radius(node.datum("scaledPoids"));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   104
				object.shrink(radius, node); 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   105
			};
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   106
    }
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   107
    
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   108
    if (this.parametres.activerInfobulle) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   109
    	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   110
		this.nodeClick = function(d) { 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   111
			object.highlight(d); 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   112
		};
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   113
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   114
		this.infoClick = function(d) { 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   115
			object.blur(); 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   116
		};
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   117
    }	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   118
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   119
	//création de l'infobulle, si inexistante
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   120
	if (null == (this.infoBulle = d3.select('#' + this.parametres.info)[0][0])) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   121
		this.infoBulle = d3.select('#' + this.parametres.selectorID).append('div')
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   122
			.attr("id", this.parametres.info)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   123
			.style("top", this.parametres.height)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   124
			.style("opacity", 0)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   125
			.style("z-index", 1);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   126
	}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   127
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   128
	if (null!=this.parametres.relations) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   129
		this.parametres.relations.add(
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   130
				this.parametres.name + ".infobulle", this.infoBulle)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   131
			.click(this.infoClick);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   132
	}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   133
	else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   134
		this.infoBulle.on("click", this.infoClick);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   135
	}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   136
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   137
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   138
	//création du canvas sur la page, si inexistant
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   139
	if (null == (this.canvas = document.getElementById(this.parametres.canvasID))) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   140
		d3.select('.gallery').insert('canvas', '#' + this.parametres.selectorID)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   141
			.attr("id", this.parametres.canvasID)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   142
			.attr("resize", false);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   143
		this.canvas = document.getElementById(this.parametres.canvasID);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   144
	}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   145
	d3.select('#' + this.parametres.canvasID)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   146
		.attr("width", d3.select('#' + this.parametres.selectorID).attr("width"))
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   147
		.attr("height", d3.select('#' + this.parametres.selectorID).attr("height"))
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   148
		.style("position", "absolute")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   149
		.style("z-index", 1);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   150
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   151
	this.mouse = {};
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   152
	this.isDown = false;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   153
	this.drag2 = false;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   154
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   155
	this.svg = d3.select('#' + this.parametres.selectorID).append('svg')
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   156
		.attr("width", this.parametres.width)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   157
		.attr("height", this.parametres.height)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   158
		.on("mousedown", function() {object.mouseDown(event);})
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   159
		.on("mousemove", function() {object.mouseMove(event);})
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   160
		.on("mouseup", function() {object.mouseUp(event);});
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   161
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   162
	paper.setup(this.canvas);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   163
	paper.view.viewSize = new paper.Size(object.parametres.width, object.parametres.height);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   164
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   165
	this.clusters = articles.clusters;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   166
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   167
	//génération d'une palette de couleurs
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   168
	if (null == this.parametres.couleurs) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   169
		//this.parametres.couleurs = this.selectColors(this.clusters.length);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   170
		this.parametres.couleurs = new Couleurs(this.clusters.length);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   171
	}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   172
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   173
	console.log("Environnement OK.");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   174
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   175
	this.data = {};
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   176
	this.zones = [];	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   177
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   178
	if (this.parametres.isPositions) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   179
		// Use directly data
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   180
		this.data.nodes = this.generateNodes(articles, this.parametres.isPositions);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   181
		this.length = articles.nbItems;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   182
		this.display();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   183
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   184
	}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   185
	else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   186
		//initialisation du Force Directed Graph
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   187
		this.data.nodes = this.generateNodes(articles, this.parametres.isPositions);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   188
		this.data.links = this.generateLinks(links, this.data.nodes);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   189
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   190
		this.force = d3.layout.force()
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   191
			.charge(this.parametres.charge)    //-20  
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   192
			.nodes(this.data.nodes)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   193
			.links(this.data.links)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   194
			.linkDistance(function(link) {return link.linkDistance;}) //20
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   195
			.linkStrength(function(link) {return link.linkStrength;})
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   196
			.size([this.parametres.width, this.parametres.height])
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   197
			.gravity(this.parametres.gravity) //.1
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   198
			.theta(this.parametres.theta)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   199
			.start();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   200
			
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   201
		console.log("Graphe en cours de stabilisation . . .");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   202
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   203
		this.force.on("tick", function() {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   204
			console.log("Stabilisation OK.");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   205
			object.display();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   206
		});
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   207
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   208
	}	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   209
};	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   210
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   211
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   212
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   213
Carte.prototype = {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   214
	constructor: Carte,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   215
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   216
	//gestion des paramètres
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   217
	etendre: function(parametres) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   218
		if (null==parametres || "object"!=typeof(parametres)) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   219
			return;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   220
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   221
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   222
		for (var cle in parametres) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   223
			this.parametres[cle] = parametres[cle];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   224
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   225
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   226
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   227
	display: function () {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   228
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   229
		this.showNodes();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   230
		if (this.parametres.activerZoom) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   231
			this.activateZoom();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   232
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   233
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   234
		paper.setup(this.canvas);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   235
		paper.view.viewSize = new paper.Size(
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   236
				this.parametres.width, this.parametres.height);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   237
		this.createBackground();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   238
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   239
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   240
	activateZoom: function() {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   241
		this.rect = this.svg.selectAll("rect")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   242
		    .data([{
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   243
		    	x: this.parametres.width*(1 - this.parametres.scaleInterval[0])/(this.parametres.scaleInterval[1] - this.parametres.scaleInterval[0]),
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   244
		    	y: 0
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   245
		    }])
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   246
			.enter().append("rect")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   247
			.attr("x", function(d) { return d.x; })
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   248
			.attr("y", function(d) { return d.y; })
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   249
		    .attr("width", 15)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   250
		    .attr("height", 15)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   251
		    .style("stroke", "black")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   252
		    .style("fill", "#00f")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   253
		    .style("z-index", 2)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   254
			.call(this.drag);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   255
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   256
		if (null!=this.parametres.relations) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   257
			this.parametres.relations.add(
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   258
					this.parametres.name + ".zoomButton", this.rect);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   259
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   260
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   261
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   262
	//génération d'une palette de couleurs
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   263
	selectColors: function(nbClusters) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   264
		var colors = colorbrewer;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   265
		var sets = ["BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdYlBu", "RdYlGn"];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   266
		var selectorID, finalColors = [];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   267
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   268
		while (finalColors.length < nbClusters) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   269
			selectorID = 	Math.floor(Math.random()*7);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   270
			selectorID2 = Math.floor(Math.random()*11);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   271
			color = new paper.RgbColor(colors[sets[selectorID]][11][selectorID2]);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   272
			
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   273
			var available = true;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   274
			for (var i = 0; i < finalColors.length; i++) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   275
				if (Math.floor(finalColors[i].hue) == Math.floor(color.hue)) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   276
					available = false;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   277
				}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   278
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   279
			
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   280
			if (color.brightness < 0.9 && available) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   281
				finalColors.push(color.toCssString());
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   282
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   283
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   284
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   285
		return finalColors;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   286
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   287
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   288
	//génération des noeuds √† partir du json
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   289
	generateNodes: function(items, isPos) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   290
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   291
		var nodes = [];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   292
		var poidsMin = 100000, poidsMax = 0;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   293
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   294
		// on crée les noeuds
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   295
		for (var i = 0 ; i<items.nbItems; ++i) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   296
			nodes.push({index: i, titre: "Titre numero " + i, weigth: 1});
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   297
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   298
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   299
		// on donne à chaque noeud son poids et couleurs
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   300
		// on traite identiquement core et agregated
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   301
		// pour les clusters
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   302
		var nbClusters = items.clusters.length;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   303
		for (var i =0; i< nbClusters; ++i) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   304
			var cluster = items.clusters[i], 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   305
				clusterId = cluster.id,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   306
				groups = [];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   307
			if (cluster.items) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   308
				groups.push("items");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   309
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   310
			else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   311
				groups.push("core");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   312
				groups.push("agregated");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   313
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   314
			for (var a in groups) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   315
				var group = cluster[groups[a]];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   316
				for (var j =0; j<group.length; ++j) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   317
					var item = group[j], poids = parseInt(item.value);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   318
					nodes[item.key]["poids"] = poids;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   319
					nodes[item.key]["scaledPoids"] = poids;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   320
					nodes[item.key]["group"] = clusterId;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   321
					nodes[item.key]["key"] = item.key;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   322
					if (isPos) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   323
						nodes[item.key]["x"] = parseFloat(item.x);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   324
						nodes[item.key]["y"] = parseFloat(item.y);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   325
					}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   326
					else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   327
						nodes[item.key]["x"] = this.parametres.width/2*(1 + Math.cos(i*Math.Pi/nbClusters));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   328
						nodes[item.key]["y"] = this.parametres.height/2*(1 + Math.sin(i*Math.Pi/nbClusters));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   329
					}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   330
					if (null != this.parametres.relations) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   331
						this.parametres.relations.add(this.parametres.selectorID + ".node." + item.key, nodes[item.key]);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   332
					}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   333
					if (poids>poidsMax) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   334
						poidsMax = poids;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   335
					}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   336
					else if (poids<poidsMin) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   337
						poidsMin = poids;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   338
					}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   339
				}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   340
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   341
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   342
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   343
		this.poidsMin = poidsMin;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   344
		this.poidsMax = poidsMax;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   345
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   346
		// pour les unclustered
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   347
		var unclusteredId = items.clusters.length;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   348
		var unclusteredItems = (items.unclustered.items)? 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   349
				items.unclustered.items: items.unclustered;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   350
		for (var i =0; i< unclusteredItems.length; ++i) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   351
			var item = unclusteredItems[i];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   352
			nodes[item.key]["poids"] = poidsMin;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   353
			nodes[item.key]["scaledPoids"] = poidsMin;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   354
			nodes[item.key]["group"] = unclusteredId;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   355
			nodes[item.key]["key"] = item.key;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   356
			if (isPos) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   357
				nodes[item.key]["x"] = parseFloat(item.x);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   358
				nodes[item.key]["y"] = parseFloat(item.y);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   359
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   360
			else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   361
				nodes[item.key]["x"] = this.parametres.width/2;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   362
				nodes[item.key]["y"] = this.parametres.height/2;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   363
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   364
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   365
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   366
		console.log("Data articles extraites.");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   367
		return nodes;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   368
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   369
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   370
	//génération des liens à partir du json
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   371
	generateLinks: function(liens, nodes) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   372
		//var linkMax = 0, linkMin = 500;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   373
		var links = [];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   374
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   375
		for (var i = 0; i< liens.images.length; ++i) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   376
			var item = liens.images[i];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   377
			for (var j = 0; j < 20 && j < item.v.length; ++j) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   378
				var voisin = item.v[j];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   379
				
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   380
				var linkDistance = 200/Math.max(voisin.d, 4), linkStrength;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   381
				
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   382
				if (nodes[item.id]["group"] == nodes[voisin.id]["group"]) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   383
					linkStrength = 1;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   384
					linkDistance *= 0.5;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   385
				}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   386
				else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   387
					linkStrength = 0.5;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   388
				}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   389
				
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   390
				links.push({source: item.id, target: voisin.id, value: voisin.d, linkDistance: linkDistance, linkStrength: linkStrength});
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   391
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   392
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   393
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   394
		console.log("Data liens extraites.");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   395
		return links;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   396
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   397
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   398
	//calcul du rayon
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   399
	radius: function(poids) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   400
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   401
		var diff = this.parametres.nodeSizeInterval[1] - this.parametres.nodeSizeInterval[0];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   402
		scale = this.getScale(this.rect);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   403
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   404
		if (this.parametres.log) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   405
			return this.parametres.nodeSizeInterval[0] + Math.log(poids/(this.poidsMin*scale))*diff/Math.log(this.poidsMax/this.poidsMin);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   406
			
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   407
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   408
		else if (this.parametres.exp) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   409
			return this.parametres.nodeSizeInterval[0]*Math.exp(Math.log(this.parametres.nodeSizeInterval[1]/this.parametres.nodeSizeInterval[0])*(poids-(this.poidsMin*scale))/(scale*(this.poidsMax - this.poidsMin)));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   410
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   411
		else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   412
			return scale*((this.parametres.nodeSizeInterval[0] + diff*(poids - scale*this.poidsMin)/(scale*(this.poidsMax - this.poidsMin))));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   413
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   414
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   415
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   416
	//affichages des noeuds
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   417
	showNodes: function() {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   418
		var object = this;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   419
		node = this.svg.selectAll("circle.node")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   420
			 .data(this.data.nodes)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   421
			 .enter().append("circle")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   422
			 .attr("class", "node")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   423
			 .attr("cx", function(d) { return d.x; })
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   424
			 .attr("cy", function(d) { return d.y; })
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   425
			 .attr("z-index", 0)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   426
			 .attr("r", function(d) {return object.radius(d.poids);})
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   427
			 .style("fill", function(d) { 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   428
				 return object.parametres.couleurs.get(d.group);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   429
			 });
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   430
			 /*.on("mouseover", this.nodeMouseover)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   431
			 .on("mouseout", this.nodeMouseout)*/;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   432
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   433
		// Register all nodes
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   434
		if (null!=object.parametres.relations) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   435
			 node.each(function(datum, index) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   436
				 datum["registrationName"] = object.parametres.name + ".node." + index; 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   437
				 object.parametres.relations.add(
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   438
						 datum.registrationName, d3.select(this))
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   439
					.mouseover(object.nodeMouseover)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   440
					.mouseout(object.nodeMouseout);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   441
		 	});
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   442
		 }
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   443
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   444
		node.append("p")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   445
			.text(function(d) { return d.titre; });
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   446
		node.on('click', this.nodeClick);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   447
		console.log("Noeuds OK.");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   448
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   449
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   450
	//génération du fond de la carte
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   451
	createBackground: function() {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   452
		var circlePaths = [];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   453
		scale = this.getScale(this.rect);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   454
		object = this;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   455
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   456
		this.svg.selectAll('circle.node').each(function(d) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   457
			var node = d3.select(this);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   458
			var circle = new paper.Path.Circle(
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   459
					new paper.Point(d.x, d.y), object.radius(d.scaledPoids)*2);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   460
			circle.fillColor = node.style("fill");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   461
			circlePaths.push(circle);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   462
		});
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   463
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   464
		console.log("Fond des noeuds OK.");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   465
		this.generateConnections(circlePaths);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   466
		paper.view.draw();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   467
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   468
		/*var endDate = new Date();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   469
		var timer = endDate.getTime() - beginDate.getTime();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   470
		console.log(timer);*/
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   471
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   472
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   473
	//generate background connections between nodes of a same cluster
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   474
	generateConnections: function(paths) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   475
		for (var c=0; c<this.clusters.length; ++c) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   476
			var cluster = this.clusters[c];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   477
			
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   478
			// définir les données suivant le type passé
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   479
			var group = cluster.items;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   480
			if (undefined==group) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   481
				group = cluster.core.concat(cluster.agregated);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   482
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   483
				
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   484
			var layer = new paper.Layer();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   485
			
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   486
			// Donner un design au fond
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   487
			for (var attr in this.parametres.layerStyle) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   488
				if (layer[attr]) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   489
					layer[attr] = this.parametres.layerStyle[attr];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   490
				}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   491
				else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   492
					layer.style[attr] = this.parametres.layerStyle[attr];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   493
				}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   494
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   495
			
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   496
			var maxDistance = this.scale(this.rect[0][0].getAttribute("x"))*this.parametres.maxDistance,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   497
				handle = this.parametres.handle_len_rate;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   498
			for (var i = 1; i<group.length; ++i) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   499
				var circle = paths[group[i].key];
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   500
				if ((circle.position.x + maxDistance > 0) && (circle.position.x < this.parametres.width + maxDistance) && (circle.position.y + maxDistance > 0) && (circle.position.y < this.parametres.height + maxDistance)) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   501
					layer.appendTop(circle);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   502
					for (var j = 0; j<i; ++j) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   503
						var path = this.connect(circle, paths[group[j].key], 0.5, handle, maxDistance);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   504
						if (null!=path) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   505
							layer.appendTop(path);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   506
						}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   507
					}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   508
				}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   509
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   510
			
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   511
			this.zones[c] = layer;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   512
			if (null != this.parametres.relations) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   513
				this.parametres.relations.add(this.parametres.selectorID + ".layer." + c, layer);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   514
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   515
			
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   516
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   517
		paper.project.layers[0].remove();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   518
		console.log("Connexions OK.");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   519
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   520
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   521
	/*
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   522
	 * Create a connection between two balls
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   523
	 */
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   524
	connect: function(ball1, ball2, v, handle_len_rate, maxDistance) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   525
	    var center1 = ball1.position;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   526
	    var center2 = ball2.position;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   527
	    var radius1 = ball1.bounds.width / 2;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   528
	    var radius2 = ball2.bounds.width / 2;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   529
	    var pi2 = Math.PI / 2;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   530
	    var d = center1.getDistance(center2);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   531
	    var u1, u2;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   532
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   533
	    if (radius1 == 0 || radius2 == 0) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   534
	        return null;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   535
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   536
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   537
	    if (d > maxDistance || d <= Math.abs(radius1 - radius2)) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   538
	        return;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   539
	    } else if (d < radius1 + radius2) { // case circles are overlapping
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   540
	        return null;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   541
	    } else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   542
	        u1 = 0;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   543
	        u2 = 0;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   544
	    }
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   545
	    
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   546
	    var center3 = center2.clone();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   547
	    center3.x = center2.x - center1.x;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   548
	    center3.y = center2.y - center1.y;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   549
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   550
	    var angle1 = center3.getAngleInRadians();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   551
	    var angle2 = Math.acos((radius1 - radius2) / d);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   552
	    var angle1a = angle1 + u1 + (angle2 - u1) * v;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   553
	    var angle1b = angle1 - u1 - (angle2 - u1) * v;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   554
	    var angle2a = angle1 + Math.PI - u2 - (Math.PI - u2 - angle2) * v;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   555
	    var angle2b = angle1 - Math.PI + u2 + (Math.PI - u2 - angle2) * v;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   556
	    var p1a = center1.add(this.getVector(angle1a, radius1));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   557
	    var p1b = center1.add(this.getVector(angle1b, radius1));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   558
	    var p2a = center2.add(this.getVector(angle2a, radius2));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   559
	    var p2b = center2.add(this.getVector(angle2b, radius2));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   560
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   561
	    // define handle length by the distance between
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   562
	    // both ends of the curve to draw
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   563
	    var totalRadius = (radius1 + radius2);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   564
	    var p3a = p2a.clone();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   565
	    p3a.x = p1a.x - p2a.x;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   566
	    p3a.y = p1a.y - p2a.y;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   567
	    var d2 = Math.min(v * handle_len_rate, p3a.length / totalRadius);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   568
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   569
	    // case circles are overlapping:
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   570
	    d2 *= Math.min(1, d * 2 / (radius1 + radius2));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   571
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   572
	    radius1 *= d2;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   573
	    radius2 *= d2;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   574
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   575
	    var path = new paper.Path([p1a, p2a, p2b, p1b]);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   576
	    path.style = ball1.style;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   577
	    path.closed = true;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   578
	    var segments = path.segments;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   579
	    segments[0].handleOut = this.getVector(angle1a - pi2, radius1);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   580
	    segments[1].handleIn = this.getVector(angle2a + pi2, radius2);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   581
	    segments[2].handleOut = this.getVector(angle2b - pi2, radius2);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   582
	    segments[3].handleIn = this.getVector(angle1b + pi2, radius1);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   583
	    return path;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   584
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   585
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   586
	// ------------------------------------------------
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   587
	getVector: function(radians, length) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   588
		var angle = radians * 180 / Math.PI;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   589
	    return new paper.Point({"angle": angle,
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   590
	        "length": length
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   591
	    });
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   592
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   593
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   594
	//apparition de l'infoBulle
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   595
	highlight: function(node) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   596
		scale = this.parametres.activerZoom ? this.scale(this.rect[0][0].getAttribute("x")) : 1;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   597
		this.infoBulle.html(this.parametres.infobulleHtml(node));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   598
		if (this.infoBulle.classed("selected")) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   599
			this.infoBulle.transition()
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   600
				.duration(500)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   601
				.style("left", node.x + "px")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   602
				.style("top", node.y + "px");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   603
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   604
		else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   605
			this.infoBulle.classed("selected", true)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   606
				.style("left", node.x + "px")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   607
				.style("top", node.y + "px")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   608
				.transition()
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   609
				.duration(300)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   610
				.style("opacity", 0.5);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   611
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   612
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   613
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   614
	//disparition de l'infoBulle
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   615
	blur: function() {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   616
		this.infoBulle.classed("selected", false)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   617
			.transition()
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   618
			.duration(400)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   619
			.style("opacity", 0);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   620
		this.infoBulle.style("top", this.parametres.height);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   621
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   622
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   623
	//zoom sur un point
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   624
	grow: function(node, scale) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   625
		if (!this.static) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   626
			node.attr("z-index", 1)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   627
				.transition()
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   628
				.duration(200)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   629
				.attr("r", this.parametres.nodeSizeInterval[1]*scale);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   630
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   631
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   632
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   633
	//dézoom sur un point
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   634
	shrink: function(radius, node) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   635
		if (!this.static) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   636
			node.transition()
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   637
				.duration(70)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   638
				.attr("z-index", 0)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   639
				.attr("r", radius);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   640
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   641
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   642
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   643
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   644
	//réaffichage du fond sur recadrage du navigateur
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   645
	onResize: function(event) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   646
		paper.view.draw();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   647
		d3.select('#' + this.parametres.canvasID)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   648
			.attr("width", d3.select('#' + this.parametres.selectorID).attr("width"))
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   649
			.attr("height", d3.select('#' + this.parametres.selectorID).attr("height"));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   650
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   651
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   652
	dragstart: function(d,i, object) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   653
    	object.rect.xi = object.scale(d3.event.x);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   654
    	object.static = true;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   655
    },
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   656
    
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   657
	dragmove: function(d, i) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   658
		d.x += d3.event.dx;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   659
		d3.select(this).attr("x", d.x);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   660
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   661
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   662
	dragend: function(d, i, object) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   663
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   664
		var ratio = object.scale(d3.event.x)/object.rect.xi;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   665
		object.infoBulle.classed("selected", false)
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   666
			.style("opacity", 0);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   667
			
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   668
		object.zoom(ratio);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   669
		object.resetCanvas();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   670
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   671
		object.zoomTransition(ratio);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   672
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   673
		object.static = false;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   674
		var timer = new Date().getTime() - object.beginDate.getTime();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   675
		console.log(timer);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   676
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   677
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   678
	resetCanvas: function() {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   679
		paper.view.remove();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   680
		this.hideView();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   681
		paper.setup(this.canvas);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   682
		paper.view.viewSize = new paper.Size(this.parametres.width, this.parametres.height);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   683
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   684
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   685
	hideView: function() {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   686
		var ctx = this.canvas.getContext('2d');
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   687
		ctx.fillStyle = 'rgb(0,0,0)';
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   688
		ctx.fillRect(this.canvas.left, this.canvas.top, this.canvas.width, this.canvas.height);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   689
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   690
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   691
	scale: function(x) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   692
		return (this.parametres.scaleInterval[0] + (this.parametres.scaleInterval[1] - this.parametres.scaleInterval[0])*(x/this.parametres.width));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   693
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   694
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   695
	getScale: function(rect) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   696
		if (rect == undefined || !this.parametres.activerZoom) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   697
			return 1;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   698
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   699
		else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   700
			if (this.parametres.zoomNode) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   701
				return this.scale(rect[0][0].getAttribute("x"));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   702
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   703
			else if (this.parametres.logZoomNode) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   704
				return Math.log(1 + this.scale(rect[0][0].getAttribute("x"))*this.parametres.logZoomNodeParameter)/(Math.log(1 + this.parametres.logZoomNodeParameter));
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   705
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   706
			else {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   707
				return 1;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   708
			}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   709
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   710
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   711
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   712
	zoom: function(ratio) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   713
		var object = this;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   714
		var scale = this.getScale(this.rect);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   715
		
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   716
		this.svg.selectAll("circle.node")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   717
			.each(function(d) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   718
				d.x = object.parametres.width/2 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   719
					- ratio*(object.parametres.width/2- d.x);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   720
				
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   721
				d.y = object.parametres.height/2 
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   722
					- ratio*(object.parametres.height/2 - d.y);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   723
				
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   724
				d.scaledPoids = d.poids*scale;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   725
			});
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   726
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   727
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   728
	zoomTransition: function(ratio) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   729
		var object = this;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   730
		var c = 0;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   731
		this.svg.selectAll("circle.node")
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   732
			.transition()
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   733
				.duration(Math.max(400*ratio, 400/ratio))
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   734
				.attr("cx", function(d) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   735
					return d.x;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   736
				})
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   737
				.attr("cy", function(d) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   738
					return d.y;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   739
				})
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   740
				.attr("r", function(d) { return object.radius(d.scaledPoids);})
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   741
				.each("end", function() {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   742
					c++;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   743
					if (c == object.length) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   744
						object.static = false;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   745
						object.createBackground();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   746
					}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   747
				});
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   748
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   749
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   750
	mouseDown: function(e) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   751
		this.isDown = true;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   752
		this.mouse.x = e.x;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   753
		this.mouse.y = e.y;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   754
		this.center = {};
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   755
		/*this.center.x = paper.view.center.x;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   756
		this.center.y = paper.view.center.y;*/
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   757
		var object = this;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   758
		setTimeout(function() {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   759
				if (object.isDown) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   760
					object.blur();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   761
					//d3.select(object.canvas).style("visibility", "hidden");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   762
					object.resetCanvas();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   763
					object.static = true;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   764
					object.drag2 = true;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   765
				}	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   766
			}, 100);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   767
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   768
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   769
	mouseMove: function(e) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   770
		if (this.drag2) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   771
			diff = {};
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   772
			diff.x = e.x - this.mouse.x;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   773
			diff.y = e.y - this.mouse.y;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   774
			/*this.center.x -= diff.x;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   775
			this.center.y -= diff.y;*/
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   776
			this.svg.selectAll('circle.node')
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   777
				.attr("cx", function(d) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   778
					d.x += diff.x;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   779
					return d.x;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   780
					})
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   781
				.attr("cy", function(d) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   782
					d.y += diff.y;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   783
					return d.y;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   784
					});
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   785
			this.mouse.x = e.x; this.mouse.y = e.y;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   786
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   787
	},
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   788
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   789
	mouseUp: function(e) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   790
		if (this.drag2) {
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   791
			//paper.view.center = new paper.Point(this.center.x, this.center.y);
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   792
			//d3.select(object.canvas).style("visibility", "visible");
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   793
			this.createBackground();
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   794
			this.static = false;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   795
			this.drag2 = false;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   796
		}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   797
		this.isDown = false;
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   798
		this.mouse = {};
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   799
	}
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   800
	
8ca7f2cea729 add alcatel folder
cobled@FRVILN0H401086.emea.lucent.com
parents:
diff changeset
   801
};