|
RE: painting Scene to BufferedImage: msg#00025java.netbeans.modules.graph.user
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
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
>
> Pete
>
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Would like to be on your mailing list, Martin Ryzl |
|---|---|
| Next by Date: | Overlapping connections, BSE Developer |
| Previous by Thread: | Re: painting Scene to BufferedImage, David Kaspar |
| Next by Thread: | Re: painting Scene to BufferedImage, David Kaspar |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |