// // This work is licensed under the Creative Commons Attribution 2.5 License. To // view a copy of this license, visit // http://creativecommons.org/licenses/by/2.5/ // or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San // Francisco, California, 94105, USA. // // All copies and derivatives of this source must contain the license statement // above and the following attribution: // // Author: Kyle Scholz http://kylescholz.com/ // Copyright: 2006 // /** * A very shallow extend() method. Simply inherit properties of the indicated class * when they don't conflict with anything already in our prototype. */ Function.prototype.extend = function( inheritFrom ) { for( property in inheritFrom.prototype ) { if ( !( property in this.prototype ) ) { this.prototype[property] = inheritFrom.prototype[property]; } } } /** * GraphModel: * * Defines a prototype for GraphModel implementations. * * TODO: @extends TimerListener */ var GraphModel = function(){}; GraphModel.prototype = { // A collection of GraphModelListeners that want to receive updates from this graph subscribers: new Array(), // A collection of root nodes updateQueue: new Array(), // nextUID: 0, /* * Initialize the instance. */ initialize: function( frameWidth, frameHeight ) { this['frameWidth'] = frameWidth; this['frameHeight'] = frameHeight; }, /* * Update nodes in updateQueue. * * @overrides TimerListener.update */ update: function() { throw( "update: Method not implemented.") }, /* * Add a subscriber. * * TODO: verify that listener conforms to interface */ subscribe: function( graphModelListener ) { this['subscribers'].push( graphModelListener ); }, /* * Add a node to the Graph. This method must be overriden. * * @throws "Method not implemented." */ addNode: function() { throw( "addNode: Method not implemented.") }, /* * Add a new edge to the Graph. This method must be overriden. * * @throws "Method not implemented." */ addEdge: function() { throw( "addEdge: Method not implemented.") } }