Skip to content

Commit

Permalink
if a gene has no subfeatures, make it render like a Box glyph
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuels committed Sep 8, 2018
1 parent 5f2e5a0 commit b9e3e18
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/JBrowse/View/FeatureGlyph/Gene.js
Expand Up @@ -37,13 +37,16 @@ _ptGlyph: function() {
return this.__ptGlyph || ( this.__ptGlyph = new ProcessedTranscriptGlyph({ track: this.track, browser: this.browser, config: this.config }) );
},

_getFeatureRectangle: function( viewArgs, feature ) {
_getFeatureRectangle( viewArgs, feature ) {

// lay out rects for each of the subfeatures
// we need to lay out rects for each of the subfeatures
var subArgs = lang.mixin( {}, viewArgs );
subArgs.showDescriptions = subArgs.showLabels = false;
var subfeatures = feature.children();

// if this gene weirdly has no subfeatures, just render as a box
if (!subfeatures || !subfeatures.length) return this.inherited(arguments)

// get the rects for the children
var padding = 1;
var fRect = {
Expand Down Expand Up @@ -126,11 +129,13 @@ layoutFeature: function( viewInfo, layout, feature ) {
return fRect;
},

renderFeature: function( context, fRect ) {
renderFeature( context, fRect ) {
const subRects = fRect.subRects;
if (!subRects || subRects.length === 0) return this.inherited(arguments)

if( fRect.viewInfo.displayMode != 'collapsed' )
context.clearRect( Math.floor(fRect.l), fRect.t, Math.ceil(fRect.w-Math.floor(fRect.l)+fRect.l), fRect.h );

var subRects = fRect.subRects;
for( var i = 0; i < subRects.length; i++ ) {
subRects[i].glyph.renderFeature( context, subRects[i] );
}
Expand All @@ -142,7 +147,7 @@ renderFeature: function( context, fRect ) {
updateStaticElements: function( context, fRect, viewArgs ) {
this.inherited( arguments );

var subRects = fRect.subRects;
var subRects = fRect.subRects || [];
for( var i = 0; i < subRects.length; i++ ) {
subRects[i].glyph.updateStaticElements( context, subRects[i], viewArgs );
}
Expand Down

0 comments on commit b9e3e18

Please sign in to comment.