So what is the relation between all of the above words on the title?
InfoCaptor is a dashboard designer used to create dashboard based on databases using SQL queries.
InfoCaptor displays information in tables and charts. For displaying tabular information it uses jtable component and for the graphs it uses JfreeChart as the graphing library.
JfreeChart is a very poweful and mature library. There are so many chart varieties available and each chart is extensively customizable.
InfoCaptor provides basic properties to be edited from the Graph editor (glet). For e.g you can change the title, background color, angle of the axis labels, item label fonts etc. But apart from these there are so many other properties and customizations that you can do to your charts and it would be impractical to provide each and every property on the Glet editor for users to modify.
The solution was to provide the end-users to add dynamic scripting where they can change the behaviour of the graphs using dynamic java like code. So Beanshell comes into the picture. With Beanshell, you can type code at run-time.
import org.jfree.*; import org.jfree.chart.renderer.category.BarRenderer3D; BarRenderer3D barRenderer = (BarRenderer3D)plot.getRenderer(); barRenderer.setDrawBarOutline(true); GradientPaint gp0 = new GradientPaint( 0.0f, 0.0f, Color.YELLOW, 0.0f, 500.0f,new Color(0,0,0,100) ); GradientPaint gp1 = new GradientPaint( 0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray ); GradientPaint gp2 = new GradientPaint( 0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray ); barRenderer.setSeriesPaint(0, gp0); barRenderer.setSeriesPaint(1, gp1); barRenderer.setSeriesPaint(2, gp2); float h = displayFrame.getHeight(); float w = displayFrame.getWidth(); GradientPaint gradientPaint = new GradientPaint(0.0F, 10.0F, Color.WHITE, h, w, Color.green.darker()); plot.setBackgroundPaint(gradientPaint); chart.setBackgroundPaint(new GradientPaint(0,0,Color.blue,0,displayFrame.getHeight(), Color.LIGHT_GRAY));
Prior to running the above script the chart looks as below
Once you run the script the chart looks like below
So with the power of Beanshell, InfoCaptor will be able to support custom extensions and this is really powerful stuff.
There will be a option to turn On/Off the Dynamic run of the script.
This will be packaged in the next release of InfoCaptor so stay tuned 🙂