Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Exception in thread "main" java.lang.IncompatibleClassChangeError(bug while using chart engine api)
Exception in thread "main" java.lang.IncompatibleClassChangeError [message #526922] Tue, 13 April 2010 13:55 Go to next message
laxmipathi raju is currently offline laxmipathi rajuFriend
Messages: 17
Registered: April 2010
Junior Member
Hi,
While using chart engine api i am getting the following exception ...

Exception in thread "main" java.lang.IncompatibleClassChangeError: Expected static method org.eclipse.birt.report.model.metadata.MetaDataDictionary.in tializeExtension()V
at org.eclipse.birt.report.model.api.impl.DesignEngineImpl.init ialize(DesignEngineImpl.java:99)
at org.eclipse.birt.report.model.api.impl.DesignEngineImpl.newS essionHandle(DesignEngineImpl.java:147)
at org.eclipse.birt.report.model.api.DesignEngine.newSessionHan dle(DesignEngine.java:108)
at org.eclipse.birt.report.engine.parser.ReportParser.getDesign Handle(ReportParser.java:143)
at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.o penReportDesign(ReportEngineHelper.java:255)
at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.o penReportDesign(ReportEngineHelper.java:195)
at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.o penReportDesign(ReportEngineHelper.java:129)
at org.eclipse.birt.report.engine.api.impl.ReportEngine.openRep ortDesign(ReportEngine.java:308)
at ChartTest.executeReport(ChartTest.java:118)
at ChartTest.main(ChartTest.java:380)


Note: I am using a rptdesing file which is desinged in BIRT 2.5.0 and i am using birt_runtime_2.5.1


Please give me the reason why this exception is coming .


Thanks & Regards,
Laxmipathi Raju
Re: Exception in thread "main" java.lang.IncompatibleClassChangeError [message #526983 is a reply to message #526922] Tue, 13 April 2010 15:54 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

How are you opening the chart? Here is an example of adding a chart to
a report design using the DE API.


Jason



import java.io.IOException;
import java.util.ArrayList;
import java.util.Vector;

import org.eclipse.birt.chart.model.Chart;
import org.eclipse.birt.chart.model.ChartWithAxes;
import org.eclipse.birt.chart.model.attribute.Anchor;
import org.eclipse.birt.chart.model.attribute.AxisType;
import org.eclipse.birt.chart.model.attribute.ChartDimension;
import org.eclipse.birt.chart.model.attribute.IntersectionType;
import org.eclipse.birt.chart.model.attribute.Position;
import org.eclipse.birt.chart.model.attribute.TickStyle;
import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionI mpl;
import org.eclipse.birt.chart.model.component.Axis;
import org.eclipse.birt.chart.model.component.Series;
import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
import org.eclipse.birt.chart.model.data.NumberDataSet;
import org.eclipse.birt.chart.model.data.Query;
import org.eclipse.birt.chart.model.data.SeriesDefinition;
import org.eclipse.birt.chart.model.data.TextDataSet;
import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl;
import org.eclipse.birt.chart.model.data.impl.QueryImpl;
import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl;
import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl;
import org.eclipse.birt.chart.model.layout.Legend;
import org.eclipse.birt.chart.model.layout.Plot;
import org.eclipse.birt.chart.model.type.BarSeries;
import org.eclipse.birt.chart.model.type.impl.BarSeriesImpl;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.DesignEngine;
import org.eclipse.birt.report.model.api.DesignFileException;
import org.eclipse.birt.report.model.api.ElementFactory;
import org.eclipse.birt.report.model.api.ExtendedItemHandle;
import org.eclipse.birt.report.model.api.IDesignEngine;
import org.eclipse.birt.report.model.api.IDesignEngineFactory;
import org.eclipse.birt.report.model.api.PropertyHandle;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.SessionHandle;
import org.eclipse.birt.report.model.api.StructureFactory;
import org.eclipse.birt.report.model.api.activity.SemanticException ;
import org.eclipse.birt.report.model.api.elements.structures.Comput edColumn;
import org.eclipse.birt.report.model.api.extension.ExtendedElementE xception;
import org.eclipse.birt.chart.model.data.*;
import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl;

import com.ibm.icu.util.ULocale;


public class AddChart
{

/**
* execute application
*
* @param args
*/
public static void main( String[] args )
{
new AddChart( ).addMyChart( );

}

/**
* Get the chart instance from the design file and add series grouping key.
*
* @return An instance of the simulated runtime chart model (containing
* filled datasets)
*/
void addMyChart( )
{
ReportDesignHandle designHandle = null;
DesignConfig config = new DesignConfig( );

config.setBIRTHome("C:/birt/birt-runtime-2_3_1/birt-runtime-2_3_1/ReportEngine ");
IDesignEngine engine = null;
try{

Platform.startup( config );
IDesignEngineFactory factory = (IDesignEngineFactory) Platform
.createFactoryObject(
IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
engine = factory.createDesignEngine( config );

}catch( Exception ex){
ex.printStackTrace();
}

SessionHandle sessionHandle = engine.newSessionHandle( (ULocale) null );

try
{
designHandle = sessionHandle.openDesign(
"report/reporttemplate.rpttemplate" );//$NON-NLS-1$
ElementFactory designFactory = designHandle.getElementFactory( );
designHandle.getBody( ).add( createMyChart(designFactory) );
}
catch ( Exception e )
{
// TODO Auto-generated catch block
e.printStackTrace( );
}


try
{
designHandle.saveAs( "report/myaddedchart.rptdesign" );//$NON-NLS-1$
System.out.println("Finished");
}
catch ( IOException e )
{
e.printStackTrace( );
}
Platform.shutdown();

}
public static ExtendedItemHandle createMyChart(ElementFactory
designFactory)
{

ExtendedItemHandle eih = designFactory.newExtendedItem (
null,"Chart" );
ComputedColumn cs1=null, cs2=null;
try
{
eih.setHeight( "175pt" );//$NON-NLS-1$
eih.setWidth( "450pt" );//$NON-NLS-1$
eih.setProperty ( ExtendedItemHandle.DATA_SET_PROP,
"ChartData");//$NON-NLS-1$
eih.setProperty("outputFormat", "PNG");

PropertyHandle cs = eih.getColumnBindings();
cs1 = StructureFactory.createComputedColumn();
cs2 = StructureFactory.createComputedColumn();
cs1.setName("xaxis");
cs1.setDataType("string");
cs2.setName("yaxis");
cs2.setDataType("float");

cs1.setExpression("dataSetRow[\"xaxis\"]");
cs2.setExpression("dataSetRow[\"yaxis\"]");
cs.addItem(cs1);
cs.addItem(cs2);
}
catch ( SemanticException e )
{
e.printStackTrace( );
}


// BAR CHARTS ARE BASED ON CHARTS THAT CONTAIN AXES

ChartWithAxes cwaBar = ChartWithAxesImpl.create();
cwaBar.setType("Bar Chart"); //$NON-NLS-1$
cwaBar.setSubType("Side-by-side");
cwaBar.getBlock().setBounds( BoundsImpl.create( 0, 0, 450, 175));


SampleData sd = DataFactory.eINSTANCE.createSampleData( );

BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData( );

sdBase.setDataSetRepresentation( "Category-A, Category-B" );//$NON-NLS-1$

sd.getBaseSampleData( ).add( sdBase );


OrthogonalSampleData sdOrthogonal =
DataFactory.eINSTANCE.createOrthogonalSampleData( );

sdOrthogonal.setDataSetRepresentation( "4,12" );//$NON-NLS-1$

sdOrthogonal.setSeriesDefinitionIndex( 0 );

sd.getOrthogonalSampleData( ).add( sdOrthogonal );


cwaBar.setSampleData( sd );



cwaBar.getBlock().setBackground(

ColorDefinitionImpl.WHITE()

);

cwaBar.getBlock().getOutline().setVisible(true);

cwaBar.setDimension(

ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL

);

// CUSTOMIZE THE PLOT

Plot p = cwaBar.getPlot();

p.getClientArea().setBackground(

ColorDefinitionImpl.create(255, 255, 225)

);

p.getOutline().setVisible(false);

cwaBar.getTitle().getLabel().getCaption().setValue(

"Simple Bar Chart"

);

// CUSTOMIZE THE LEGEND

Legend lg = cwaBar.getLegend();

lg.getText().getFont().setSize(16);

lg.getInsets().set(10, 5, 0, 0);

lg.setAnchor(Anchor.NORTH_LITERAL);

// CUSTOMIZE THE X-AXIS

Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes()[0];

xAxisPrimary.setType(AxisType.TEXT_LITERAL);

xAxisPrimary.getMajorGrid().setTickStyle(

TickStyle.BELOW_LITERAL

);

xAxisPrimary.getOrigin().setType(

IntersectionType.VALUE_LITERAL

);

xAxisPrimary.getTitle().setVisible(false);

// CUSTOMIZE THE Y-AXIS

Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis(

xAxisPrimary

);

yAxisPrimary.getMajorGrid().setTickStyle(

TickStyle.LEFT_LITERAL

);

yAxisPrimary.setType(AxisType.LINEAR_LITERAL);

yAxisPrimary.getLabel().getCaption().getFont().setRotation(9 0);

// INITIALIZE A COLLECTION WITH THE X-SERIES DATA

Vector vs = new Vector();

vs.add("zero");

vs.add("one");

vs.add("two");

TextDataSet categoryValues = TextDataSetImpl.create(vs);

// INITIALIZE A COLLECTION WITH THE Y-SERIES DATA

ArrayList vn1 = new ArrayList();

vn1.add(new Double(25));

vn1.add(new Double(35));

vn1.add(new Double(-45));

NumberDataSet orthoValues1 = NumberDataSetImpl.create(

vn1

);

// CREATE THE CATEGORY BASE SERIES

Series seCategory = SeriesImpl.create();
Query xQ = QueryImpl.create( "row[\"xaxis\"].length" );
seCategory.getDataDefinition( ).add( xQ );
//seCategory.setDataSet(categoryValues);

// CREATE THE VALUE ORTHOGONAL SERIES

BarSeries bs1 = (BarSeries) BarSeriesImpl.create();

bs1.setSeriesIdentifier("My Bar Series");

//bs1.setDataSet(orthoValues1);
Query yQ = QueryImpl.create( "row[\"yaxis\"]" );
bs1.getDataDefinition( ).add( yQ );
bs1.setRiserOutline(null);

bs1.getLabel().setVisible(true);

bs1.setLabelPosition(Position.INSIDE_LITERAL);

// WRAP THE BASE SERIES IN THE X-AXIS SERIES DEFINITION

SeriesDefinition sdX = SeriesDefinitionImpl.create();

sdX.getSeriesPalette().update(0); // SET THE COLORS IN THE PALETTE

xAxisPrimary.getSeriesDefinitions().add(sdX);

sdX.getSeries().add(seCategory);

// WRAP THE ORTHOGONAL SERIES IN THE X-AXIS SERIES DEFINITION

SeriesDefinition sdY = SeriesDefinitionImpl.create();

sdY.getSeriesPalette().update(1); // SET THE COLOR IN THE PALETTE

yAxisPrimary.getSeriesDefinitions().add(sdY);

sdY.getSeries().add(bs1);

try
{
//Add ChartReportItemImpl to ExtendedItemHandle
eih.getReportItem( ).setProperty( "chart.instance", cwaBar );
}
catch ( ExtendedElementException e )
{
e.printStackTrace( );
}

return eih;

}
}


laxmipathi raju wrote:
> Hi,
> While using chart engine api i am getting the following exception ...
>
> Exception in thread "main" java.lang.IncompatibleClassChangeError:
> Expected static method
> org.eclipse.birt.report.model.metadata.MetaDataDictionary.in
> tializeExtension()V
> at org.eclipse.birt.report.model.api.impl.DesignEngineImpl.init
> ialize(DesignEngineImpl.java:99)
> at org.eclipse.birt.report.model.api.impl.DesignEngineImpl.newS
> essionHandle(DesignEngineImpl.java:147)
> at org.eclipse.birt.report.model.api.DesignEngine.newSessionHan
> dle(DesignEngine.java:108)
> at org.eclipse.birt.report.engine.parser.ReportParser.getDesign
> Handle(ReportParser.java:143)
> at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.o
> penReportDesign(ReportEngineHelper.java:255)
> at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.o
> penReportDesign(ReportEngineHelper.java:195)
> at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.o
> penReportDesign(ReportEngineHelper.java:129)
> at org.eclipse.birt.report.engine.api.impl.ReportEngine.openRep
> ortDesign(ReportEngine.java:308)
> at ChartTest.executeReport(ChartTest.java:118)
> at ChartTest.main(ChartTest.java:380)
>
>
> Note: I am using a rptdesing file which is desinged in BIRT 2.5.0 and i
> am using birt_runtime_2.5.1
>
> Please give me the reason why this exception is coming .
>
>
> Thanks & Regards,
> Laxmipathi Raju
>
Re: Exception in thread "main" java.lang.IncompatibleClassChangeError [message #526984 is a reply to message #526983] Tue, 13 April 2010 15:54 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Here is an example of modifying an existing chart using the DE/CE API.

Jason

/*********************************************************** ************
* Copyright (c) 2004 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Actuate Corporation - initial API and implementation
************************************************************ ***********/



import java.io.IOException;

import org.eclipse.birt.chart.model.Chart;
import org.eclipse.birt.chart.model.ChartWithAxes;
import org.eclipse.birt.chart.model.attribute.DataType;
import org.eclipse.birt.chart.model.attribute.SortOption;
import org.eclipse.birt.chart.model.component.Axis;
import org.eclipse.birt.chart.model.data.SeriesDefinition;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.DesignEngine;
import org.eclipse.birt.report.model.api.DesignFileException;
import org.eclipse.birt.report.model.api.ExtendedItemHandle;
import org.eclipse.birt.report.model.api.IDesignEngine;
import org.eclipse.birt.report.model.api.IDesignEngineFactory;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.SessionHandle;
import org.eclipse.birt.report.model.api.extension.ExtendedElementE xception;

import com.ibm.icu.util.ULocale;

/**
* Presents a bar chart with grouping on X series, which could be
acheived in
* the report designer as follows: Chart Builder -> Data -> X Series ->
Set Dat
* Sorting / Tick Grouping Enabled
*/
public class GroupOnXSeries
{

/**
* execute application
*
* @param args
*/
public static void main( String[] args )
{
new GroupOnXSeries( ).groupSeries( );

}

/**
* Get the chart instance from the design file and group X series of the
* chart.
*
* @return An instance of the simulated runtime chart model (containing
* filled datasets)
*/
void groupSeries( )
{


ReportDesignHandle designHandle = null;
DesignConfig config = new DesignConfig( );

config.setBIRTHome("C:/birt/birt-runtime-2_5_1/birt-runtime-2_5_1/ReportEngine ");
IDesignEngine engine = null;
try{

Platform.startup( config );
IDesignEngineFactory factory = (IDesignEngineFactory) Platform
.createFactoryObject(
IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
engine = factory.createDesignEngine( config );

}catch( Exception ex){
ex.printStackTrace();
}

SessionHandle sessionHandle = engine.newSessionHandle( (ULocale) null );


try
{
designHandle = sessionHandle.openDesign(
"report/NonGroupOnXSeries.rptdesign" );//$NON-NLS-1$
}
catch ( DesignFileException e )
{
// TODO Auto-generated catch block
e.printStackTrace( );
}

ExtendedItemHandle eih = (ExtendedItemHandle) designHandle.getBody( )
.getContents( ).get( 0 );

Chart cm = null;
try
{
cm = (Chart) eih.getReportItem( ).getProperty( "chart.instance" );
//$NON-NLS-1$
}
catch ( ExtendedElementException e )
{
// TODO Auto-generated catch block
e.printStackTrace( );
}

cm.getTitle( ).getLabel( ).getCaption( ).setValue( "Group On X Series"
);//$NON-NLS-1$

cm.getTitle( ).getLabel( ).getCaption( ).getFont().setSize(12);
cm.getTitle( ).getLabel( ).getCaption( ).getFont().setRotation(45);

SeriesDefinition sdX = (SeriesDefinition) ( (Axis) ( (ChartWithAxes) cm )
.getAxes( ).get( 0 ) ).getSeriesDefinitions( ).get( 0 );

sdX.setSorting( SortOption.ASCENDING_LITERAL );
sdX.getGrouping( ).setEnabled( true );
sdX.getGrouping( ).setAggregateExpression( "Sum" );//$NON-NLS-1$
sdX.getGrouping( ).setGroupType( DataType.NUMERIC_LITERAL );
sdX.getGrouping( ).setGroupingInterval( 1 );


try
{
designHandle.saveAs( "report/GroupOnXSeries.rptdesign" );//$NON-NLS-1$
}
catch ( IOException e )
{
e.printStackTrace( );
}
Platform.shutdown();

}

}


Jason Weathersby wrote:
> How are you opening the chart? Here is an example of adding a chart to
> a report design using the DE API.
>
>
> Jason
>
>
>
> import java.io.IOException;
> import java.util.ArrayList;
> import java.util.Vector;
>
> import org.eclipse.birt.chart.model.Chart;
> import org.eclipse.birt.chart.model.ChartWithAxes;
> import org.eclipse.birt.chart.model.attribute.Anchor;
> import org.eclipse.birt.chart.model.attribute.AxisType;
> import org.eclipse.birt.chart.model.attribute.ChartDimension;
> import org.eclipse.birt.chart.model.attribute.IntersectionType;
> import org.eclipse.birt.chart.model.attribute.Position;
> import org.eclipse.birt.chart.model.attribute.TickStyle;
> import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionI mpl;
> import org.eclipse.birt.chart.model.component.Axis;
> import org.eclipse.birt.chart.model.component.Series;
> import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
> import org.eclipse.birt.chart.model.data.NumberDataSet;
> import org.eclipse.birt.chart.model.data.Query;
> import org.eclipse.birt.chart.model.data.SeriesDefinition;
> import org.eclipse.birt.chart.model.data.TextDataSet;
> import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl;
> import org.eclipse.birt.chart.model.data.impl.QueryImpl;
> import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
> import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl;
> import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl;
> import org.eclipse.birt.chart.model.layout.Legend;
> import org.eclipse.birt.chart.model.layout.Plot;
> import org.eclipse.birt.chart.model.type.BarSeries;
> import org.eclipse.birt.chart.model.type.impl.BarSeriesImpl;
> import org.eclipse.birt.core.framework.Platform;
> import org.eclipse.birt.report.model.api.DesignConfig;
> import org.eclipse.birt.report.model.api.DesignEngine;
> import org.eclipse.birt.report.model.api.DesignFileException;
> import org.eclipse.birt.report.model.api.ElementFactory;
> import org.eclipse.birt.report.model.api.ExtendedItemHandle;
> import org.eclipse.birt.report.model.api.IDesignEngine;
> import org.eclipse.birt.report.model.api.IDesignEngineFactory;
> import org.eclipse.birt.report.model.api.PropertyHandle;
> import org.eclipse.birt.report.model.api.ReportDesignHandle;
> import org.eclipse.birt.report.model.api.SessionHandle;
> import org.eclipse.birt.report.model.api.StructureFactory;
> import org.eclipse.birt.report.model.api.activity.SemanticException ;
> import
> org.eclipse.birt.report.model.api.elements.structures.Comput edColumn;
> import
> org.eclipse.birt.report.model.api.extension.ExtendedElementE xception;
> import org.eclipse.birt.chart.model.data.*;
> import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl;
>
> import com.ibm.icu.util.ULocale;
>
>
> public class AddChart
> {
>
> /**
> * execute application
> *
> * @param args
> */
> public static void main( String[] args )
> {
> new AddChart( ).addMyChart( );
>
> }
>
> /**
> * Get the chart instance from the design file and add series
> grouping key.
> *
> * @return An instance of the simulated runtime chart model (containing
> * filled datasets)
> */
> void addMyChart( )
> {
> ReportDesignHandle designHandle = null;
> DesignConfig config = new DesignConfig( );
>
> config.setBIRTHome("C:/birt/birt-runtime-2_3_1/birt-runtime-2_3_1/ReportEngine ");
>
> IDesignEngine engine = null;
> try{
>
> Platform.startup( config );
> IDesignEngineFactory factory = (IDesignEngineFactory) Platform
> .createFactoryObject(
> IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
> engine = factory.createDesignEngine( config );
>
> }catch( Exception ex){
> ex.printStackTrace();
> }
>
> SessionHandle sessionHandle = engine.newSessionHandle( (ULocale)
> null );
>
> try
> {
> designHandle = sessionHandle.openDesign(
> "report/reporttemplate.rpttemplate" );//$NON-NLS-1$
> ElementFactory designFactory =
> designHandle.getElementFactory( );
> designHandle.getBody( ).add( createMyChart(designFactory) );
> }
> catch ( Exception e )
> {
> // TODO Auto-generated catch block
> e.printStackTrace( );
> }
>
>
> try
> {
> designHandle.saveAs( "report/myaddedchart.rptdesign"
> );//$NON-NLS-1$
> System.out.println("Finished");
> }
> catch ( IOException e )
> {
> e.printStackTrace( );
> }
> Platform.shutdown();
>
> }
> public static ExtendedItemHandle createMyChart(ElementFactory
> designFactory)
> {
>
> ExtendedItemHandle eih = designFactory.newExtendedItem (
> null,"Chart" );
> ComputedColumn cs1=null, cs2=null;
> try
> {
> eih.setHeight( "175pt" );//$NON-NLS-1$
> eih.setWidth( "450pt" );//$NON-NLS-1$
> eih.setProperty ( ExtendedItemHandle.DATA_SET_PROP,
> "ChartData");//$NON-NLS-1$
> eih.setProperty("outputFormat", "PNG");
>
> PropertyHandle cs = eih.getColumnBindings();
> cs1 = StructureFactory.createComputedColumn();
> cs2 = StructureFactory.createComputedColumn();
> cs1.setName("xaxis");
> cs1.setDataType("string");
> cs2.setName("yaxis");
> cs2.setDataType("float");
>
> cs1.setExpression("dataSetRow[\"xaxis\"]");
> cs2.setExpression("dataSetRow[\"yaxis\"]");
> cs.addItem(cs1);
> cs.addItem(cs2);
> }
> catch ( SemanticException e )
> {
> e.printStackTrace( );
> }
>
>
> // BAR CHARTS ARE BASED ON CHARTS THAT CONTAIN AXES
>
> ChartWithAxes cwaBar = ChartWithAxesImpl.create();
> cwaBar.setType("Bar Chart"); //$NON-NLS-1$
> cwaBar.setSubType("Side-by-side");
> cwaBar.getBlock().setBounds( BoundsImpl.create( 0, 0, 450,
> 175));
>
>
> SampleData sd = DataFactory.eINSTANCE.createSampleData( );
>
> BaseSampleData sdBase =
> DataFactory.eINSTANCE.createBaseSampleData( );
>
> sdBase.setDataSetRepresentation( "Category-A, Category-B"
> );//$NON-NLS-1$
>
> sd.getBaseSampleData( ).add( sdBase );
>
>
> OrthogonalSampleData sdOrthogonal =
> DataFactory.eINSTANCE.createOrthogonalSampleData( );
>
> sdOrthogonal.setDataSetRepresentation( "4,12" );//$NON-NLS-1$
>
> sdOrthogonal.setSeriesDefinitionIndex( 0 );
>
> sd.getOrthogonalSampleData( ).add( sdOrthogonal );
>
>
> cwaBar.setSampleData( sd );
>
>
>
> cwaBar.getBlock().setBackground(
>
> ColorDefinitionImpl.WHITE()
>
> );
>
> cwaBar.getBlock().getOutline().setVisible(true);
>
> cwaBar.setDimension(
>
> ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL
>
> );
>
> // CUSTOMIZE THE PLOT
>
> Plot p = cwaBar.getPlot();
>
> p.getClientArea().setBackground(
>
> ColorDefinitionImpl.create(255, 255, 225)
>
> );
>
> p.getOutline().setVisible(false);
>
> cwaBar.getTitle().getLabel().getCaption().setValue(
>
> "Simple Bar Chart"
>
> );
>
> // CUSTOMIZE THE LEGEND
>
> Legend lg = cwaBar.getLegend();
>
> lg.getText().getFont().setSize(16);
>
> lg.getInsets().set(10, 5, 0, 0);
>
> lg.setAnchor(Anchor.NORTH_LITERAL);
>
> // CUSTOMIZE THE X-AXIS
>
> Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes()[0];
>
> xAxisPrimary.setType(AxisType.TEXT_LITERAL);
>
> xAxisPrimary.getMajorGrid().setTickStyle(
>
> TickStyle.BELOW_LITERAL
>
> );
>
> xAxisPrimary.getOrigin().setType(
>
> IntersectionType.VALUE_LITERAL
>
> );
>
> xAxisPrimary.getTitle().setVisible(false);
>
> // CUSTOMIZE THE Y-AXIS
>
> Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis(
>
> xAxisPrimary
>
> );
>
> yAxisPrimary.getMajorGrid().setTickStyle(
>
> TickStyle.LEFT_LITERAL
>
> );
>
> yAxisPrimary.setType(AxisType.LINEAR_LITERAL);
>
> yAxisPrimary.getLabel().getCaption().getFont().setRotation(9 0);
>
> // INITIALIZE A COLLECTION WITH THE X-SERIES DATA
>
> Vector vs = new Vector();
>
> vs.add("zero");
>
> vs.add("one");
>
> vs.add("two");
>
> TextDataSet categoryValues = TextDataSetImpl.create(vs);
>
> // INITIALIZE A COLLECTION WITH THE Y-SERIES DATA
>
> ArrayList vn1 = new ArrayList();
>
> vn1.add(new Double(25));
>
> vn1.add(new Double(35));
>
> vn1.add(new Double(-45));
>
> NumberDataSet orthoValues1 = NumberDataSetImpl.create(
>
> vn1
>
> );
>
> // CREATE THE CATEGORY BASE SERIES
>
> Series seCategory = SeriesImpl.create();
> Query xQ = QueryImpl.create( "row[\"xaxis\"].length" );
> seCategory.getDataDefinition( ).add( xQ );
> //seCategory.setDataSet(categoryValues);
>
> // CREATE THE VALUE ORTHOGONAL SERIES
>
> BarSeries bs1 = (BarSeries) BarSeriesImpl.create();
>
> bs1.setSeriesIdentifier("My Bar Series");
>
> //bs1.setDataSet(orthoValues1);
> Query yQ = QueryImpl.create( "row[\"yaxis\"]" );
> bs1.getDataDefinition( ).add( yQ );
> bs1.setRiserOutline(null);
>
> bs1.getLabel().setVisible(true);
>
> bs1.setLabelPosition(Position.INSIDE_LITERAL);
>
> // WRAP THE BASE SERIES IN THE X-AXIS SERIES DEFINITION
>
> SeriesDefinition sdX = SeriesDefinitionImpl.create();
>
> sdX.getSeriesPalette().update(0); // SET THE COLORS IN THE
> PALETTE
>
> xAxisPrimary.getSeriesDefinitions().add(sdX);
>
> sdX.getSeries().add(seCategory);
>
> // WRAP THE ORTHOGONAL SERIES IN THE X-AXIS SERIES DEFINITION
>
> SeriesDefinition sdY = SeriesDefinitionImpl.create();
>
> sdY.getSeriesPalette().update(1); // SET THE COLOR IN THE
> PALETTE
>
> yAxisPrimary.getSeriesDefinitions().add(sdY);
>
> sdY.getSeries().add(bs1);
>
> try
> {
> //Add ChartReportItemImpl to ExtendedItemHandle
> eih.getReportItem( ).setProperty( "chart.instance",
> cwaBar );
> }
> catch ( ExtendedElementException e )
> {
> e.printStackTrace( );
> }
>
> return eih;
>
> }
> }
>
>
> laxmipathi raju wrote:
>> Hi,
>> While using chart engine api i am getting the following exception ...
>>
>> Exception in thread "main" java.lang.IncompatibleClassChangeError:
>> Expected static method
>> org.eclipse.birt.report.model.metadata.MetaDataDictionary.in
>> tializeExtension()V
>> at org.eclipse.birt.report.model.api.impl.DesignEngineImpl.init
>> ialize(DesignEngineImpl.java:99)
>> at org.eclipse.birt.report.model.api.impl.DesignEngineImpl.newS
>> essionHandle(DesignEngineImpl.java:147)
>> at org.eclipse.birt.report.model.api.DesignEngine.newSessionHan
>> dle(DesignEngine.java:108)
>> at org.eclipse.birt.report.engine.parser.ReportParser.getDesign
>> Handle(ReportParser.java:143)
>> at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.o
>> penReportDesign(ReportEngineHelper.java:255)
>> at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.o
>> penReportDesign(ReportEngineHelper.java:195)
>> at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.o
>> penReportDesign(ReportEngineHelper.java:129)
>> at org.eclipse.birt.report.engine.api.impl.ReportEngine.openRep
>> ortDesign(ReportEngine.java:308)
>> at ChartTest.executeReport(ChartTest.java:118)
>> at ChartTest.main(ChartTest.java:380)
>>
>>
>> Note: I am using a rptdesing file which is desinged in BIRT 2.5.0 and
>> i am using birt_runtime_2.5.1
>>
>> Please give me the reason why this exception is coming .
>>
>>
>> Thanks & Regards,
>> Laxmipathi Raju
>>
Previous Topic:Getting parameter values from JSP
Next Topic:Chart Drill Through
Goto Forum:
  


Current Time: Fri Sep 20 22:12:42 GMT 2024

Powered by FUDForum. Page generated in 0.03897 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top