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