From a5649318bbc66d7db47da4cf60a944f11f79588f Mon Sep 17 00:00:00 2001 From: Robert Buels Date: Wed, 30 Jan 2013 14:00:07 -0500 Subject: [PATCH] rename a bunch of CanvasFeatures config variables. prioritize more descriptive configuration variable names over gbrowse compatibility --- src/JBrowse/View/Track/Alignments2.js | 29 +++++++++++++++--------- src/JBrowse/View/Track/CanvasFeatures.js | 24 ++++++++++---------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/JBrowse/View/Track/Alignments2.js b/src/JBrowse/View/Track/Alignments2.js index be6719ea83..95f1ed0217 100644 --- a/src/JBrowse/View/Track/Alignments2.js +++ b/src/JBrowse/View/Track/Alignments2.js @@ -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' } } ); @@ -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 ); } @@ -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 ); } @@ -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); } diff --git a/src/JBrowse/View/Track/CanvasFeatures.js b/src/JBrowse/View/Track/CanvasFeatures.js index 34f61d7738..962b86eaf2 100644 --- a/src/JBrowse/View/Track/CanvasFeatures.js +++ b/src/JBrowse/View/Track/CanvasFeatures.js @@ -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 } @@ -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 @@ -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 ); } }