Skip to content

Commit

Permalink
changed drawing method to use pixel values instead of fRects
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmirob committed Feb 27, 2013
1 parent a5b884c commit 4e118b6
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions src/JBrowse/View/Track/Wiggle/XYPlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var XYPlot = declare( [WiggleBase, YScaleMixin],
* Draw a set of features on the canvas.
* @private
*/
_drawFeatures: function( scale, leftBase, rightBase, block, canvas, features, featureRects, dataScale ) {
_drawFeatures: function( scale, leftBase, rightBase, block, canvas, pixels, dataScale ) {
var context = canvas.getContext('2d');
var canvasHeight = canvas.height;
var toY = dojo.hitch( this, function( val ) {
Expand All @@ -84,39 +84,34 @@ var XYPlot = declare( [WiggleBase, YScaleMixin],
var bgColor = this.config.style.bg_color;
var disableClipMarkers = this.config.disable_clip_markers;

dojo.forEach( features, function(f,i) {

var fRect = featureRects[i];

//console.log( f.get('start') +'-'+f.get('end')+':'+f.get('score') );
var score = f.get('score');
fRect.t = toY( score );
//console.log( score, fRect.t );
dojo.forEach( pixels, function(p,i) {
var score = toY(p);
var w = Math.ceil(scale);

// draw the background color if we are configured to do so
if( bgColor && fRect.t >= 0 ) {
if( bgColor && score >= 0 ) {
context.fillStyle = bgColor;
context.fillRect( fRect.l, 0, fRect.w, canvasHeight );
context.fillRect( i, 0, w, canvasHeight );
}

if( fRect.t <= canvasHeight ) { // if the rectangle is visible at all
if( score <= canvasHeight ) { // if the rectangle is visible at all

if( fRect.t <= originY ) {
if( score <= originY ) {
// bar goes upward
context.fillStyle = posColor;
context.fillRect( fRect.l, fRect.t, fRect.w, originY-fRect.t+1);
if( !disableClipMarkers && fRect.t < 0 ) { // draw clip marker if necessary
context.fillRect( i, score, w, originY-score+1);
if( !disableClipMarkers && score < 0 ) { // draw clip marker if necessary
context.fillStyle = clipColor || negColor;
context.fillRect( fRect.l, 0, fRect.w, 2 );
context.fillRect( i, 0, w, 2 );
}
}
else {
// bar goes downward
context.fillStyle = negColor;
context.fillRect( fRect.l, originY, fRect.w, fRect.t-originY+1 );
if( !disableClipMarkers && fRect.t >= canvasHeight ) { // draw clip marker if necessary
context.fillRect( i, originY, w, score-originY+1 );
if( !disableClipMarkers && score >= canvasHeight ) { // draw clip marker if necessary
context.fillStyle = clipColor || posColor;
context.fillRect( fRect.l, canvasHeight-3, fRect.w, 2 );
context.fillRect( i, canvasHeight-3, w, 2 );
}
}
}
Expand Down

0 comments on commit 4e118b6

Please sign in to comment.