|
Re: Multiple Charts on a Canvas [message #552834 is a reply to message #552791] |
Fri, 13 August 2010 16:50 |
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03330 seconds