Developer’s corner

JLOW - Java Libraries fOr Workflow - Release 2.0

Author : Cyril Pestel - Read before any use of available Java classes


  • JAVA J2SE Development Kit (JDK) 1.4 or later
  • Use the last version of jlow-common and jlow-frontend jars
  • JGraph library is needed and available at (download the free library)

Creates your own application with JLOW

We will learn how to use JLOW by creating a new application which allows adding a task named “RGB coloration” into the editor JLOW area. We have three inputs for this task and one output. The coloration needs three images with three different waves. The result of this task is an colored image.

How to creates a window ?

We begin by creating a window though SWING components of JAVA. We suggest extending a class by the JFrame packaged into javax.swing. This class can be contains :

    public SampleFrame() {
        Container content = getContentPane();
        content.setLayout(new BorderLayout());
        setSize(400, 300);
        setLocation(200, 200);
    public static void main(String args[]) {
        SampleFrame frame = new SampleFrame();

How to use the class Jlow ?

The main class to use is named Jlow and need the element that contains all tasks which can be adding into the area. This element must implement the interface IRegister (package cds.jlow.descriptor). A simple implementation is the class Register.

        register = new Registerer();
        wfEditor = new Jlow(register);
        content.add(wfEditor, "Center");

How to add a descriptor ?

Now, we have to create a new element which describes the task that we want to add. This is here that the view of the task is setting.

        String idAtts = Utils.getIdUnique();
        Attributs attsTask = new Attributs(idAtts, "AttsTask",
            new Color(141, 90, 99, 200), new Dimension(100, 100));
        attsTask.putAtt("border", BorderFactory.createRaisedBevelBorder());

The constructor of the Attributs class takes for parameters: an identifier, a name, a color, and a dimension. We can add some properties to the Attributs like a border, a font, an icon. These informations are registered into the object named register which is known by the editor. The identifier is used for identifying the Attributs in the register (we generate an unique identifier with getIdUnique method).

You can also use AttributsFactory for generate a default Attributs for tasks and a default Attributs for ports.

Then we must create the descriptor of the task.

        String idDesc = Utils.getIdUnique();
        Hashtable mods = new Hashtable();
        mods.put("tostring", new ToStringModule());
        mods.put("tohtml", new ToHtmlModule());
        TaskDescriptor desc = new TaskDescriptor(idDesc, "RGB color", mods);
        register.add(desc, idAtts);

TaskDescriptor takes an identifier and a name which is printed into the box created though the module ToStringModule. A module is used for giving a service to the descriptor. For example, ToHtmlModule allows the task to print in a balloon help a few informations about the task or another object from the editor area. As the same way, we must create the Attributs and an IDescriptor for the entries (port) of the task.

        String idTImg = Utils.getIdUnique();
        Attributs typeImg = AttributsFactory.newPortAttributs(idTImg, "Image");
        String idport = Utils.getIdUnique();
        String nameport = "Image 1";
        PortDescriptor port = new PortDescriptor(idport, nameport, IPortDescriptor.INPUT,
        DescriptorFactory.newVariable(Type.STRINGNAME, Type.STRING,
            new String("http://localhost/image1.fits")), mods);
        register.add(port, idTImg);

First we have to create new attributes for the entry. Then, we create the port of the task for using it like an input. Finally, the descriptor and the attributes are linked into the register. It¡Çs necessary to repeat this three times for each input port which represents the three images with different wave length. The output is made with the same way but we use addOuputPort of the task.

You can use DescriptorFactory for generate a Variable which is an IDataDescriptor with a name, a type and a value. See the class Type for more details on it.

When all these staffs are done, we can add into the editor area the task registered.

        wfEditor.insert(new Point(20,20), idTask);

Download and links

jlowtutorial.txt · Last modified: 2010/04/30 07:40 (external edit)

Thanks for acknowledging the CDS developer’s resources (libraries, source code, etc.)