Skip to content

Commit

Permalink
rename a bunch of CanvasFeatures config variables. prioritize more de…
Browse files Browse the repository at this point in the history
…scriptive configuration variable names over gbrowse compatibility
  • Loading branch information
rbuels committed Jan 30, 2013
1 parent 72b6f7d commit a564931
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
29 changes: 18 additions & 11 deletions src/JBrowse/View/Track/Alignments2.js
Expand Up @@ -22,21 +22,22 @@ return declare( [ CanvasFeatureTrack, MismatchesMixin ], {
{
//maxFeatureScreenDensity: 400
style: {
bgcolor: function( feature ) {
color: function( feature ) {
var missing_mate = feature.get('multi_segment_template') && !feature.get('multi_segment_all_aligned');
var strand = feature.get('strand');
return missing_mate ? this.getStyle( feature, 'bgcolor_missing_mate' ) :
strand == 1 || strand == '+' ? this.getStyle( feature, 'bgcolor_fwd_strand' ) :
strand == -1 || strand == '-' ? this.getStyle( feature, 'bgcolor_rev_strand' ) :
return missing_mate ? this.getStyle( feature, 'color_missing_mate' ) :
strand == 1 || strand == '+' ? this.getStyle( feature, 'color_fwd_strand' ) :
strand == -1 || strand == '-' ? this.getStyle( feature, 'color_rev_strand' ) :
this.colorForBase('reference');
},
bgcolor_fwd_strand: '#EC8B8B',
bgcolor_rev_strand: '#898FD8',
bgcolor_missing_mate: '#D11919',
color_fwd_strand: '#EC8B8B',
color_rev_strand: '#898FD8',
color_missing_mate: '#D11919',
border_color: null,
height: 7,
marginBottom: 1,
showMismatches: true,
font: 'bold 10px Courier New,monospace'
mismatchFont: 'bold 10px Courier New,monospace'
}
}
);
Expand Down Expand Up @@ -75,7 +76,7 @@ return declare( [ CanvasFeatureTrack, MismatchesMixin ], {
context.fillRect( mRect.l, mRect.t, mRect.w, mRect.h );

if( mRect.w >= charSize.w && mRect.h >= charSize.h-3 ) {
context.font = this.config.style.font;
context.font = this.config.style.mismatchFont;
context.fillStyle = mismatch.type == 'deletion' ? 'white' : 'black';
context.fillText( mismatch.base, mRect.l+(mRect.w-charSize.w)/2+1, mRect.t+mRect.h-(mRect.h-charSize.h+4)/2 );
}
Expand All @@ -84,7 +85,7 @@ return declare( [ CanvasFeatureTrack, MismatchesMixin ], {
context.fillStyle = 'black';
context.fillRect( mRect.l-1, mRect.t, 2, mRect.h );
if( mRect.w >= charSize.w && mRect.h >= charSize.h-3 ) {
context.font = this.config.style.font;
context.font = this.config.style.mismatchFont;
context.fillStyle = 'black';
context.fillText( '('+mismatch.base+')', mRect.l+2, mRect.t+mRect.h-(mRect.h-charSize.h+4)/2 );
}
Expand All @@ -100,7 +101,13 @@ return declare( [ CanvasFeatureTrack, MismatchesMixin ], {

getCharacterMeasurements: function( context ) {
return this.charSize = this.charSize || function() {
var fpx = (this.config.style.font.match(/(\d+)px/i)||[])[1] || Infinity;
var fpx;

try {
fpx = (this.config.style.mismatchFont.match(/(\d+)px/i)||[])[1];
} catch(e) {}

fpx = fpx || Infinity;
return { w: fpx, h: fpx };
}.call(this);
}
Expand Down
24 changes: 12 additions & 12 deletions src/JBrowse/View/Track/CanvasFeatures.js
Expand Up @@ -74,9 +74,9 @@ return declare( [CanvasTrack,FeatureDetailMixin], {
return {
maxFeatureScreenDensity: 400,
style: {
bgcolor: 'goldenrod',
color: 'goldenrod',
mouseovercolor: 'rgba(0,0,0,0.3)',
fgcolor: null,
border_color: null,
height: 11,
marginBottom: 1
}
Expand Down Expand Up @@ -344,19 +344,19 @@ return declare( [CanvasTrack,FeatureDetailMixin], {
// draw each feature
renderFeature: function( context, viewArgs, fRect ) {
// background
var bgcolor = this.getStyle( fRect.f, 'bgcolor' );
if( bgcolor ) {
context.fillStyle = bgcolor;
var color = this.getStyle( fRect.f, 'color' );
if( color ) {
context.fillStyle = color;
context.fillRect( fRect.l, fRect.t, fRect.w, fRect.h );
}

// foreground border
var fgcolor;
var border_color;
if( fRect.h > 3 ) {
fgcolor = this.getStyle( fRect.f, 'fgcolor' );
if( fgcolor ) {
border_color = this.getStyle( fRect.f, 'border_color' );
if( border_color ) {
context.lineWidth = 1;
context.strokeStyle = fgcolor;
context.strokeStyle = border_color;

// need to stroke a smaller rectangle to remain within
// the bounds of the feature's overall height and
Expand All @@ -366,9 +366,9 @@ return declare( [CanvasTrack,FeatureDetailMixin], {
}
}
else if( fRect.h > 1 ) {
fgcolor = this.getStyle( fRect.f, 'fgcolor' );
if( fgcolor ) {
context.fillStyle = fgcolor;
border_color = this.getStyle( fRect.f, 'border_color' );
if( border_color ) {
context.fillStyle = border_color;
context.fillRect( fRect.l, fRect.t+fRect.h-1, fRect.w, 1 );
}
}
Expand Down

0 comments on commit a564931

Please sign in to comment.