documentation for groovy console and basic groovy scripting support
[jalview.git] / help / html / features / groovy.html
1 <html>\r
2 <head><title>Groovy Shell</title></head>\r
3 <body>\r
4 <p><strong>The Groovy Shell</strong></p>\r
5 <p><a href="http://groovy.codehaus.org/">Groovy</a> is an &quot;<em>agile and dynamic \r
6 language for the Java platform</em>&quot;. The groovy scripting language makes it \r
7 extremely easy to programmatically interact with Java programs, in much the same \r
8 way that Javascript is used to generate and interact with applets and other \r
9 objects on the page.</p>\r
10 <p><em>Opening the Groovy Console</em><br>If groovy is available, then the \r
11 <strong>Tools&#8594;Groovy Console...</strong> menu entry will be available \r
12 from the Jalview Desktop's drop-down menu. Selecting this will open the\r
13 <a href="http://groovy.codehaus.org/Groovy+Console">Groovy Console</a> which \r
14 allows you to interactively execute Groovy scripts within the Jalview run-time environment.</p>\r
15 <p><em>Executing groovy scripts on Jalview startup</em><br>\r
16 The -groovy &lt;script&gt; option on the <a href="commandline.html"/>Jalview command line</a>command line option will </p>\r
17 <p>There is as yet no properly defined scripting interface to Jalview, but all the\r
18 public methods of the jalview class hierarchy can be called from Groovy scripts. \r
19 The access point for this is the <strong>Jalview</strong> object defined in\r
20 the groovy environent which corresponds to the <pre>jalview.gui.Desktop</pre> object which\r
21 manages all the Jalview windows.</p>  \r
22 Here's an example to get you started:<br>\r
23 <ul><li>Getting the title, alignment and first sequence from the current alignFrame<br>\r
24 <pre>\r
25 def alf = Jalview.getAlignframes();\r
26 print alf[0].getTitle();\r
27 def alignment = alf[0].viewport.alignment;\r
28 def seq = alignment.getSequenceAt(0);\r
29 </pre>\r
30 </li>\r
31 </ul>\r
32 </p>\r
33 <p><strong>Getting Groovy...<br></strong>\r
34 Jalview Groovy support is only possible if the core groovy \r
35 jars which include the GroovyShell are present on the CLASSPATH \r
36 when Jalview is started. <p>The jars are obtained from the \r
37 <em>embedded</em> directory within the <a \r
38 href="http://dist.codehaus.org/groovy/distributions">groovy \r
39 distribution</a>. The easiest way of adding them to the \r
40 Jalview classpath is to download and build jalview from \r
41 it's source distribution, and then add the groovy-all-*.jar \r
42 to the lib directory whose path is given in the java.ext.dirs property.</p>\r
43 \r
44 <p>&nbsp;</p>\r
45 </body>\r
46 </html>\r