# HG changeset patch # User veltr # Date 1343237791 -7200 # Node ID 45cca39b00ac4d262fd0ef605ccbac7cc6b5178f # Parent 4b07ff5c2dd6c54d09bcbca367d5930481cdf5b3 First rendering tests diff -r 4b07ff5c2dd6 -r 45cca39b00ac client/data/test-data.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/data/test-data.json Wed Jul 25 19:36:31 2012 +0200 @@ -0,0 +1,112 @@ +{ + "title": "Test Graph", + "creation_date": "2012-07-25T11:00:00.0Z", + "users": [ + { + "id": "u-cybunk", + "title": "Samuel", + "uri": "http://twitter.com/cybunk", + "color": "#e00000" + }, + { + "id": "u-raphv", + "title": "Raphael", + "uri": "http://twitter.com/raphv", + "color": "#00a000" + } + ], + "nodes": [ + { + "id": "n-001", + "title": "連環 (Renkan)", + "uri": "http://ja.wikipedia.org/wiki/%E7%99%BE%E5%AD%A6%E9%80%A3%E7%92%B0", + "created_by": "u-cybunk", + "position": { + "x": 0, + "y": 0 + } + }, + { + "id": "n-002", + "title": "Savoir", + "uri": "http://fr.wikipedia.org/wiki/Savoir", + "created_by": "u-raphv", + "position": { + "x": 200, + "y": 50 + } + }, + { + "id": "n-003", + "title": "Connaissance", + "uri": "http://fr.wikipedia.org/wiki/Connaissance", + "created_by": "u-raphv", + "position": { + "x": 300, + "y": -50 + } + }, + { + "id": "n-004", + "title": "graphe", + "uri": "http://fr.wikipedia.org/wiki/Th%C3%A9orie_des_graphes", + "created_by": "u-cybunk", + "position": { + "x": -200, + "y": 0 + } + }, + { + "id": "n-005", + "title": "nœud", + "uri": "http://fr.wikipedia.org/wiki/Th%C3%A9orie_des_graphes", + "created_by": "u-cybunk", + "position": { + "x": -300, + "y": 100 + } + }, + { + "id": "n-006", + "title": "lien", + "uri": "http://fr.wikipedia.org/wiki/Th%C3%A9orie_des_graphes", + "created_by": "u-cybunk", + "position": { + "x": -300, + "y": -100 + } + } + ], + "edges": [ + { + "id": "e-001", + "from": "n-001", + "to": "n-002", + "created_by": "u_raphv" + }, + { + "id": "e-002", + "from": "n-002", + "to": "n-003", + "created_by": "u_raphv" + }, + { + "id": "e-003", + "from": "n-001", + "to": "n-004", + "created_by": "u_cybunk" + }, + { + "id": "e-004", + "from": "n-004", + "to": "n-005", + "created_by": "u_cybunk" + }, + { + "id": "e-005", + "from": "n-004", + "to": "n-006", + "created_by": "u_cybunk" + } + ] +} diff -r 4b07ff5c2dd6 -r 45cca39b00ac client/js/json-serializer.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/js/json-serializer.js Wed Jul 25 19:36:31 2012 +0200 @@ -0,0 +1,42 @@ +Rkns.Serializers.BasicJson = Rkns.Utils.inherit(Rkns.Serializers._Base); + +Rkns.Serializers.BasicJson.prototype._init = function() { + this.load(this._project._opts.url); +} + +Rkns.Serializers.BasicJson.prototype.load = function(_url) { + var _this = this; + Rkns.$.getJSON(_url, function(_data) { + _this.deserialize(_data); + _this.handleCallbacks(); + }); +} + +Rkns.Serializers.BasicJson.prototype.deserialize = function(_serializedData) { + if (typeof _serializedData === "string") { + _serializedData = JSON.parse(_serializedData); + } + var _proj = this._project; + _proj.title = _serializedData.title || "(untitled project)"; + if (typeof _serializedData.users === "object" && _serializedData.users) { + _proj.users.addElements( + Rkns._(_serializedData.users).map(function(_userData) { + return new Rkns.Model.User(_proj, _userData); + }) + ); + } + if (typeof _serializedData.nodes === "object" && _serializedData.nodes) { + _proj.nodes.addElements( + Rkns._(_serializedData.nodes).map(function(_nodeData) { + return new Rkns.Model.Node(_proj, _nodeData); + }) + ); + } + if (typeof _serializedData.edges === "object" && _serializedData.edges) { + _proj.edges.addElements( + Rkns._(_serializedData.edges).map(function(_edgeData) { + return new Rkns.Model.Edge(_proj, _edgeData); + }) + ); + } +} diff -r 4b07ff5c2dd6 -r 45cca39b00ac client/js/main.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/js/main.js Wed Jul 25 19:36:31 2012 +0200 @@ -0,0 +1,128 @@ +/* + * Copyright 2012 Institut de recherche et d'innovation + * contributor(s) : Samuel Huron, Raphael Velt + * + * contact@iri.centrepompidou.fr + * http://www.iri.centrepompidou.fr + * + * This software is a computer program whose purpose is to show and add annotations on a video . + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-C license and that you accept its terms. +*/ + +/* Declaring the Renkan Namespace Rkns */ + +Rkns = {} + +Rkns.$ = jQuery; + +Rkns._ = _; + +Rkns.Serializers = {}; + +Rkns.Serializers._Base = function(_project) { + if (typeof _project !== "undefined") { + this._project = _project; + this._callbackQueue = []; + this._loaded = false; + } +} + +Rkns.Serializers._Base.prototype.deserialize = function() {} + +Rkns.Serializers._Base.prototype.deferCallback = function(_callback) { + var _this = this; + Rkns._.defer(function() { + _callback.call(_this); + }); +} + +Rkns.Serializers._Base.prototype.handleCallbacks = function() { + this._loaded = true; + while (this._callbackQueue.length) { + this.deferCallback(this._callbackQueue.splice(0,1)[0]); + } +} + +Rkns.Serializers._Base.prototype.onLoad = function(_callback) { + if (this._loaded) { + this.deferCallback(_callback); + } else { + this._callbackQueue.push(_callback); + } +} + +Rkns.Renderers = {}; + +Rkns.Renderers._Base = function(_project) { + if (typeof _project !== "undefined") { + this._project = _project; + } +} + +Rkns.Project = function(_opts) { + if (typeof _opts.serializer == "undefined") { + _opts.serializer = "BasicJson"; + } + if (typeof _opts.renderer == "undefined") { + _opts.renderer = "Paper"; + } + this._opts = _opts; + this.users = new Rkns.Model.List(); + this.nodes = new Rkns.Model.List(); + this.edges = new Rkns.Model.List(); + this.serializer = new Rkns.Serializers[_opts.serializer](this); + this.renderer = new Rkns.Renderers[_opts.renderer](this); + var _this = this; + this.serializer.onLoad(function() { + _this.renderer.draw(); + }) +} + +/* Utility functions */ + +Rkns.Utils = { + _ID_AUTO_INCREMENT : 0, + _ID_BASE : (function(_d) { + function pad(n){return n<10 ? '0'+n : n} + function fillrand(n) { + var _res = '' + for (var i=0; i + + + + + Test de Rendu RENKAN + + + + + + + + + + + + + + + + +