Skip to content

Commit

Permalink
introduce track.maxFeatureScreenDensity and track.layoutPitchY co…
Browse files Browse the repository at this point in the history
…nfig 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.
  • Loading branch information
rbuels committed Nov 3, 2012
1 parent b576685 commit f13c5ee
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
15 changes: 8 additions & 7 deletions src/JBrowse/View/Track/Alignments.js
Expand Up @@ -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'
}
}
);
},
Expand Down
43 changes: 28 additions & 15 deletions src/JBrowse/View/Track/HTMLFeatures.js
Expand Up @@ -109,6 +109,10 @@ HTMLFeatures = declare( HTMLFeatures,
_defaultConfig: function() {
return {
description: true,

maxFeatureScreenDensity: 0.5,
layoutPitchY: 6,

style: {
className: "feature2",
histScale: 4,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -956,15 +968,16 @@ 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;
},
_clearLayout: function() {
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();
Expand Down

0 comments on commit f13c5ee

Please sign in to comment.