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:Peter Harman (pe@experiment626.plus.com)
Date:May 21, 2007 1:51:43 pm
List:org.netbeans.graph.users

hi David,

The reason behind the need to do this is that I want to use Widgets as icons for Nodes in other windows on the platform, and the Node interface uses java.awt.Image for it's icons. The widgets are programmatically generated from my object model so I don't want it the other way around (using ImageWidget's to show the Node icons).

If it were possible to add this to Scene that would be great for my application but hopefully would be useful to other users as it would help integrating the visual library with the Nodes / Explorer modules in this way.

thanks

Pete

_____

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

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