== Using plugins == Click "Plugins -> Load Plugin" from the Transformer window menu bar. You should be presented with a file browser, select a jar file containing one or more Batchable classes. The plugin will add a new cascaded menu to the plugins menu, the cascaded menu will contain each "Batchable" class as both a single and a batch item on the "Plugins" sub menu. == Writing plugins == To implement a plugin for JPsychoMorph you need to create a Java class that overrides the Facemorph.Batchable interface: {{{ public interface Batchable { public boolean process(ImageZoomPanel izp, boolean single); public boolean initialise(PsychoMorphForm psychomorph); public void finish(); public String getName(); } }}} This interface is part of the Facemorph library available here: * http://users.aber.ac.uk/bpt/jpsychomorph/version4/facemorphlib.jar -- facemorphlib.jar Documentation for all the classes in the library is available here: * http://users.aber.ac.uk/bpt/jpsychomorph/version4/javadoc/ -- facemorphlib documentation The main method in the Batchable interface is ''process'', which will be called for each image in the batch. The ''single'' parameter is true if the processing is '''not''' operating in batch mode, but on a single loaded image. This is useful for things like pushing undo information on the stack, which you may not want to do in batch mode. The ImageZoomPanel allows access to the currently loaded Image and Template. The ''initialise'' method is called once before a batch of images, or before a single image is processed. It allows access to the rest of the system state via the PsychoMorphForm parameter. The ''finish'' method is called after all the images in the list have been processed, it is not called when operating on a single image. The ''getName'' method should return the name of the Batchable for inclusion in the ''Plugins'' menu on the psychomorph Transform window. Both Batch and single versions of the plugin will be added to the menu. The class must also have a no parameter (default) constructor for initialising. This is called both when the plugin is first loaded into the system and every time the (single or batch) menu item is clicked. == Examples == Full source code including a NetBeans project is available: * http://users.aber.ac.uk/bpt/jpsychomorph/version4/pluginexamples.zip -- NetBeans project and source code for example plugins * http://users.aber.ac.uk/bpt/jpsychomorph/version4/pluginexamples.jar -- Just the compiled plugins === Simple example === An example of a simple Batchable is given below. This Batchable checks that the inner lip points are correctly positioned vertically, and swaps corresponding points if needed. {{{ import Facemorph.Template; import Facemorph.psychomorph.Batchable; import Facemorph.psychomorph.ImageZoomPanel; import Facemorph.psychomorph.PsychoMorphForm; import java.awt.geom.Point2D; /** * Batch corrects the mouth in the "standard" template, by checking if the top -lip is below the bottom lip points and swapping if needed */ public class BatchCorrectMouth implements Batchable { public boolean process(ImageZoomPanel izp, boolean single) { Template tem = izp.getTemplate(); int[] topMouth = {94, 95, 96, 97, 98}, bottomMouth = {99, 100, 101, 102, 103}; for (int i=0; i