Skip to main content
Jump to: navigation, search

RAP/BIRT Integration

Revision as of 08:53, 2 July 2009 by (Talk | contribs) (Use the right renderer)

| RAP wiki home | RAP project home |



Besides a rich user interaction many applications need to display a big amount of data sets as diagrams or reports as part of their applications. In order to bridge the gap the BIRT project was created as part of the eclipse ecosystem. BIRT is an open source Eclipse-based reporting system that integrates with your Java/J2EE application to produce compelling reports. That BIRT integrates well with classic RCP applications is a well known fact. But the need for rich internet applications is still growing. And here the RAP comes into play. As a platform for developing Web 2.0 applications with the same patterns as for RCP it paves the way for single sourcing applications running on both platforms. In this talk we will show how to integrate diagrams and reports known from BIRT into RAP applications. Topics covered include how to setup the environment to let BIRT and RAP play well together. In addition we will give advices how to use the reports inside RAP applications and which problems may arise. As a final outcome of we will know everything to bring reporting capabilities into RAP applications.


The first thing we need to do is to mix up a target which contains both runtimes: RAP and BIRT. We need to download both runtimes first:

When merging the two runtimes together, we should be sure that no bundle is available twice as this results in same strange errors during runtime. So first step is to remove all the duplicate bundles.

Fixing ICU

RAP provides them in version 4, the BIRT runtime needs them in version 3. So be sure that you include version 3 of the ICU bundles in order to get the constraints resolved for both runtimes.



Under normal circumstances you create your chart object, fill it with some data and draw it on some surface. As RAP does not support any drawing capabilities we need to adjust the last step a little bit.

Create the chart object

Creating a new chart is done exactly as you would do it in the SWT/RCP case. For more information how to use the Chart API of BIRT, please refer to one of the BIRT tutorials (eg. Using the BIRT Chart Engine in Your Plug-in We only included an example here for the sake of completeness.

private Chart createBarChart() {
    ChartWithAxes chart = ChartWithAxesImpl.create();
    chart.setDimension( ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL );
    Plot plot = chart.getPlot();
    plot.setBackground( ColorDefinitionImpl.WHITE() );
    plot.getClientArea().setBackground( ColorDefinitionImpl.WHITE() );
    Legend legend = chart.getLegend();
    legend.setItemType( LegendItemType.CATEGORIES_LITERAL );
    legend.setVisible( true );
    Text caption = chart.getTitle().getLabel().getCaption();
    caption.setValue( "Distribution of Chart Column Heights" );
    Axis xAxis = ( ( ChartWithAxes )chart ).getPrimaryBaseAxes()[ 0 ];
    xAxis.getTitle().setVisible( true );
    xAxis.getTitle().getCaption().setValue( "" );
    Axis yAxis = ( ( ChartWithAxes )chart ).getPrimaryOrthogonalAxis( xAxis );
    yAxis.getTitle().setVisible( true );
    yAxis.getTitle().getCaption().setValue( "" );
    yAxis.getScale().setStep( 1.0 );
    TextDataSet categoryValues = TextDataSetImpl.create( new String[]{
      "short", "medium", "tall"
    } );
    Series seCategory = SeriesImpl.create();
    seCategory.setDataSet( categoryValues );
    SeriesDefinition sdX = SeriesDefinitionImpl.create();
    sdX.getSeriesPalette().shift( 1 );
    xAxis.getSeriesDefinitions().add( sdX );
    sdX.getSeries().add( seCategory );
    NumberDataSet orthoValuesDataSet1 = NumberDataSetImpl.create( new double[]{
      1, 2, 3
    } );
    BarSeries bs1 = ( BarSeries )BarSeriesImpl.create();
    bs1.setDataSet( orthoValuesDataSet1 );
    SeriesDefinition sdY = SeriesDefinitionImpl.create();
    yAxis.getSeriesDefinitions().add( sdY );
    sdY.getSeries().add( bs1 );
    return chart;

Use the right renderer

Instead of using the SWT renderer, we just use a simple file renderer (eg. PNG) to draw the chart. In RAP enviroments we should never use the org.eclipse.birt.chart.device.swt. Instead we can use the simple image renderes found in org.eclipse.birt.chart.device.extension.

Here you can see the dependencies of one of the example projects:

Birt dependencies.png

The most important items are:

  • org.eclipse.birt.chart.engine - The chart engine itself
  • org.eclipse.birt.chart.engine.extension - All chart types
  • org.eclipse.birt.chart.device.extension - The image file renderers

Display the image

Be aware of TSD


PDF reports

HTML reports


Back to the top