Ensembl .menu. When a new glyph is drawn to a DrawableContainer by either one of the GlyphSets in Bio::EnsEMBL::GlyphSet or the Sanger::Graphics::Renderer::imagemap, an entry is also made in the clickable image map for the resulting image which contains the information necessary to display the z-menu. Each glyph that requires a new z-menu be displayed should respond to a zmenu call, returning a new EnsEMBL::Web::Interface::ZMenu object. For example:
sub zmenu {
### Routing method
my ($self, $gene, $transcript, $ajax) = @_;
if ($ajax) {
return $self->ajax_zmenu($gene);
} else {
return $self->static_zmenu($gene, $transcript);
}
}
sub ajax_zmenu {
### Creates a new z-menu object, and returns it.
my ($self, $gene) = @_;
my $zmenu = EnsEMBL::Web::Interface::ZMenu->new( (
title => $gene->stable_id(),
type => 'ensembl_transcript',
ident => $gene->stable_id(),
placeholder => 'yes'
) );
return $zmenu;
}
sub static_zmenu {
### Code for synchronous menu display (slower)
...
}
ZMenu object is then used by the imagemap renderer to generate the appropriate javascript link which will be used in the imagemap, via the EnsEMBL::Web::Interface::ZMenuCollection class. This class controls how the ZMenu objects are represented at the various different stages of their life cycle, and determins the protocol by which the server and browser will communicate when the ZMenu is populated asynchronously.menu). This call immediately constructs and displays the menu as it stands. The javascript can be found in ajax_zmenu.js. By default, a placeholder z-menu will be displayed, which informs the user that the system is loading the menu content. As soon as the menu is displayed, an asynchronous call is made to populate_zmenu, to (unsurprisingly), populate the menu.
type parameter of the original ZMenu. For example, above a new ZMenu placeholder object was created with a type of ensembl_transcript. As such, a new EnsEMBL::Web::Interface::ZMenu::ensembl_transcript is created. This object has the job of retrieving and processing the necessary information to populate the (currently empty) z-menu. The class should implement these functions in the populate method, which is called automatically on new ZMenu:: objects.ZMenu::ensembl_transcript will be passed in sufficient information to collate the necessary content. Once it is ready, a series of add calls can be made to populate the menu. For example:
add_textadd_linkadd_htmlpopulate method is complete, the results are sent back to the browser, and the z-menu is populated via javascript. At this stage, the user should now be looking at the appropriate content.
ZMenu:: objects. These objects are passed the same parameters as other objects via the populate call, and can add additional content to the menu via the add methdos above. Existing content which may have already been added by other plugins can also be removed with the remove_by_name function.
ZMenu object from the glyph, a fully populated object can be returned. This populated menu will take longer to prepare, and take longer to download, but will be displayed in its completeness when a feature is clicked in EnsEMBL. For example:
sub zmenu {
### Routing method
my ($self, $gene, $transcript, $ajax) = @_;
if ($ajax) {
return $self->ajax_zmenu($gene);
} else {
return $self->static_zmenu($gene, $transcript);
}
}
sub ajax_zmenu {
### Code for asynchronous menu display (faster)
...
}
sub static_zmenu {
my ($self, $gene) = @_;
my $zmenu = EnsEMBL::Web::Interface::ZMenu->new( (
title => $gene->stable_id(),
type => 'ensembl_transcript',
ident => $gene->stable_id(),
placeholder => 'no'
) );
$zmenu->add_text('text1', 'ID: ' . $gene->stable_id() );
$zmenu->add_link((name => 'link1',
text => 'More: ' . $gene->stable_id(),
url => 'http://www.ensembl.org' ) );
return $zmenu;
}
© 2008 WTSI / EBI. Ensembl is available to download for public use - please see the code licence for details.