4 messages in org.netbeans.graph.usersRe: painting Scene to BufferedImage
FromSent OnAttachments
Peter HarmanMay 17, 2007 12:38 pm 
David KasparMay 20, 2007 9:36 pm 
Peter HarmanMay 21, 2007 1:51 pm 
David KasparMay 22, 2007 12:32 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: painting Scene to BufferedImageActions...
From:David Kaspar (Davi@Sun.COM)
Date:May 20, 2007 9:36:12 pm
List:org.netbeans.graph.users

Hi Peter,

The whole issue is that the scene view has to be created and shown to get correct font-metrics ... It means the "addNotify" method of the JComponent scene view has to be called be Swing. Only then the scene knows correct font-metrics...

Therefore it is not possible to solve your use-case now.

Let me know, it is really necessary to work "off-screen". If so, then we can add a new method: // the method name is weird so we can propose better one public final void Scene.forceValidate (Graphics2D graphics) { Graphics2D prevoiusGraphics = getGraphics (); setGraphics (graphics); validate (); setGraphics (prevoiusGraphics); }

In your use-case you would just call: // create an empty image myScene.forceValidate (myEmptyImageGraphics); // get the caculated scene width and height and create an image of particular size myScene.paint (myOutputImageGraphics);

Be aware that this may introduce a problem later when you show the view since the Graphics2D object may have different font-metrics ...

Regards, David

Peter Harman wrote:

hi,

I am trying to export a scene as a java.awt.Image by painting to a BufferedImage, without opening the scene view in a topcomponent. In a similar manner to the issue raised in "Help regarding Satellite view integration with Navigator panel." I receive an error due to the scene not having been validated. Is there a way of doing this? I have tried creating a view but not using it, but this results in a blank image or the same issue.

thanks