graphstream / gs-ui-swing

GraphStream Swing user interface
http://graphstream-project.org/
Other
25 stars 12 forks source link

cannot create image with swing backend: initImage is never called in the constructor #18

Open MohamedLEGH opened 7 months ago

MohamedLEGH commented 7 months ago

I have the following bug when I try to create an image :

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.awt.Graphics2D.getTransform()" because "this.g2" is null
        at org.graphstream.ui.swing.BackendJ2D.prepareNewFrame(BackendJ2D.java:107)
        at org.graphstream.ui.swing.SwingGraphRenderer.render(SwingGraphRenderer.java:223)
        at org.graphstream.ui.swing.util.SwingFileSinkImages.render(SwingFileSinkImages.java:70)
        at org.graphstream.stream.file.FileSinkImages.outputNewImage(FileSinkImages.java:548)
        at org.graphstream.stream.file.FileSinkImages.outputNewImage(FileSinkImages.java:515)

I think the problem is that the function initImage (that create g2d) is never called in the constructor:

https://github.com/graphstream/gs-ui-swing/blob/67888fae1f2bbc71b4d9ab50bdfd20e7ea391a67/src/org/graphstream/ui/swing/util/SwingFileSinkImages.java#L78C1-L82C3