Skip to content

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

@MohamedLEGH

Description

@MohamedLEGH

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions