Open the "Plugins - Scripting - Jython Interpreter" (see [[Scripting Help]]) and make sure there is a TrakEM2 project open, with a display open. Then type or paste the examples below.
= Introduction to scripting TrakEM2 =
See a [http://www.ini.uzh.ch/~acardona/img/trakem2_datastructure_diagram.svg TrakEM2 class diagram] for a complete list.
=== Get the instance of a selected image ===
for d in Display.getFront().
=== Setting and getting member objects in jython ===
In Jython as in Python, member objects have automatically <i>get</> and <i>set</i> functions.
For example, altough a [http://www.ini.uzh.ch/~acardona/api/ini/trakem2/display/Displayable.html Displayable] has a private <i>String title</i> member, this is valid python code for getting and setting the title of a Displayable like a Patch:
A new name for this Patch
=== The properties of a Displayable: title, color, visibility, locked, alpha, affine transform, dimensions and bounds ===
>>> aff.scale(2.0, 2.0)
More convenient are the methods <i>scale</i>, <i>translate</i>, <i>rotate</i> and particularly <i>preTransform</i>, for the manipulation of a [http://www.ini.uzh.ch/~acardona/api/ini/trakem2/display/Displayable.html Displayable]'s affine transform (see [http://java.sun.com/javase/6/docs/api/java/awt/geom/AffineTransform.html AffineTransform]) and that of its linked Displayables (any transform propagates to the linked ones).
If you change the affine transform of a Displayable directly (by calling <i>getAffineTransform()</i> and then manipulating it), keep in mind that you will most likely screw up the internal cached maps for fast location of the Displayable object. To solve that, be sure to
all <i>updateBucket()</i> on the affected Displayable object.
= Adding images =
# Add it to a layer
== Jython scripting ==
Jython_Scripting]] in fiji.
*[http://www.jython.org Jython webpage].