Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsCannot render chart to image - possibly a bug
https://www.eclipse.org/forums/index.php/mv/msg/262951/759715/#msg_759715
http://www.birt-exchange.org/org/wiki/index.php?title=BIRT:Charts2.2
to render a chart to an image but the bottom of the image is missing. Here
is the code:
Is this still a bug or has it been fixed in versions > 2.6.1?]]>Anton2011-11-29T18:00:40-00:00Re: Cannot render chart to image - possibly a bug
https://www.eclipse.org/forums/index.php/mv/msg/262951/759968/#msg_759968
Take a look at the attached files.
Jason
On 11/29/2011 1:00 PM, Anton wrote:
> I use birt 2.6.1. I use the example on this page:
>
> http://www.birt-exchange.org/org/wiki/index.php?title=BIRT:Charts2.2
>
> to render a chart to an image but the bottom of the image is missing.
> Here is the code:
>
>
>
> // DEFINE A CHART STRUCTURE
> Chart cm = SampleCharts.createMyChart();
> // OBTAIN A PNG IMAGE DEVICE RENDERER
> PluginSettings ps = PluginSettings.instance();
> IDeviceRenderer idr = null;
> try {
> idr = ps.getDevice("dv.PNG");
> } catch (ChartException pex)
> {
> DefaultLoggerImpl.instance().log(pex);
> }
>
> // 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, null,bo, null);
> } catch (ChartException gex)
> {
>
> DefaultLoggerImpl.instance().log(gex);
> System.exit(0);
> }
> // RENDER THE CHART TO A PNG FILE
> BufferedImage img = new BufferedImage((int) bo.getWidth(), (int)
> bo.getHeight(), BufferedImage.TYPE_INT_ARGB);
> idr.setProperty(IDeviceRenderer.CACHED_IMAGE, img);
> idr.setProperty(IDeviceRenderer.FILE_IDENTIFIER, "chart.png");
> try {
> gr.render(idr, gcs);
> } catch (ChartException rex)
> {
> DefaultLoggerImpl.instance().log(rex);
> }
>
>
> ImageIcon icon = new ImageIcon(img);
> JLabel label = new JLabel(icon, JLabel.CENTER);
> JOptionPane.showMessageDialog(null, label, "icon", -1);
>
>
> The image that is written to disk looks fine though. Its has been up
> before and it seems to be a bug:
>
> http://www.eclipse.org/forums/index.php/m/94425/
>
> but I cannot find the bug on the birt bugzilla.
>
> Is this still a bug or has it been fixed in versions > 2.6.1?]]>Jason Weathersby2011-11-30T18:32:47-00:00Re: Cannot render chart to image - possibly a bug
https://www.eclipse.org/forums/index.php/mv/msg/262951/759969/#msg_759969
help us debug it.
Jason
On 11/30/2011 1:32 PM, Jason Weathersby wrote:
> Have you tried the swing viewer examples from the examples view?
> Take a look at the attached files.
>
> Jason
>
> On 11/29/2011 1:00 PM, Anton wrote:
>> I use birt 2.6.1. I use the example on this page:
>>
>> http://www.birt-exchange.org/org/wiki/index.php?title=BIRT:Charts2.2
>>
>> to render a chart to an image but the bottom of the image is missing.
>> Here is the code:
>>
>>
>>
>> // DEFINE A CHART STRUCTURE
>> Chart cm = SampleCharts.createMyChart();
>> // OBTAIN A PNG IMAGE DEVICE RENDERER
>> PluginSettings ps = PluginSettings.instance();
>> IDeviceRenderer idr = null;
>> try {
>> idr = ps.getDevice("dv.PNG");
>> } catch (ChartException pex)
>> {
>> DefaultLoggerImpl.instance().log(pex);
>> }
>>
>> // 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, null,bo, null);
>> } catch (ChartException gex)
>> {
>>
>> DefaultLoggerImpl.instance().log(gex);
>> System.exit(0);
>> }
>> // RENDER THE CHART TO A PNG FILE
>> BufferedImage img = new BufferedImage((int) bo.getWidth(), (int)
>> bo.getHeight(), BufferedImage.TYPE_INT_ARGB);
>> idr.setProperty(IDeviceRenderer.CACHED_IMAGE, img);
>> idr.setProperty(IDeviceRenderer.FILE_IDENTIFIER, "chart.png");
>> try {
>> gr.render(idr, gcs);
>> } catch (ChartException rex)
>> {
>> DefaultLoggerImpl.instance().log(rex);
>> }
>>
>>
>> ImageIcon icon = new ImageIcon(img);
>> JLabel label = new JLabel(icon, JLabel.CENTER);
>> JOptionPane.showMessageDialog(null, label, "icon", -1);
>>
>>
>> The image that is written to disk looks fine though. Its has been up
>> before and it seems to be a bug:
>>
>> http://www.eclipse.org/forums/index.php/m/94425/
>>
>> but I cannot find the bug on the birt bugzilla.
>>
>> Is this still a bug or has it been fixed in versions > 2.6.1?
>]]>Jason Weathersby2011-11-30T18:34:10-00:00Re: Cannot render chart to image - possibly a bug
https://www.eclipse.org/forums/index.php/mv/msg/262951/760061/#msg_760061
image:
BTW if you could build a small swing app that shows the issue it could
help us debug it.
Jason
On 11/30/2011 1:32 PM, Jason Weathersby wrote:
> Have you tried the swing viewer examples from the examples view?
> Take a look at the attached files.
>
> Jason
>
> On 11/29/2011 1:00 PM, Anton wrote:
>> I use birt 2.6.1. I use the example on this page:
>>
>> http://www.birt-exchange.org/org/wiki/index.php?title=BIRT:Charts2.2
>>
>> to render a chart to an image but the bottom of the image is missing.
>> Here is the code:
>>
>>
>>
>> // DEFINE A CHART STRUCTURE
>> Chart cm = SampleCharts.createMyChart();
>> // OBTAIN A PNG IMAGE DEVICE RENDERER
>> PluginSettings ps = PluginSettings.instance();
>> IDeviceRenderer idr = null;
>> try {
>> idr = ps.getDevice("dv.PNG");
>> } catch (ChartException pex)
>> {
>> DefaultLoggerImpl.instance().log(pex);
>> }
>>
>> // 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, null,bo, null);
>> } catch (ChartException gex)
>> {
>>
>> DefaultLoggerImpl.instance().log(gex);
>> System.exit(0);
>> }
>> // RENDER THE CHART TO A PNG FILE
>> BufferedImage img = new BufferedImage((int) bo.getWidth(), (int)
>> bo.getHeight(), BufferedImage.TYPE_INT_ARGB);
>> idr.setProperty(IDeviceRenderer.CACHED_IMAGE, img);
>> idr.setProperty(IDeviceRenderer.FILE_IDENTIFIER, "chart.png");
>> try {
>> gr.render(idr, gcs);
>> } catch (ChartException rex)
>> {
>> DefaultLoggerImpl.instance().log(rex);
>> }
>>
>>
>> ImageIcon icon = new ImageIcon(img);
>> JLabel label = new JLabel(icon, JLabel.CENTER);
>> JOptionPane.showMessageDialog(null, label, "icon", -1);
>>
>>
>> The image that is written to disk looks fine though. Its has been up
>> before and it seems to be a bug:
>>
>> http://www.eclipse.org/forums/index.php/m/94425/
>>
>> but I cannot find the bug on the birt bugzilla.
>>
>> Is this still a bug or has it been fixed in versions > 2.6.1?
>]]>Anton2011-12-01T06:47:17-00:00Re: Cannot render chart to image - possibly a bug
https://www.eclipse.org/forums/index.php/mv/msg/262951/760220/#msg_760220
/**
* Constructor
*/
public StandaloneChartOSGi( )
{
//The deployment runtime libs can be used to build the code
//if using osgi, must have valid plugins directory
PlatformConfig pf = new PlatformConfig();
//Returns a singleton instance of the Chart Engine
ChartEngine ce = ChartEngine.instance(pf);
//Returns a singleton instance of the Generator
IGenerator gr = ce.getGenerator();
On 12/1/2011 1:47 AM, Anton wrote:
> Rendering to swing works fine. The problem is when I render the chart to
> an image:
>
> ps = PluginSettings.instance();
> double width = chart.getBlock().getBounds().getWidth();
> double height = chart.getBlock().getBounds().getHeight();
> Bounds bo = BoundsImpl.create(0, 0, width, height);
> Generator gr = Generator.instance();
> BufferedImage img = null;
> try {
> idr = ps.getDevice("dv.PNG");
> img = new BufferedImage((int) bo.getWidth(), (int) bo.getHeight(),
> BufferedImage.TYPE_INT_ARGB);
> idr.setProperty(IDeviceRenderer.CACHED_IMAGE, img);
> idr.setProperty(IDeviceRenderer.EXPECTED_BOUNDS, bo);
> gcs = gr.build(idr.getDisplayServer(), chart, null, bo, null);
> gr.render(idr, gcs);
> } catch (ChartException pex) {
> DefaultLoggerImpl.instance().log(pex);
> }
> ImageIcon icon = new ImageIcon(image);
> JLabel label = new JLabel(icon, JLabel.CENTER);
> JOptionPane.showMessageDialog(null, label, "icon", -1);
>
>
>
> If I render to png file it works fine:
>
> ps = PluginSettings.instance();
> double width = chart.getBlock().getBounds().getWidth();
> double height = chart.getBlock().getBounds().getHeight();
> Bounds bo = BoundsImpl.create(0, 0, width, height);
> Generator gr = Generator.instance();
> BufferedImage img = null;
> try {
> idr = ps.getDevice("dv.PNG");
> idr.setProperty(IDeviceRenderer.FILE_IDENTIFIER, out.getAbsolutePath());
> gcs = gr.build(idr.getDisplayServer(), chart, null, bo, null);
> gr.render(idr, gcs);
> } catch (ChartException pex) {
> DefaultLoggerImpl.instance().log(pex);
> }
>
>
>
>
>
>
> "Jason Weathersby" wrote in message news:jb5sv1$6fg$2@news.eclipse.org...
>
> BTW if you could build a small swing app that shows the issue it could
> help us debug it.
>
> Jason
>
> On 11/30/2011 1:32 PM, Jason Weathersby wrote:
>> Have you tried the swing viewer examples from the examples view?
>> Take a look at the attached files.
>>
>> Jason
>>
>> On 11/29/2011 1:00 PM, Anton wrote:
>>> I use birt 2.6.1. I use the example on this page:
>>>
>>> http://www.birt-exchange.org/org/wiki/index.php?title=BIRT:Charts2.2
>>>
>>> to render a chart to an image but the bottom of the image is missing.
>>> Here is the code:
>>>
>>>
>>>
>>> // DEFINE A CHART STRUCTURE
>>> Chart cm = SampleCharts.createMyChart();
>>> // OBTAIN A PNG IMAGE DEVICE RENDERER
>>> PluginSettings ps = PluginSettings.instance();
>>> IDeviceRenderer idr = null;
>>> try {
>>> idr = ps.getDevice("dv.PNG");
>>> } catch (ChartException pex)
>>> {
>>> DefaultLoggerImpl.instance().log(pex);
>>> }
>>>
>>> // 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, null,bo, null);
>>> } catch (ChartException gex)
>>> {
>>>
>>> DefaultLoggerImpl.instance().log(gex);
>>> System.exit(0);
>>> }
>>> // RENDER THE CHART TO A PNG FILE
>>> BufferedImage img = new BufferedImage((int) bo.getWidth(), (int)
>>> bo.getHeight(), BufferedImage.TYPE_INT_ARGB);
>>> idr.setProperty(IDeviceRenderer.CACHED_IMAGE, img);
>>> idr.setProperty(IDeviceRenderer.FILE_IDENTIFIER, "chart.png");
>>> try {
>>> gr.render(idr, gcs);
>>> } catch (ChartException rex)
>>> {
>>> DefaultLoggerImpl.instance().log(rex);
>>> }
>>>
>>>
>>> ImageIcon icon = new ImageIcon(img);
>>> JLabel label = new JLabel(icon, JLabel.CENTER);
>>> JOptionPane.showMessageDialog(null, label, "icon", -1);
>>>
>>>
>>> The image that is written to disk looks fine though. Its has been up
>>> before and it seems to be a bug:
>>>
>>> http://www.eclipse.org/forums/index.php/m/94425/
>>>
>>> but I cannot find the bug on the birt bugzilla.
>>>
>>> Is this still a bug or has it been fixed in versions > 2.6.1?
>>
>]]>Jason Weathersby2011-12-01T16:01:08-00:00Re: Cannot render chart to image - possibly a bug
https://www.eclipse.org/forums/index.php/mv/msg/262951/760328/#msg_760328
quite sure how though :-)
/**
* Constructor
*/
public StandaloneChartOSGi( )
{
//The deployment runtime libs can be used to build the code
//if using osgi, must have valid plugins directory
PlatformConfig pf = new PlatformConfig();
//Returns a singleton instance of the Chart Engine
ChartEngine ce = ChartEngine.instance(pf);
//Returns a singleton instance of the Generator
IGenerator gr = ce.getGenerator();
On 12/1/2011 1:47 AM, Anton wrote:
> Rendering to swing works fine. The problem is when I render the chart to
> an image:
>
> ps = PluginSettings.instance();
> double width = chart.getBlock().getBounds().getWidth();
> double height = chart.getBlock().getBounds().getHeight();
> Bounds bo = BoundsImpl.create(0, 0, width, height);
> Generator gr = Generator.instance();
> BufferedImage img = null;
> try {
> idr = ps.getDevice("dv.PNG");
> img = new BufferedImage((int) bo.getWidth(), (int) bo.getHeight(),
> BufferedImage.TYPE_INT_ARGB);
> idr.setProperty(IDeviceRenderer.CACHED_IMAGE, img);
> idr.setProperty(IDeviceRenderer.EXPECTED_BOUNDS, bo);
> gcs = gr.build(idr.getDisplayServer(), chart, null, bo, null);
> gr.render(idr, gcs);
> } catch (ChartException pex) {
> DefaultLoggerImpl.instance().log(pex);
> }
> ImageIcon icon = new ImageIcon(image);
> JLabel label = new JLabel(icon, JLabel.CENTER);
> JOptionPane.showMessageDialog(null, label, "icon", -1);
>
>
>
> If I render to png file it works fine:
>
> ps = PluginSettings.instance();
> double width = chart.getBlock().getBounds().getWidth();
> double height = chart.getBlock().getBounds().getHeight();
> Bounds bo = BoundsImpl.create(0, 0, width, height);
> Generator gr = Generator.instance();
> BufferedImage img = null;
> try {
> idr = ps.getDevice("dv.PNG");
> idr.setProperty(IDeviceRenderer.FILE_IDENTIFIER, out.getAbsolutePath());
> gcs = gr.build(idr.getDisplayServer(), chart, null, bo, null);
> gr.render(idr, gcs);
> } catch (ChartException pex) {
> DefaultLoggerImpl.instance().log(pex);
> }
>
>
>
>
>
>
> "Jason Weathersby" wrote in message news:jb5sv1$6fg$2@news.eclipse.org...
>
> BTW if you could build a small swing app that shows the issue it could
> help us debug it.
>
> Jason
>
> On 11/30/2011 1:32 PM, Jason Weathersby wrote:
>> Have you tried the swing viewer examples from the examples view?
>> Take a look at the attached files.
>>
>> Jason
>>
>> On 11/29/2011 1:00 PM, Anton wrote:
>>> I use birt 2.6.1. I use the example on this page:
>>>
>>> http://www.birt-exchange.org/org/wiki/index.php?title=BIRT:Charts2.2
>>>
>>> to render a chart to an image but the bottom of the image is missing.
>>> Here is the code:
>>>
>>>
>>>
>>> // DEFINE A CHART STRUCTURE
>>> Chart cm = SampleCharts.createMyChart();
>>> // OBTAIN A PNG IMAGE DEVICE RENDERER
>>> PluginSettings ps = PluginSettings.instance();
>>> IDeviceRenderer idr = null;
>>> try {
>>> idr = ps.getDevice("dv.PNG");
>>> } catch (ChartException pex)
>>> {
>>> DefaultLoggerImpl.instance().log(pex);
>>> }
>>>
>>> // 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, null,bo, null);
>>> } catch (ChartException gex)
>>> {
>>>
>>> DefaultLoggerImpl.instance().log(gex);
>>> System.exit(0);
>>> }
>>> // RENDER THE CHART TO A PNG FILE
>>> BufferedImage img = new BufferedImage((int) bo.getWidth(), (int)
>>> bo.getHeight(), BufferedImage.TYPE_INT_ARGB);
>>> idr.setProperty(IDeviceRenderer.CACHED_IMAGE, img);
>>> idr.setProperty(IDeviceRenderer.FILE_IDENTIFIER, "chart.png");
>>> try {
>>> gr.render(idr, gcs);
>>> } catch (ChartException rex)
>>> {
>>> DefaultLoggerImpl.instance().log(rex);
>>> }
>>>
>>>
>>> ImageIcon icon = new ImageIcon(img);
>>> JLabel label = new JLabel(icon, JLabel.CENTER);
>>> JOptionPane.showMessageDialog(null, label, "icon", -1);
>>>
>>>
>>> The image that is written to disk looks fine though. Its has been up
>>> before and it seems to be a bug:
>>>
>>> http://www.eclipse.org/forums/index.php/m/94425/
>>>
>>> but I cannot find the bug on the birt bugzilla.
>>>
>>> Is this still a bug or has it been fixed in versions > 2.6.1?
>>
>]]>Anton2011-12-01T21:52:59-00:00