I have an applet that visualizes a large graph using JUNG2. A while back I managed to add an export feature which allows the user to export the graphs to vector-based images, this time utilizing FreeHEP library. It all worked nice and smooth (I even used PDF exports in a publication).
Now the applet seems to crash when I try to export the graphs. Digging into the java console I found out that it's due a NPE deep down in the library. Below is the relevant portion of the stack trace:
Exception in thread "AWT-EventQueue-2" java.lang.ExceptionInInitializerError
at org.freehep.graphicsio.gif.GIFImageWriteParam.<init>(GIFImageWriteParam.java:28)
at org.freehep.graphicsio.gif.GIFImageWriter.getDefaultWriteParam(GIFImageWriter.java:73)
at org.freehep.graphicsio.exportchooser.ImageExportFileType.<init>(ImageExportFileType.java:71)
at org.freehep.graphicsio.exportchooser.ImageIOExportFileType.onRegistration(ImageIOExportFileType.java:50)
at javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:715)
at javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:302)
at org.freehep.util.export.ExportFileTypeRegistry.addApplicationClasspathExportFileTypes(ExportFileTypeRegistry.java:122)
at org.freehep.util.export.ExportFileTypeRegistry.getDefaultInstance(ExportFileTypeRegistry.java:50)
at org.freehep.util.export.ExportFileType.getExportFileTypes(ExportFileType.java:181)
at org.freehep.util.export.ExportFileType.getExportFileTypes(ExportFileType.java:173)
at org.freehep.util.export.ExportDialog.addAllExportFileTypes(ExportDialog.java:64)
at org.freehep.util.export.ExportDialog.<init>(ExportDialog.java:130)
at org.freehep.util.export.ExportDialog.<init>(ExportDialog.java:90)
at org.freehep.util.export.ExportDialog.<init>(ExportDialog.java:82)
at myproject.visualization.ExtendedModelGraphMouse$ExportActionListener.actionPerformed(ExtendedModelGraphMouse.java:167)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
...
Caused by: java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.freehep.graphics2d.PixelGraphics2D.<clinit>(PixelGraphics2D.java:101)
... 53 more
I have been digging into the source code of the FreeHEP library (hosted at Grep Code), the last line (topmost) in the stack trace points to the line that starts with UserProperties
public GIFImageWriteParam(Locale locale) {
super(locale);
canWriteProgressive = true;
progressiveMode = MODE_DEFAULT;
UserProperties def = new UserProperties(GIFGraphics2D
.getDefaultProperties());
quantizeColors = def.isProperty(GIFGraphics2D.QUANTIZE_COLORS);
quantizeMode = def.getProperty(GIFGraphics2D.QUANTIZE_MODE);
}
From what I can decipher this should mean that GIFGraphics2D
turns out to be null
- why, I don't understand. I have double checked my build file to make sure necessary libs are in place, and neither my build file nor my code that utilizes the ExportDialog
(see the very first link in the question body) has changed in over a year. So what could be the issue here?