Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Hacking on JAS3

Tools

Building JAS3 from source requires Apache Ant.

No Format

wget http://apache.oregonstate.edu/ant/binaries/apache-ant-1.6.5-bin.zip
unzip apache-ant-1.6.5-bin.zip

Building

Obtaining the Source

JAS3

...

CVS Instructions

and most of its non-external dependencies can be found on the FreeHep SVN.

JAS3

This command will checkout the JAS3 trunk from SVNCVS checkout command.

No Format
cvssvn -dco :pserver:anonymous@cvssvn://svn.freehep.org:/cvssvn/jas co jas3/trunk/

FreeHep

Much of JAS3's functionality is found in the freehep package.

CVS Instructions

CVS checkout command.

No Format
setenv CVSROOT :pserver:anoncvs@cvs.freehep.org:/cvs/freehep
cvs login
[jascvs]
cvs co -P freehep

FreeHep Build Instructions

No Format

cd freehep
export FREEHEP=`pwd`
tools/ant

Building JAS3 from Source

Build Instructions

No Format
cd jas3
ant

Installing Freehep Dependencies

Make a file ~/jas3.properties containing the following:

No Format

FREEHEP=C:\path\to\freehep
Warning

On Windows, the path separators need to be double backslashes. (Check same for Unix???)

Now, run from JAS3:

No Format

ant extLibs

This pulls all FreeHep external library jars files into the jas3/extensions directory.

Plugins

Overview

JAS uses plugins for most of its functionality. A plugin (org.freehep.application.Studio.Plugin) is a loadable module that is supposed to encapsulate certain functionality, such as handling of a specific data format.

Structure

On startup, JAS looks for this path in the jar file to load a plugin.

No Format

PLUGIN-inf/plugins.xml

For example, here is the contents of that file for the org.lcsim plugin.

No Format

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plugins SYSTEM "http://java.freehep.org/schemas/plugin/1.0/plugin.dtd">
<plugins>
   <plugin>
      <information>
          <name>org.lcsim</name>
	  <category>hep.linearcollider</category>
          <author>LCSIM Team</author>
          <version>0.9</version>
          <description kind="short">org.lcsim plugin for JAS3</description>
          <description>org.lcsim plugin for JAS3.</description>
          <load-at-start/>
      </information>
      <resources>
          <j2se minVersion="1.5"/>
          <file href="http://jas.freehep.org/jas3/plugins/lcsim/0.9/lcsim.jar" location="lcsim.jar"/>
          <file href="http://jas.freehep.org/jas3/plugins/lcsim/0.9/freehep-physics.jar" location="freehep-physics.jar"/>
          <file href="http://jas.freehep.org/jas3/plugins/lcsim/0.9/sio.jar" location="sio.jar"/>
          <file href="http://jas.freehep.org/jas3/plugins/lcsim/0.9/GeomConverter.jar" location="GeomConverter.jar"/>
          <file href="http://jas.freehep.org/jas3/plugins/lcsim/0.9/commons-math.jar" location="commons-math.jar"/>
      </resources>
      <plugin-desc class="org.lcsim.plugin.LCSimPlugin"/>
    </plugin>
</plugins>

The load-at-start tag under information means that JAS will automatically instantiate this plugin when the application starts.

The class to be loaded is listed under plugin-desc as org.lcsim.plugin.LCSimPlugin.

Any initialization should be performed in the init() method. The postInit() method is used for any initialization that involves other plugins that may not have been loaded when init() was called.

Menus

Example of adding a File -> New -> Example Plugin menu item.

No Format

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE MenuSystem SYSTEM "http://java.freehep.org/schemas/menus/1.0/menus.dtd">
<MenuSystem>
    <MenuBar id="mainMenu">
        <Menu name="File" mnemonic="F" location="100">
            <Menu name="New" mnemonic="N" location="50">
                <Component type="default" 
                           icon="/classpath/to/examplePluginIcon.gif" 
                           name="Example Plugin" 
                           mnemonic="E" 
                           command="ExamplePlugin" 
                           location="1200"/>
            </Menu>
        </Menu>
    </MenuBar>
</MenuSystem>

Within the init() function of the plugin class, the following lines of code should be used to build the menus.

No Format

Studio app = getApplication();
XMLMenuBuilder builder = app.getXMLMenuBuilder();
URL xml = getClass().getResource("ExamplePlugin.menus");
builder.build(xml);