Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Multiple Charts on a Canvas
Multiple Charts on a Canvas [message #552791] Fri, 13 August 2010 10:11 Go to next message
No real name is currently offline No real name
Messages: 23
Registered: August 2010
Junior Member
Hello,
I am working on an SWT environment and I need to draw a huge number of tiny charts. Is it possible to draw multiple charts on 1 canvas as opposed to creating each chart on its own canvas (which creates a DeviceRenderer bottleneck in my case).
If so could you pls post a code snippet?

Thanks.
Re: Multiple Charts on a Canvas [message #552834 is a reply to message #552791] Fri, 13 August 2010 12:50 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

I do not know if this is the best way to do this, but here is a snippet
of how I showed 2 charts on the same canvas.

public final void paintControl( PaintEvent e )
{

Rectangle d = this.getClientArea( );
d.height = d.height/2;
d.width = d.width/2;
Rectangle c = new Rectangle(d.width, d.height, d.width, d.height);
Image imgChart = new Image( this.getDisplay( ), d );
Image imgChart2 = new Image( this.getDisplay( ), c );

GC gcImage = new GC( imgChart );

//Look at IDeviceRenderer.java for all properties
//like DPI_RESOLUTION
//FILE_IDENTIFIER
//FORMAT_IDENTIFIER
//UPDATE_NOTIFIER

Generator gr = Generator.instance( );
try
{

idr.setProperty( IDeviceRenderer.GRAPHICS_CONTEXT, gcImage );

Bounds bo = BoundsImpl.create( 0, 0, d.width, d.height );
bo.scale( 72d / idr.getDisplayServer( ).getDpiResolution( ) );
gcs = gr.build( idr.getDisplayServer( ),
cm,
bo,
null,
null,
null );
gr.render( idr, gcs );
GC gc = e.gc;
gc.drawImage( imgChart, d.x, d.y );

Bounds bo2 = BoundsImpl.create( 0, 0, c.width, c.height );
bo2.scale( 72d / idr.getDisplayServer( ).getDpiResolution( ) );

gcs = gr.build( idr.getDisplayServer( ),
cm2,
bo2,
null,
null,
null );
gr.render( idr, gcs );
gc.drawImage( imgChart, c.x, c.y );


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

}
}

Jason

On 8/13/2010 10:11 AM, asadanandan@axiomainc.com wrote:
> Hello,
> I am working on an SWT environment and I need to draw a huge number of
> tiny charts. Is it possible to draw multiple charts on 1 canvas as
> opposed to creating each chart on its own canvas (which creates a
> DeviceRenderer bottleneck in my case).
> If so could you pls post a code snippet?
>
> Thanks.
Previous Topic:Number formatting in BIRT 2.3.1
Next Topic:Eclipse Helios & BIRT 2.6 freezes
Goto Forum:
  


Current Time: Sat Aug 30 20:23:19 EDT 2014

Powered by FUDForum. Page generated in 0.01656 seconds