commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/54898b02d42a/ changeset: 54898b02d42a user: jgoecks date: 2012-06-15 23:43:54 summary: Visualization framework improvements. affected #: 5 files diff -r 0bd0c35351c4eb9c7103b6d737543317abc54ac0 -r 54898b02d42afdacaef261a49bbef18dd563365d static/scripts/mvc/tools.js --- a/static/scripts/mvc/tools.js +++ b/static/scripts/mvc/tools.js @@ -68,6 +68,16 @@ }, /** + * Set many input values at once. + */ + set_input_values: function(inputs_dict) { + var self = this; + _.each(_.keys(inputs_dict), function(input_name) { + self.set_input_value(input_name, inputs_dict[input_name]); + }); + }, + + /** * Run tool; returns a Deferred that resolves to the tool's output(s). */ run: function() { diff -r 0bd0c35351c4eb9c7103b6d737543317abc54ac0 -r 54898b02d42afdacaef261a49bbef18dd563365d static/scripts/viz/trackster.js --- a/static/scripts/viz/trackster.js +++ b/static/scripts/viz/trackster.js @@ -176,56 +176,6 @@ var extend = require('class').extend, slotting = require('slotting'), painters = require('painters'); - - -// ---- Canvas management and extensions ---- - -/** - * Canvas manager is used to create canvases, for browsers, this deals with - * backward comparibility using excanvas, as well as providing a pattern cache - */ -var CanvasManager = function( document, default_font ) { - this.document = document; - this.default_font = default_font !== undefined ? default_font : "9px Monaco, Lucida Console, monospace"; - - this.dummy_canvas = this.new_canvas(); - this.dummy_context = this.dummy_canvas.getContext('2d'); - this.dummy_context.font = this.default_font; - - this.char_width_px = this.dummy_context.measureText("A").width; - - this.patterns = {}; - - // FIXME: move somewhere to make this more general - this.load_pattern( 'right_strand', "/visualization/strand_right.png" ); - this.load_pattern( 'left_strand', "/visualization/strand_left.png" ); - this.load_pattern( 'right_strand_inv', "/visualization/strand_right_inv.png" ); - this.load_pattern( 'left_strand_inv', "/visualization/strand_left_inv.png" ); -} - -extend( CanvasManager.prototype, { - load_pattern: function( key, path ) { - var patterns = this.patterns, - dummy_context = this.dummy_context, - image = new Image(); - image.src = galaxy_paths.attributes.image_path + path; - image.onload = function() { - patterns[key] = dummy_context.createPattern( image, "repeat" ); - } - }, - get_pattern: function( key ) { - return this.patterns[key]; - }, - new_canvas: function() { - var canvas = this.document.createElement("canvas"); - // If using excanvas in IE, we need to explicately attach the canvas - // methods to the DOM element - if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); } - // Keep a reference back to the manager - canvas.manager = this; - return canvas; - } -}); // ---- Web UI specific utilities ---- @@ -2985,18 +2935,20 @@ this.data_url = ('data_url' in obj_dict ? obj_dict.data_url : default_data_url); this.data_url_extra_params = {} this.data_query_wait = ('data_query_wait' in obj_dict ? obj_dict.data_query_wait : DEFAULT_DATA_QUERY_WAIT); - this.dataset_check_url = converted_datasets_state_url; + this.dataset_check_url = ('converted_datasets_state_url' in obj_dict ? obj_dict.converted_datasets_state_url : converted_datasets_state_url); // A little ugly creating data manager right now due to transition to Backbone-based objects. - var dataset = new Dataset({ - id: obj_dict.dataset_id, - hda_ldda: obj_dict.hda_ldda - }); + var track = this, + dataset = new Dataset({ + id: obj_dict.dataset_id, + hda_ldda: obj_dict.hda_ldda + }); this.data_manager = ('data_manager' in obj_dict ? obj_dict.data_manager : new GenomeDataManager({ dataset: dataset, - data_url: default_data_url, + data_url: track.data_url, + dataset_state_url: track.dataset_check_url, data_mode_compatible: this.data_and_mode_compatible, can_subset: this.can_subset, })); diff -r 0bd0c35351c4eb9c7103b6d737543317abc54ac0 -r 54898b02d42afdacaef261a49bbef18dd563365d static/scripts/viz/trackster_ui.js --- a/static/scripts/viz/trackster_ui.js +++ b/static/scripts/viz/trackster_ui.js @@ -36,7 +36,7 @@ * Create new object from a template. A template can be either an object dictionary or an * object itself. */ -var object_from_template = function(template, container) { +var object_from_template = function(template, view, container) { if ('copy' in template) { // Template is an object. return template.copy(container); @@ -93,7 +93,7 @@ drawable_type, drawable; for (var i = 0; i < drawables_config.length; i++) { - view.add_drawable( object_from_template( drawables_config[i], view ) ); + view.add_drawable( object_from_template( drawables_config[i], view, view ) ); } } diff -r 0bd0c35351c4eb9c7103b6d737543317abc54ac0 -r 54898b02d42afdacaef261a49bbef18dd563365d static/scripts/viz/visualization.js --- a/static/scripts/viz/visualization.js +++ b/static/scripts/viz/visualization.js @@ -1,5 +1,7 @@ /** - * Model, view, and controller objects for Galaxy tools and tool panel. + * Model, view, and controller objects for Galaxy visualization framework. + * + * Required libraries: Backbone, jQuery * * Models have no references to views, instead using events to indicate state * changes; this is advantageous because multiple views can use the same object @@ -45,14 +47,66 @@ } }); +// TODO: move to Backbone + +/** + * Canvas manager is used to create canvases, for browsers, this deals with + * backward comparibility using excanvas, as well as providing a pattern cache + */ +var CanvasManager = function(default_font) { + this.default_font = default_font !== undefined ? default_font : "9px Monaco, Lucida Console, monospace"; + + this.dummy_canvas = this.new_canvas(); + this.dummy_context = this.dummy_canvas.getContext('2d'); + this.dummy_context.font = this.default_font; + + this.char_width_px = this.dummy_context.measureText("A").width; + + this.patterns = {}; + + // FIXME: move somewhere to make this more general + this.load_pattern( 'right_strand', "/visualization/strand_right.png" ); + this.load_pattern( 'left_strand', "/visualization/strand_left.png" ); + this.load_pattern( 'right_strand_inv', "/visualization/strand_right_inv.png" ); + this.load_pattern( 'left_strand_inv', "/visualization/strand_left_inv.png" ); +} + +_.extend( CanvasManager.prototype, { + load_pattern: function( key, path ) { + var patterns = this.patterns, + dummy_context = this.dummy_context, + image = new Image(); + image.src = galaxy_paths.attributes.image_path + path; + image.onload = function() { + patterns[key] = dummy_context.createPattern( image, "repeat" ); + } + }, + get_pattern: function( key ) { + return this.patterns[key]; + }, + new_canvas: function() { + var canvas = $("<canvas/>")[0]; + // If using excanvas in IE, we need to explicately attach the canvas + // methods to the DOM element + if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); } + // Keep a reference back to the manager + canvas.manager = this; + return canvas; + } +}); + /** * Generic cache that handles key/value pairs. */ var Cache = Backbone.Model.extend({ defaults: { num_elements: 20, - obj_cache: {}, - key_ary: [] + obj_cache: null, + key_ary: null + }, + + initialize: function(options) { + this.clear(); }, get_elt: function(key) { @@ -114,9 +168,36 @@ dataset: null, filters_manager: null, data_url: null, + dataset_state_url: null, data_mode_compatible: function(entry, mode) { return true; }, can_subset: function(entry) { return false; } }), + + /** + * Returns deferred that resolves to true when dataset is ready (or false if dataset + * cannot be used). + */ + data_is_ready: function() { + var dataset = this.get('dataset'), + ready_deferred = $.Deferred(), + ss_deferred = new ServerStateDeferred({ + ajax_settings: { + url: this.get('dataset_state_url'), + data: { + dataset_id: dataset.id, + hda_ldda: dataset.get('hda_ldda') + }, + dataType: "json" + }, + interval: 5000, + success_fn: function(response) { return response !== "pending"; } + }); + + $.when(ss_deferred.go()).then(function(response) { + ready_deferred.resolve(response === "ok" || response === "data" ); + }); + return ready_deferred; + }, /** * Load data from server; returns AJAX object so that use of Deferred is possible. @@ -366,6 +447,10 @@ end: this.get('end') }); }, + + length: function() { + return this.get('end') - this.get('start'); + }, /** Returns region in canonical form chrom:start-end */ toString: function() { @@ -438,6 +523,10 @@ } }); +var GenomeRegionCollection = Backbone.Collection.extend({ + model: GenomeRegion +}); + /** * A genome browser bookmark. */ diff -r 0bd0c35351c4eb9c7103b6d737543317abc54ac0 -r 54898b02d42afdacaef261a49bbef18dd563365d templates/base_panels.mako --- a/templates/base_panels.mako +++ b/templates/base_panels.mako @@ -53,7 +53,11 @@ var galaxy_paths = new GalaxyPaths({ root_path: '${h.url_for( "/" )}', image_path: '${h.url_for( "/static/images" )}', - tool_url: '${h.url_for( controller="/api/tools" )}' + tool_url: '${h.url_for( controller="/api/tools" )}', + data_url: '${h.url_for( controller="tracks", action="data" )}', + raw_data_url: '${h.url_for( controller="tracks", action="raw_data" )}', + converted_datasets_state_url: '${h.url_for( controller="tracks", action="converted_datasets_state" )}', + dataset_state_url: '${h.url_for( controller="tracks", action="dataset_state" )}' }); </script></%def> https://bitbucket.org/galaxy/galaxy-central/changeset/aaf5c82a5579/ changeset: aaf5c82a5579 user: jgoecks date: 2012-06-15 23:45:22 summary: Merge affected #: 5 files diff -r ccfcca670dfa5303d09a178473b663c15e5dc80a -r aaf5c82a55794c97125696aecb27056b5087fdb7 static/scripts/mvc/tools.js --- a/static/scripts/mvc/tools.js +++ b/static/scripts/mvc/tools.js @@ -68,6 +68,16 @@ }, /** + * Set many input values at once. + */ + set_input_values: function(inputs_dict) { + var self = this; + _.each(_.keys(inputs_dict), function(input_name) { + self.set_input_value(input_name, inputs_dict[input_name]); + }); + }, + + /** * Run tool; returns a Deferred that resolves to the tool's output(s). */ run: function() { diff -r ccfcca670dfa5303d09a178473b663c15e5dc80a -r aaf5c82a55794c97125696aecb27056b5087fdb7 static/scripts/viz/trackster.js --- a/static/scripts/viz/trackster.js +++ b/static/scripts/viz/trackster.js @@ -176,56 +176,6 @@ var extend = require('class').extend, slotting = require('slotting'), painters = require('painters'); - - -// ---- Canvas management and extensions ---- - -/** - * Canvas manager is used to create canvases, for browsers, this deals with - * backward comparibility using excanvas, as well as providing a pattern cache - */ -var CanvasManager = function( document, default_font ) { - this.document = document; - this.default_font = default_font !== undefined ? default_font : "9px Monaco, Lucida Console, monospace"; - - this.dummy_canvas = this.new_canvas(); - this.dummy_context = this.dummy_canvas.getContext('2d'); - this.dummy_context.font = this.default_font; - - this.char_width_px = this.dummy_context.measureText("A").width; - - this.patterns = {}; - - // FIXME: move somewhere to make this more general - this.load_pattern( 'right_strand', "/visualization/strand_right.png" ); - this.load_pattern( 'left_strand', "/visualization/strand_left.png" ); - this.load_pattern( 'right_strand_inv', "/visualization/strand_right_inv.png" ); - this.load_pattern( 'left_strand_inv', "/visualization/strand_left_inv.png" ); -} - -extend( CanvasManager.prototype, { - load_pattern: function( key, path ) { - var patterns = this.patterns, - dummy_context = this.dummy_context, - image = new Image(); - image.src = galaxy_paths.attributes.image_path + path; - image.onload = function() { - patterns[key] = dummy_context.createPattern( image, "repeat" ); - } - }, - get_pattern: function( key ) { - return this.patterns[key]; - }, - new_canvas: function() { - var canvas = this.document.createElement("canvas"); - // If using excanvas in IE, we need to explicately attach the canvas - // methods to the DOM element - if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); } - // Keep a reference back to the manager - canvas.manager = this; - return canvas; - } -}); // ---- Web UI specific utilities ---- @@ -2985,18 +2935,20 @@ this.data_url = ('data_url' in obj_dict ? obj_dict.data_url : default_data_url); this.data_url_extra_params = {} this.data_query_wait = ('data_query_wait' in obj_dict ? obj_dict.data_query_wait : DEFAULT_DATA_QUERY_WAIT); - this.dataset_check_url = converted_datasets_state_url; + this.dataset_check_url = ('converted_datasets_state_url' in obj_dict ? obj_dict.converted_datasets_state_url : converted_datasets_state_url); // A little ugly creating data manager right now due to transition to Backbone-based objects. - var dataset = new Dataset({ - id: obj_dict.dataset_id, - hda_ldda: obj_dict.hda_ldda - }); + var track = this, + dataset = new Dataset({ + id: obj_dict.dataset_id, + hda_ldda: obj_dict.hda_ldda + }); this.data_manager = ('data_manager' in obj_dict ? obj_dict.data_manager : new GenomeDataManager({ dataset: dataset, - data_url: default_data_url, + data_url: track.data_url, + dataset_state_url: track.dataset_check_url, data_mode_compatible: this.data_and_mode_compatible, can_subset: this.can_subset, })); diff -r ccfcca670dfa5303d09a178473b663c15e5dc80a -r aaf5c82a55794c97125696aecb27056b5087fdb7 static/scripts/viz/trackster_ui.js --- a/static/scripts/viz/trackster_ui.js +++ b/static/scripts/viz/trackster_ui.js @@ -36,7 +36,7 @@ * Create new object from a template. A template can be either an object dictionary or an * object itself. */ -var object_from_template = function(template, container) { +var object_from_template = function(template, view, container) { if ('copy' in template) { // Template is an object. return template.copy(container); @@ -93,7 +93,7 @@ drawable_type, drawable; for (var i = 0; i < drawables_config.length; i++) { - view.add_drawable( object_from_template( drawables_config[i], view ) ); + view.add_drawable( object_from_template( drawables_config[i], view, view ) ); } } diff -r ccfcca670dfa5303d09a178473b663c15e5dc80a -r aaf5c82a55794c97125696aecb27056b5087fdb7 static/scripts/viz/visualization.js --- a/static/scripts/viz/visualization.js +++ b/static/scripts/viz/visualization.js @@ -1,5 +1,7 @@ /** - * Model, view, and controller objects for Galaxy tools and tool panel. + * Model, view, and controller objects for Galaxy visualization framework. + * + * Required libraries: Backbone, jQuery * * Models have no references to views, instead using events to indicate state * changes; this is advantageous because multiple views can use the same object @@ -45,14 +47,66 @@ } }); +// TODO: move to Backbone + +/** + * Canvas manager is used to create canvases, for browsers, this deals with + * backward comparibility using excanvas, as well as providing a pattern cache + */ +var CanvasManager = function(default_font) { + this.default_font = default_font !== undefined ? default_font : "9px Monaco, Lucida Console, monospace"; + + this.dummy_canvas = this.new_canvas(); + this.dummy_context = this.dummy_canvas.getContext('2d'); + this.dummy_context.font = this.default_font; + + this.char_width_px = this.dummy_context.measureText("A").width; + + this.patterns = {}; + + // FIXME: move somewhere to make this more general + this.load_pattern( 'right_strand', "/visualization/strand_right.png" ); + this.load_pattern( 'left_strand', "/visualization/strand_left.png" ); + this.load_pattern( 'right_strand_inv', "/visualization/strand_right_inv.png" ); + this.load_pattern( 'left_strand_inv', "/visualization/strand_left_inv.png" ); +} + +_.extend( CanvasManager.prototype, { + load_pattern: function( key, path ) { + var patterns = this.patterns, + dummy_context = this.dummy_context, + image = new Image(); + image.src = galaxy_paths.attributes.image_path + path; + image.onload = function() { + patterns[key] = dummy_context.createPattern( image, "repeat" ); + } + }, + get_pattern: function( key ) { + return this.patterns[key]; + }, + new_canvas: function() { + var canvas = $("<canvas/>")[0]; + // If using excanvas in IE, we need to explicately attach the canvas + // methods to the DOM element + if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); } + // Keep a reference back to the manager + canvas.manager = this; + return canvas; + } +}); + /** * Generic cache that handles key/value pairs. */ var Cache = Backbone.Model.extend({ defaults: { num_elements: 20, - obj_cache: {}, - key_ary: [] + obj_cache: null, + key_ary: null + }, + + initialize: function(options) { + this.clear(); }, get_elt: function(key) { @@ -114,9 +168,36 @@ dataset: null, filters_manager: null, data_url: null, + dataset_state_url: null, data_mode_compatible: function(entry, mode) { return true; }, can_subset: function(entry) { return false; } }), + + /** + * Returns deferred that resolves to true when dataset is ready (or false if dataset + * cannot be used). + */ + data_is_ready: function() { + var dataset = this.get('dataset'), + ready_deferred = $.Deferred(), + ss_deferred = new ServerStateDeferred({ + ajax_settings: { + url: this.get('dataset_state_url'), + data: { + dataset_id: dataset.id, + hda_ldda: dataset.get('hda_ldda') + }, + dataType: "json" + }, + interval: 5000, + success_fn: function(response) { return response !== "pending"; } + }); + + $.when(ss_deferred.go()).then(function(response) { + ready_deferred.resolve(response === "ok" || response === "data" ); + }); + return ready_deferred; + }, /** * Load data from server; returns AJAX object so that use of Deferred is possible. @@ -366,6 +447,10 @@ end: this.get('end') }); }, + + length: function() { + return this.get('end') - this.get('start'); + }, /** Returns region in canonical form chrom:start-end */ toString: function() { @@ -438,6 +523,10 @@ } }); +var GenomeRegionCollection = Backbone.Collection.extend({ + model: GenomeRegion +}); + /** * A genome browser bookmark. */ diff -r ccfcca670dfa5303d09a178473b663c15e5dc80a -r aaf5c82a55794c97125696aecb27056b5087fdb7 templates/base_panels.mako --- a/templates/base_panels.mako +++ b/templates/base_panels.mako @@ -53,7 +53,11 @@ var galaxy_paths = new GalaxyPaths({ root_path: '${h.url_for( "/" )}', image_path: '${h.url_for( "/static/images" )}', - tool_url: '${h.url_for( controller="/api/tools" )}' + tool_url: '${h.url_for( controller="/api/tools" )}', + data_url: '${h.url_for( controller="tracks", action="data" )}', + raw_data_url: '${h.url_for( controller="tracks", action="raw_data" )}', + converted_datasets_state_url: '${h.url_for( controller="tracks", action="converted_datasets_state" )}', + dataset_state_url: '${h.url_for( controller="tracks", action="dataset_state" )}' }); </script></%def> Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket