logo       

Re: painting Scene to BufferedImage: msg#00028

java.netbeans.modules.graph.user

Subject: Re: painting Scene to BufferedImage


Hi Peter,

I have created an issue #104474 for it:
http://graph.netbeans.org/issues/show_bug.cgi?id=104474

Unfortunately very likely I would not be able to integrate the change in
near few weeks. Therefore temporarily, please, add the "forceValidate"
method into the Scene class in your source code of the library and
compile it. When the feature is committed, the whole description would
be attach to the issue above.

BTW: Anyway I thing that it is not good idea to used Widgets for
rendering Images for Nodes in Explorer. The reason is that those images
have 16x16px size and therefore users will not get much information from
the rendered icon anyway. Instead usually an object has a representation
image which is used by nodes in explorer.

Regards,
David


Peter Harman wrote:
> 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>
Google Custom Search

News | FAQ | advertise