From f13c5eed0f5bbe2081901e171fe2ebe030ba73aa Mon Sep 17 00:00:00 2001 From: Robert Buels Date: Sat, 3 Nov 2012 10:28:35 -0400 Subject: [PATCH] introduce `track.maxFeatureScreenDensity` and `track.layoutPitchY` config variables, which control when the "too many features" message displays, and the vertical pitch of the track layout engine. will probably leave layoutPitchY undocumented, it would go away if we change the feature layout engine. --- src/JBrowse/View/Track/Alignments.js | 15 ++++----- src/JBrowse/View/Track/HTMLFeatures.js | 43 +++++++++++++++++--------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/JBrowse/View/Track/Alignments.js b/src/JBrowse/View/Track/Alignments.js index 5a560c7827..d9c1573f2a 100644 --- a/src/JBrowse/View/Track/Alignments.js +++ b/src/JBrowse/View/Track/Alignments.js @@ -11,16 +11,17 @@ return declare( HTMLFeatures, */ { - constructor: function() { - }, - _defaultConfig: function() { return Util.deepUpdate( dojo.clone( this.inherited(arguments) ), - { style: { - className: 'alignment', - arrowheadClass: 'arrowhead' - } + { + maxFeatureScreenDensity: 1.2, + layoutPitchY: 4, + style: { + histScale: 1, + className: 'alignment', + arrowheadClass: 'arrowhead' + } } ); }, diff --git a/src/JBrowse/View/Track/HTMLFeatures.js b/src/JBrowse/View/Track/HTMLFeatures.js index 286c114095..f7fcb9d0ce 100644 --- a/src/JBrowse/View/Track/HTMLFeatures.js +++ b/src/JBrowse/View/Track/HTMLFeatures.js @@ -109,6 +109,10 @@ HTMLFeatures = declare( HTMLFeatures, _defaultConfig: function() { return { description: true, + + maxFeatureScreenDensity: 0.5, + layoutPitchY: 6, + style: { className: "feature2", histScale: 4, @@ -412,18 +416,26 @@ HTMLFeatures = declare( HTMLFeatures, this._updatedLabelForBlockSize = blockBases; } - //console.log("scale: %d, histScale: %d", scale, this.histScale); - if( scale < stats.featureDensity * this.config.style.histScale ) { - // if our store offers density histograms, draw them - if( this.store.histograms ) { + // console.log(this.name+" scale: %d, density: %d, histScale: %d, screenDensity: %d", scale, stats.featureDensity, this.config.style.histScale, stats.featureDensity / scale ); + + // if we our store offers density histograms, and we are zoomed out far enough, draw them + if( this.store.histograms && scale < stats.featureDensity * this.config.style.histScale ) { this.fillHist(blockIndex, block, leftBase, rightBase, stripeWidth, containerStart, containerEnd); - } - // otherwise, display a zoomed-out-too-far message - else { - this.fillMessage( blockIndex, block, 'Too many features to show'+(scale >= this.browser.view.maxPxPerBp ? '': '; zoom in to see detail')+'.' ); - } - } else { + } + // if we have no histograms, check the predicted density of + // features on the screen, and display a message if it's + // bigger than maxFeatureScreenDensity + else if( stats.featureDensity / scale > this.config.maxFeatureScreenDensity ) { + this.fillMessage( + blockIndex, + block, + 'Too many features to show' + + (scale >= this.browser.view.maxPxPerBp ? '': '; zoom in to see detail') + + '.' + ); + } + else { // if we have transitioned to viewing features, delete the // y-scale used for the histograms @@ -650,7 +662,7 @@ HTMLFeatures = declare( HTMLFeatures, featureStart = parseInt(featureStart); - var levelHeight = this.glyphHeight + 2; + var levelHeight = this.glyphHeight; // if the label extends beyond the feature, use the // label end position as the end position for layout @@ -664,11 +676,11 @@ HTMLFeatures = declare( HTMLFeatures, if( this.showLabels && scale >= this.labelScale ) { if (name) { featureEnd = Math.max(featureEnd, featureStart + (''+name).length * this.labelWidth / scale ); - levelHeight += this.labelHeight; + levelHeight += this.labelHeight + 1; } if( description ) { featureEnd = Math.max( featureEnd, featureStart + (''+description).length * this.labelWidth / scale ); - levelHeight += this.labelHeight; + levelHeight += this.labelHeight + 1; } } featureEnd += Math.max(1, this.padding / scale); @@ -956,7 +968,7 @@ HTMLFeatures = declare( HTMLFeatures, _getLayout: function( scale ) { // create the layout if we need to, and we can if( ( ! this.layout || this.layout.pitchX != 4/scale ) && scale ) - this.layout = new Layout({pitchX: 4/scale, pitchY: 4}); + this.layout = new Layout({pitchX: 4/scale, pitchY: this.layoutPitchY || this.config.layoutPitchY }); return this.layout; }, @@ -964,7 +976,8 @@ HTMLFeatures = declare( HTMLFeatures, delete this.layout; }, - // when all the blocks are hidden, we also should recalculate our layout + // when all the blocks are hidden, we also should recalculate our + // layout changed: function() { this.inherited(arguments); this._clearLayout();