2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/605f4d69d5db/ changeset: 605f4d69d5db user: jgoecks date: 2012-10-16 19:43:57 summary: Circster cleanup: remove track indexes and make renderers into views. affected #: 1 file diff -r 0391351559dd124f305245a9d27f071f28debc54 -r 605f4d69d5db3f9bbfc949ac22ba5ee744649a5f static/scripts/viz/circster.js --- a/static/scripts/viz/circster.js +++ b/static/scripts/viz/circster.js @@ -1,8 +1,5 @@ define(["libs/underscore", "libs/d3", "viz/visualization"], function(_, d3, visualization) { -// General backbone style inheritence -var Base = function() { this.initialize && this.initialize.apply(this, arguments); }; Base.extend = Backbone.Model.extend; - var SVGUtils = Backbone.Model.extend({ /** @@ -51,11 +48,10 @@ this.track_gap = 5; this.label_arc_height = 20; this.scale = 1; - this.track_renderers = null; + this.track_views = null; // When track added to the model, add to view as well. this.model.get('tracks').on('add', this.add_track, this); - }, /** @@ -103,7 +99,7 @@ "translate(" + d3.event.translate + ")" + " scale(" + scale + ")"); - // Propagate scale changes to renderers. + // Propagate scale changes to views. if (self.scale !== scale) { // Use timeout to wait for zooming/dragging to stop before rendering more detail. if (self.zoom_drag_timeout) { @@ -111,8 +107,8 @@ } self.zoom_drag_timeout = setTimeout(function() { // Render more detail in tracks' visible elements. - _.each(self.track_renderers, function(renderer) { - renderer.update_scale(scale); + _.each(self.track_views, function(view) { + view.update_scale(scale); }); }, 400); } @@ -123,23 +119,23 @@ // -- Render each dataset in the visualization. -- - // Create a renderer for each track in the visualiation and render. - this.track_renderers = tracks.map(function(track, index) { - track_renderer_class = (track.get('track_type') === 'LineTrack' ? - CircsterBigWigTrackRenderer : - CircsterSummaryTreeTrackRenderer ); + // Create a view for each track in the visualiation and render. + this.track_views = tracks.map(function(track, index) { + track_view_class = (track.get('track_type') === 'LineTrack' ? + CircsterBigWigTrackView : + CircsterSummaryTreeTrackView ); - return new track_renderer_class({ + return new track_view_class({ + el: svg.append('g')[0], track: track, - track_index: index, radius_bounds: tracks_bounds[index], genome: self.genome, total_gap: self.total_gap }); }); - _.each(this.track_renderers, function(renderer) { - renderer.render(svg); + _.each(this.track_views, function(view) { + view.render(); }); // -- Render chromosome labels. -- @@ -147,56 +143,57 @@ // Set radius start = end for track bounds. var track_bounds = tracks_bounds[tracks.length]; track_bounds[1] = track_bounds[0]; - this.label_track_renderer = new CircsterLabelTrackRenderer({ + this.label_track_view = new CircsterLabelTrackView({ + el: svg.append('g')[0], track: new CircsterLabelTrack(), - track_index: tracks.length, radius_bounds: track_bounds, genome: self.genome, total_gap: self.total_gap }); - this.label_track_renderer.render(svg); + this.label_track_view.render(); }, /** * Render a single track on the outside of the current visualization. */ add_track: function(new_track) { - // Reset scale and zoom. + // TODO: Reset scale and zoom. // Recompute and update track bounds. var new_track_bounds = this.get_tracks_bounds(); - _.each(this.track_renderers, function(track_renderer, i) { + _.each(this.track_views, function(track_view, i) { //console.log(self.get_tracks_bounds(), i); - track_renderer.update_radius_bounds(new_track_bounds[i]); + track_view.update_radius_bounds(new_track_bounds[i]); }); // Render new track. - var track_index = this.track_renderers.length - track_renderer_class = (new_track.get('track_type') === 'LineTrack' ? - CircsterBigWigTrackRenderer : - CircsterSummaryTreeTrackRenderer ), - track_renderer = new track_renderer_class({ + var track_index = this.track_views.length + track_view_class = (new_track.get('track_type') === 'LineTrack' ? + CircsterBigWigTrackView : + CircsterSummaryTreeTrackView ), + track_view = new track_view_class({ + el: d3.select('g.tracks').append('g')[0], track: new_track, - track_index: track_index, radius_bounds: new_track_bounds[track_index], genome: this.genome, total_gap: this.total_gap }); - track_renderer.render(d3.select('g.tracks')); - this.track_renderers.push(track_renderer); + track_view.render(); + this.track_views.push(track_view); // Update label track. var track_bounds = new_track_bounds[ new_track_bounds.length-1 ]; track_bounds[1] = track_bounds[0]; - this.label_track_renderer.update_radius_bounds(track_bounds); + this.label_track_view.update_radius_bounds(track_bounds); } }); /** * Renders a track in a Circster visualization. */ -var CircsterTrackRenderer = Base.extend({ +var CircsterTrackView = Backbone.View.extend({ + tagName: 'g', /* ----------------------- Public Methods ------------------------- */ @@ -210,17 +207,20 @@ this.options.chroms_layout = this._chroms_layout(); this.options.data_bounds = []; this.options.scale = 1; - this.options.parent_elt = null; + this.options.parent_elt = d3.select(this.$el[0]); }, /** * Render track's data by adding SVG elements to parent. */ - render: function(parent) { + render: function() { // -- Create track group element. -- - this.options.parent_elt = parent.append("g").attr("id", "parent-" + this.options.track_index); var track_parent_elt = this.options.parent_elt; + if (!track_parent_elt) { + console.log('no parent elt'); + } + // -- Render background arcs. -- var genome_arcs = this.options.chroms_layout, arc_gen = d3.svg.arc() @@ -306,7 +306,7 @@ }, /** - * Update renderer scale. This fetches more data if scale is increased. + * Update view scale. This fetches more data if scale is increased. */ update_scale: function(new_scale) { // -- Update scale and return if new scale is less than old scale. -- @@ -432,13 +432,12 @@ /** * Render chromosome labels. */ -var CircsterLabelTrackRenderer = CircsterTrackRenderer.extend({ +var CircsterLabelTrackView = CircsterTrackView.extend({ initialize: function(options) { - this.options = options; + CircsterTrackView.prototype.initialize.call(this, options); this.options.bg_stroke = 'fff'; this.options.bg_fill = 'fff'; - this.options.chroms_layout = this._chroms_layout(); }, /** @@ -467,9 +466,9 @@ }); /** - * Rendered for quantitative data. + * View for quantitative track in Circster. */ -var CircsterQuantitativeTrackRenderer = CircsterTrackRenderer.extend({ +var CircsterQuantitativeTrackView = CircsterTrackView.extend({ /** * Renders quantitative data with the form [x, value] and assumes data is equally spaced across @@ -533,7 +532,7 @@ /** * Layout for summary tree data in a circster visualization. */ -var CircsterSummaryTreeTrackRenderer = CircsterQuantitativeTrackRenderer.extend({ +var CircsterSummaryTreeTrackView = CircsterQuantitativeTrackView.extend({ get_data_bounds: function(data) { // Get max across data. @@ -546,9 +545,9 @@ }); /** - * Layout for BigWig data in a circster visualization. + * Bigwig track view in Circster */ -var CircsterBigWigTrackRenderer = CircsterQuantitativeTrackRenderer.extend({ +var CircsterBigWigTrackView = CircsterQuantitativeTrackView.extend({ get_data_bounds: function(data) { // Set max across dataset by extracting all values, flattening them into a https://bitbucket.org/galaxy/galaxy-central/changeset/e1ea65232d19/ changeset: e1ea65232d19 user: jgoecks date: 2012-10-16 19:45:08 summary: Merge affected #: 1 file diff -r 605f4d69d5db3f9bbfc949ac22ba5ee744649a5f -r e1ea65232d19a053be0725a91b47a1d81e309ee6 lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -259,7 +259,7 @@ can_generate_dependency_metadata = False tool_dependency_name = elem.get( 'name', None ) if tool_dependency_name and tool_dependency_version: - for tool_dict in metadata_dict[ 'tools' ]: + for tool_dict in metadata_dict.get( 'tools', [] ): requirements = tool_dict.get( 'requirements', [] ) for requirement_dict in requirements: req_name = requirement_dict.get( 'name', None ) @@ -281,7 +281,7 @@ # <environment_variable name="R_SCRIPT_PATH" action="set_to">$REPOSITORY_INSTALL_DIR</environment_variable> env_var_name = env_var_elem.get( 'name', None ) if env_var_name: - for tool_dict in metadata_dict[ 'tools' ]: + for tool_dict in metadata_dict.get( 'tools', [] ): requirements = tool_dict.get( 'requirements', [] ) for requirement_dict in requirements: # {"name": "R_SCRIPT_PATH", "type": "set_environment", "version": null} 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.