Bio-Graphics
view release on metacpan or search on metacpan
lib/Bio/Graphics/Panel.pm view on Meta::CPAN
Create the image in a web-accessible directory and return its URL, its
clickable imagemap, and the name of the imagemap. The following
options are recognized:
Option Description
------ -----------
-url The URL to store the image at.
-root The directory path that should be appended to the
start of -url in order to obtain a physical
directory path.
-link A string pattern or coderef that will be used to
generate the outgoing hypertext links for the imagemap.
-title A string pattern or coderef that will be used to
generate the "title" tags of each element in the imagemap
(these appear as popup hint boxes in certain browsers).
-target A string pattern or coderef that will be used to
generate the window target for each element. This can
be used to pop up a new window when the user clicks on
an element.
-mapname The name to use for the E<lt>mapE<gt> tag. If not provided,
a unique one will be autogenerated for you.
This method returns a three element list consisting of the URL at
which the image has been written to, the imagemap HTML, and the name
of the map. Usually you will incorporate this information into an
HTML document like so:
my ($url,$map,$mapname) =
$panel->image_and_map(-link=>'http://www.google.com/search?q=$name');
print qq(<img src="$url" usemap="#$mapname">),"\n";
print $map,"\n";
=item $url = $panel-E<gt>create_web_image($url,$root)
Create the image, write it into the directory indicated by
concatenating $root and $url (i.e. "$root/$url"), and return $url.
=item $map = $panel-E<gt>create_web_map('mapname',$linkrule,$titlerule,$targetrule)
Create a clickable imagemap named "mapname" using the indicated rules
to generate the hypertext links, the element titles, and the window
targets for the graphical elements. Return the HTML for the map,
including the enclosing E<lt>mapE<gt> tag itself.
=back
To use this method effectively, you will need a web server and an
image directory in the document tree that is writable by the web
server user. For example, if your web server's document root is
located at /var/www/html, you might want to create a directory named
"tmpimages" for this purpose:
mkdir /var/www/html/tmpimages
chmod 1777 /var/www/html/tmpimages
The 1777 privilege will allow anyone to create files and
subdirectories in this directory, but only the owner of the file will
be able to delete it.
When you call image_and_map(), you must provide it with two vital
pieces of information: the URL of the image directory and the physical
location of the web server's document tree. In our example, you would
call:
$panel->image_and_map(-root => '/var/www/html',-url=>'/tmpimages');
If you are working with virtual hosts, you might wish to provide the
hostname:portnumber part of the URL. This will work just as well:
$panel->image_and_map(-root => '/var/www/html',
-url => 'http://myhost.com:8080/tmpimages');
If you do not provide the -root argument, the method will try to
figure it out from the DOCUMENT_ROOT environment variable. If you do
not provide the -url argument, the method will assume "/tmp".
During execution, the image_and_map() method will generate a unique
name for the image using the Digest::MD5 module. You can get this
module on CPAN and it B<must> be installed in order to use
image_and_map(). The imagename will be a long hexadecimal string such
as "e7457643f12d413f20843d4030c197c6.png". Its URL will be
/tmpimages/e7457643f12d413f20843d4030c197c6.png, and its physical path
will be /var/www/html/tmpimages/e7457643f12d413f20843d4030c197c6.png
In addition to providing directory information, you must also tell
image_and_map() how to create outgoing links for each graphical
feature, and, optionally, how to create the "hover title" (the popup
yellow box displayed by most modern browsers), and the name of the
window or frame to link to when the user clicks on it.
There are three ways to specify the link destination:
=over 4
=item 1.
By configuring one or more tracks with a -link argument.
=item 2.
By configuring the panel with a -link argument.
=item 3.
By passing a -link argument in the call to image_and_map().
=back
The -link argument can be either a string or a coderef. If you pass a
string, it will be interpreted as a URL pattern containing runtime
variables. These variables begin with a dollar sign ($), and are
replaced at run time with the information relating to the selected
annotation. Recognized variables include:
( run in 1.818 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )