Wednesday, February 27, 2008

List file class loader

Matrex is composed by several jars:
  • The Matrex jars: api, gui, fun.
  • The libraries used by Matrex, for example SWT, jfreechart.
  • The plug-ins, for example the library to connect Matrex to Matlab.
To have java loading all these jars when starting Matrex, they was listed in the classpath parameter of the java call.
Here is the typical content of a batch file starting Matrex (it uses the two variables MATREX_CP and LIB_CP):
MATREX_CP=matrex_api.jar:matrex_fun.jar:matrex_gui.jar
LIB_CP=freehepj3d.jar:jython.jar:commons-math-1.1.jar:jfreechart-1.0.8a.jar:jcommon-1.0.12.jar:jxl.jar:lucene-core-2.0.0.jar:swt/swt.jar:antlr-runtime-3.0.1.jar:javacsv.jar:net.sf.paperclips_1.0.2.jar
java -Djava.library.path=swt -Djava.util.logging.config.file=logging.properties -classpath $MATREX_CP:$LIB_CP matrex.gui.Start $1


This approach has several problems:
  • It is not readable, and it becomes less readable adding more libraries.
  • If the user wants to add a plug-in, he has to edit the batch file. This is unconfortable, because the user needs to learn the syntax of the batch file, and dangerous: if the user does a small mistake changing the batch file the program does not start.
  • you need to have one copy of this batch file for each platform in which Matrex is released (Windows, Linux, MacOSX...).


In these days I worked on a new approach. The idea is to have 3 files containing the list of jars needed to start Matrex:

  • matrex.cld containing the main Matrex jars
  • libraries.cld containing the libraries used by Matrex
  • plugis.cld containing the plug-ins (it is empty when Matrex is installed)
Here is an content of the matrex.cld file. The other two files follow the same rules:

matrex_api.jar
matrex_fun.jar
matrex_gui.jar


To load these files and to load the jars listed in them, Matrex uses a custom class loader, TextFilesClassLoader.

The start class of Matrex is now called MatrexLoader.
MatrexLoader loads the main class of Matrex, Start, using TextFilesClassLoader as class loader.
Since Start all the other classes of Matrex (included the ones in the library) are loaded, directly or indirectly, from Start, they all use the same class loader used by Start, TextFilesClassLoader.

In this way it has been also possible to write a special Matrex GUI dialog, PluginsDialog, to update the content of plugins.cld:



This is much easier than to change manually the batch file.


Wednesday, February 06, 2008

Matrex functions unit testing

I added a small chapter at the end of the function coding document about the Matrex functions code unit testing.


Before version 1.2 some of the Matrex functions had JUnit unit testing, but it was very limited.
In version 1.2 I had to write the code for the ISQL function template, which is very complex compared to the other templates.
So I needed to test it well.
For this reason I wrote some unit testing help classes (for JUnit) that I grouped under the package matrex.item.test.
These classes can be used for the unit testing of any Matrex function template.

With these classes unit testing of matrex functions becomes very easy. For standard function templates it is a matter of minutes to write a test case.
Give a look to them!

Monday, February 04, 2008

Matrex 1.2 released

Finally Matrex 1.2 has been released!

The big step forward of this version is the new ISQL module.
The ISQL module is a function template to apply SQL queries to vectors in a Matrex project.
It is therefore possible:
  • to apply filters on parts of the vectors
  • to order the elements of the vectors
  • to aggregate them
all with simple SQL queries. The internalsql document contained in the distributions explains how.
As far as I know, no other spreadsheet application allows something similar.

Other enhancements are:

  • Print matrices and presentations.
  • Export matrices and presentations to csv and xls.



  • Import data from database, using an SQL query.
  • Menus to remove multiple items, duplicate matrices and functions, add function from a matrix (the function will have the matrix as first argument).


  • A summary step for the expression parser.

  • Possibility to change the colors of the windows headers.


Also, several bugs have been removed (dates formatting, items renaming, boolean matrices editing).