Package org.eclipse.birt.chart.device

Examples of org.eclipse.birt.chart.device.IDeviceRenderer


      gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
      gc.fillRectangle(buffer.getBounds());

      final Bounds bo = BoundsImpl.create(X_OFFSET, Y_OFFSET, adjustedRe.width - 2 * X_OFFSET, adjustedRe.height - 2 * Y_OFFSET);

      IDeviceRenderer deviceRenderer = null;
      try {
        deviceRenderer = PluginSettings.instance().getDevice("dv.SWT"); //$NON-NLS-1$
        deviceRenderer.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gc);
        bo.scale(72d / deviceRenderer.getDisplayServer().getDpiResolution()); // CONVERT
        // TO
        // POINTS

        // GENERATE AND RENDER THE CHART
        final Generator gr = Generator.instance();
        RunTimeContext rtc = new RunTimeContext();

        GeneratedChartState state = gr.build(deviceRenderer.getDisplayServer(), cm, bo, null, rtc, null);

        gr.render(deviceRenderer, state);
      } catch (Exception ex) {
        paintError = ex;
      } finally {
        gc.dispose();
        if (deviceRenderer != null) {
          deviceRenderer.dispose();
        }
      }

      if (paintError != null) {
        buffer = oldBuffer;
View Full Code Here


    mainComposite.setFocus();
  }
 
  public void renderPNG(IFile file){
    PluginSettings ps = PluginSettings.instance();
    IDeviceRenderer idr = null;
    
    try {
        idr = ps.getDevice("dv.PNG");
    } catch (ChartException pex) {
      pex.printStackTrace();
    }
    
    // define the bounds in points
    Bounds bo = BoundsImpl.create(0, 0, 800, 600); // in points
    // build the rendered chart structure
    Generator gr = Generator.instance();
    GeneratedChartState gcs = null;
    
    try {
        gcs = gr.build(idr.getDisplayServer(), cm, bo, null);
    } catch (ChartException gex) {
      gex.printStackTrace();   
    }
    
    // render the chart to a png file
    java.awt.Image img = new BufferedImage(
            (int) bo.getWidth(), (int) bo.getHeight(), BufferedImage.TYPE_INT_ARGB
    );
    try {
      idr.setProperty(IDeviceRenderer.FILE_IDENTIFIER, file.getRawLocation().toOSString());
      try {
        gr.render(idr, gcs);
      } catch (ChartException rex) {
        rex.printStackTrace();
      }
View Full Code Here

TOP

Related Classes of org.eclipse.birt.chart.device.IDeviceRenderer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.