How to get a screenshot of a chart?

345 views
Skip to first unread message

ak

unread,
Feb 4, 2010, 6:55:03 AM2/4/10
to Jzy3d
Hi. I found out Jzy3d . It's amazing. I love it.

I'd like to get a screenshot of a generated chart. Anybody know how to
do it?

I have tried below code. Although I could get a window in which a
chart was drawn, newimage.jpg was just a black image.

As a debugger, the bufferedImage was null object at the line marked
(*).

ChartLauncher.openChart(ChartGenerator.getChart(), new
Rectangle(0,200,400,400), "Surface");
Chart chart = ChartGenerator.getChart();
BufferedImage bufferedImage = chart.getCanvas().screenshot();
try{
file = new File("newimage.jpg");
(*) ImageIO.write((RenderedImage)bufferedImage, "jpg", file); //<--
bufferedImage is null object as a debugger.
}catch(IOException e) {

}

Martin Pernollet

unread,
Feb 4, 2010, 12:10:29 PM2/4/10
to jz...@googlegroups.com
Thanks :)
If you checkout the trunk, you may look at the Launcher (http://code.google.com/p/jzy3d/source/browse/trunk/src/demos/net/masagroup/jzy3d/demos/Launcher.java)
I could efficiently generate an image by calling:

Chart chart = SurfaceDemo.getChart(Quality.Intermediate, "swing");
ImageIO.write(chart.screenshot(), "png", new File(fileName));

I added this feature very recently so maybe it is not completely stable?
I both tried to screenshot using an AWT and Swing canvas with success.

You may try updating the project because the trunk changes often.

Regards
Martin

ak

unread,
Feb 6, 2010, 4:18:36 AM2/6/10
to Jzy3d

Thank you, Martin.

I could get screen shot image.
As mentioned by your post, I used a image generating code written in
the Launcher.

I really enjoy the jzy3d with WIndows PC. Great library.
But I can't run it on mac os... I'll post the problem another post...

Thanks.

On Feb 5, 2:10 am, Martin Pernollet <martin.pernol...@gmail.com>
wrote:
> Thanks :)
> If you checkout the trunk, you may look at the Launcher (http://code.google.com/p/jzy3d/source/browse/trunk/src/demos/net/masa...


> )
> I could efficiently generate an image by calling:
>
> Chart chart = SurfaceDemo.getChart(Quality.Intermediate, "swing");
> ImageIO.write(chart.screenshot(), "png", new File(fileName));
>
> I added this feature very recently so maybe it is not completely stable?
> I both tried to screenshot using an AWT and Swing canvas with success.
>
> You may try updating the project because the trunk changes often.
>
> Regards
> Martin
>

> 2010/2/4 ak <akihito.s...@gmail.com>

Martin Pernollet

unread,
Feb 6, 2010, 5:56:11 AM2/6/10
to jz...@googlegroups.com
Thanks for you reply!
That would be great to have a description of your bug on the issue list (http://code.google.com/p/jzy3d/issues/list). Please add a screenshot to exhibit your problem.
That's the second time someone reports a problem with MacOS: Massimiliano reported a problem with the colorbar display.

ak

unread,
Feb 7, 2010, 1:53:47 AM2/7/10
to Jzy3d

Thanks, Martin.

I guess the screenshot issue wasn't a bug. It was just my fault to use
the jzy3d library.

Machintosh problem would be a bug. At first, I post a issue as a new
post of the Google group.

On Feb 6, 7:56 pm, Martin Pernollet <martin.pernol...@gmail.com>
wrote:


> Thanks for you reply!
> That would be great to have a description of your bug on the issue list (http://code.google.com/p/jzy3d/issues/list). Please add a screenshot to
> exhibit your problem.
> That's the second time someone reports a problem with MacOS: Massimiliano
> reported a problem with the colorbar display.
>

> 2010/2/6 ak <akihito.s...@gmail.com>

Reply all
Reply to author
Forward
0 new messages