Jalview 2.6 source licence
[jalview.git] / help / html / features / groovy.html
1 <html>\r
2 <!--\r
3  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)\r
4  * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
5  * \r
6  * This file is part of Jalview.\r
7  * \r
8  * Jalview is free software: you can redistribute it and/or\r
9  * modify it under the terms of the GNU General Public License \r
10  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\r
11  * \r
12  * Jalview is distributed in the hope that it will be useful, but \r
13  * WITHOUT ANY WARRANTY; without even the implied warranty \r
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
15  * PURPOSE.  See the GNU General Public License for more details.\r
16  * \r
17  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.\r
18 -->\r
19 <head><title>Groovy Shell</title></head>\r
20 <body>\r
21 <p><strong>The Groovy Shell</strong></p>\r
22 <p><a href="http://groovy.codehaus.org/">Groovy</a> is an &quot;<em>agile and dynamic \r
23 language for the Java platform</em>&quot;. The groovy scripting language makes it \r
24 extremely easy to programmatically interact with Java programs, in much the same \r
25 way that Javascript is used to generate and interact with applets and other \r
26 objects on the page.</p>\r
27 <p><strong><em>Getting Groovy...</em></strong><br>\r
28 Jalview Groovy support is only possible if the core groovy \r
29 jars which include the GroovyShell are present on the CLASSPATH \r
30 when Jalview is started.</p><p>The jars are obtained from the \r
31 <em>embedded</em> directory within the <a \r
32 href="http://dist.codehaus.org/groovy/distributions">groovy \r
33 distribution</a>. The easiest way of adding them to the \r
34 Jalview classpath is to download and build jalview from \r
35 it's source distribution, and then add the groovy-all-*.jar \r
36 to the lib directory whose path is given in the java.ext.dirs property.</p>\r
37 <p><strong>Opening Jalview's Groovy Console</strong><br>If groovy is available, then the \r
38 <strong>Tools&#8594;Groovy Console...</strong> menu entry will be available \r
39 from the Jalview Desktop's drop-down menu. Selecting this will open the\r
40 <a href="http://groovy.codehaus.org/Groovy+Console">Groovy Console</a> which \r
41 allows you to interactively execute Groovy scripts within the Jalview run-time environment.</p>\r
42 <p><strong>Executing groovy scripts on Jalview startup</strong><br>\r
43 The -groovy &lt;script&gt; option on the <a href="commandline.html"/>\r
44 Jalview command line</a> will execute the contents of \r
45 &lt;script&gt;. &lt;script&gt; may be a file, or alternatively if it is &quot;STDIN&quot; \r
46 then the standard input will be used.</p>\r
47 <p><strong>Access to Jalview's functions from Groovy Scripts</strong><br>\r
48 There is as yet no properly defined scripting interface to Jalview, but all the\r
49 public methods of the jalview class hierarchy can be called from Groovy scripts. \r
50 The access point for this is the <strong>Jalview</strong> object defined in\r
51 the groovy environent which corresponds to the <pre>jalview.gui.Desktop</pre> object which\r
52 manages all the Jalview windows.</p>  \r
53 Here's an example to get you started:<br>\r
54 <ul><li>Getting the title, alignment and first sequence from the current alignFrame<br>\r
55 <pre>\r
56 def alf = Jalview.getAlignframes();\r
57 print alf[0].getTitle();\r
58 def alignment = alf[0].viewport.alignment;\r
59 def seq = alignment.getSequenceAt(0);\r
60 </pre>\r
61 </li>\r
62 </ul>\r
63 </p>\r
64 \r
65 <p>&nbsp;</p>\r
66 </body>\r
67 </html>\r