Skip to content

Commit

Permalink
add a "Highlight feature" to the default HTMLFeatures right-click men…
Browse files Browse the repository at this point in the history
…u, references #76
  • Loading branch information
rbuels committed Feb 26, 2013
1 parent d200087 commit 5300c29
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
12 changes: 11 additions & 1 deletion src/JBrowse/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ Browser.prototype.initView = function() {
// make the menu item for clearing the current highlight
this._highlightClearButton = new dijitMenuItem(
{
label: 'Clear highlight',
onClick: dojo.hitch( this, function() {
var h = this.getHighlight();
if( h ) {
Expand Down Expand Up @@ -2179,7 +2180,7 @@ Browser.prototype.setHighlight = function( newHighlight ) {
Browser.prototype._updateHighlightClearButton = function() {
if( this._highlightClearButton ) {
this._highlightClearButton.set( 'disabled', !!! this._highlight );
this._highlightClearButton.set( 'label', 'Clear highlight' + ( this._highlight ? ' ' + this._highlight : '' ));
this._highlightClearButton.set( 'label', 'Clear highlight' + ( this._highlight ? ' - ' + this._highlight : '' ));
}
};

Expand All @@ -2191,6 +2192,15 @@ Browser.prototype.clearHighlight = function() {
}
};

Browser.prototype.setHighlightAndRedraw = function( location ) {
var oldHighlight = this.getHighlight();
if( oldHighlight )
this.view.hideRegion( oldHighlight );
this.view.hideRegion( location );
this.setHighlight( location );
this.view.showVisibleBlocks( false );
};

/**
* Clears the old highlight if necessary, sets the given new
* highlight, and updates the display to show the highlighted location.
Expand Down
22 changes: 16 additions & 6 deletions src/JBrowse/Model/Location.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
define([
'dojo/_base/array',
'JBrowse/Util'
],
function(
array,
Util
) {

Expand All @@ -15,18 +17,26 @@ return Util.fastDeclare(

if( args.location )
this._populate( args.location );
if( args.feature ) {
var f = args.feature;
this._populate({ start: f.get('start'),
end: f.get('end'),
ref: f.get('seq_id'),
strand: f.get('strand'),
objectName: f.get('Name') || f.get('ID')
});
}

this._populate( args );

}
},
_populate: function( args ) {
this.ref = args.ref;
this.start = args.start;
this.end = args.end;
this.strand = args.strand;
this.tracks = args.tracks;
this.objectName = args.objectName;
array.forEach( 'ref,start,end,strand,tracks,objectName'.split(','),
function( p ) {
if( p in args )
this[p] = args[p];
}, this);
},

toString: function() {
Expand Down
13 changes: 11 additions & 2 deletions src/JBrowse/View/Track/HTMLFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ define( [
'JBrowse/View/Track/ExportMixin',
'JBrowse/View/Track/FeatureDetailMixin',
'JBrowse/Util',
'JBrowse/View/GranularRectLayout'
'JBrowse/View/GranularRectLayout',
'JBrowse/Model/Location'
],
function( declare,
lang,
Expand All @@ -33,7 +34,8 @@ define( [
ExportMixin,
FeatureDetailMixin,
Util,
Layout
Layout,
Location
) {

var HTMLFeatures = declare( [ BlockBased, YScaleMixin, ExportMixin, FeatureDetailMixin ], {
Expand Down Expand Up @@ -114,6 +116,13 @@ var HTMLFeatures = declare( [ BlockBased, YScaleMixin, ExportMixin, FeatureDetai
action: 'contentDialog',
iconClass: 'dijitIconTask',
content: dojo.hitch( this, 'defaultFeatureDetail' )
},
{ label: 'Highlight feature',
action: function( feature ) {
var loc = new Location({ feature: this.feature, tracks: [this.track] });
this.track.browser.setHighlightAndRedraw(loc);
},
iconClass: 'dijitIconFilter'
}
]
};
Expand Down

0 comments on commit 5300c29

Please sign in to comment.