Examples of Groovey coding style and interface to UJMP

4.11K viewsScripting
0

I hope the attached may be of some interest to others.

It demonstrates some features of Groovey coding, such as closures – which avoid the need to write all those tedious loops when scanning the children of classes such as Matrices and Categories. Example:
[code:1wu8betl]def int matrixIndexFromName(String mName)
{
def listOfMatrices = []
matrices.each{listOfMatrices.add( it.name )}
// or [I]matrices.each{listOfMatrices << it.name }[/I]
int i = listOfMatrices.indexOf(mName)
}[/code:1wu8betl]

It uses Java Swing to get user input.

It also includes a primitive interface to Universal Java Matrix Package (UJMP), which enables a Quantrix matrix to be be imported and processed using matrix algebra operations. To use this capability you need to download the UJMP code ([url:1wu8betl]http://www.ujmp.org/[/url:1wu8betl]) and put in the ScriptingLibs directory per:
[quote="Ben G":1wu8betl]Dominik:

External JARs can be imported as of 4.0.42. For security reasons, we decided to use a single blessed location for external libraries rather than making the entire class path available to scripting. To install a library for use with scripting, follow these steps:

1) Open the folder on your hard drive where Quantrix is installed, and within that folder create a subfolder called “”ScriptingLibs””.

2) Place any JARs you need to use within the ScriptingLibs folder.

3) Restart Quantrix if necessary. In your script, import the classes you would like to use as you would in normal Groovy or Java source.
[/quote:1wu8betl]

Feedback, corrections, and further refinements much appreciated.

Simon

0

I’m not aware that you need to add anything else. I do have JRE 1.6 on my machine but I don’t think you should need that to run the code.

I’d suggest copying the Action script (for the UMJP demo) into the scripting console and executing it line by line to see where it fails. It sounds like the MatrixFactory method is working to create the UJMP matrix, and then the script is failing on either the showGUI() or reshape() – which seems very odd…

Please let me know if you can find anything else.

You are viewing 1 out of 3 answers, click here to view all answers.

Latest Questions