1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
//le chart est envoyer à cette fonction qui le "traduit" en composite SWT
public ChartViewerSWT(final Chart chart, final Composite parent,
final int style)
{
super( parent, style );
try
{
idr = ChartEngine.instance( ).getRenderer( "dv.SWT" );
}
catch ( ChartException pex )
{
LOGGER.debug("Error in ChartViewerSWT {}", pex);
}
cm = chart;
LOGGER.debug("end");
}
/**
* The SWT paint callback
*/
public void paintControl(final PaintEvent pe)
{
Rectangle d = this.getClientArea( );
if ( bFirstPaint )
{
imgChart = new Image( this.getDisplay( ), d );
gcImage = new GC( imgChart );
idr.setProperty( IDeviceRenderer.GRAPHICS_CONTEXT, gcImage );
bo = BoundsImpl.create( 0, 0, d.width, d.height );
LOGGER.debug("d.width={}", d.width);
LOGGER.debug("d.height={}", d.height);
bo.scale( 72d / idr.getDisplayServer( ).getDpiResolution( ) );
}
Generator gr = Generator.instance();
try
{
gcs = gr.build( idr.getDisplayServer( ), cm, bo, null, null, null );
gr.render( idr, gcs );
GC gc = pe.gc;
gc.drawImage( imgChart, d.x, d.y );
LOGGER.debug("d.x={}", d.x);
LOGGER.debug("d.y={}", d.y);
}
catch (ChartException ce)
{
LOGGER.error(ce.getLocalizedMessage());
}
bFirstPaint = false;
} |
Partager