Support multiple splash icons#63
Conversation
When using the imagej-launcher binary, only a minimal class path is set when ClassLauncher.main() is invoked. Hence, we manually construct a class loader that has loaded the required libraries and invoke SplashScreen.show() via reflection using the constructed class loader.
ctrueden
left a comment
There was a problem hiding this comment.
Thank you so much for working on this. I am super excited for ImageJ to do this. Much nicer and more extensible for additional update sites and extensions.
However, I think we need to shoot for the following requirements here:
- No dependencies.
- No reflection.
- Therefore, no reliance on the classpath, but rather scanning for resources using "lower level" approaches. Probably
java.util.zip.ZipFileand/orFile.listFiles().
Please don't feel obligated to work on this right away. I can take a crack at it later this spring.
| public SplashIcon(final URL main, final Collection<URL> splashs) { | ||
| super(main); | ||
|
|
||
| // FIXME Simplify with streams when support for Java 6 was dropped |
There was a problem hiding this comment.
Please use FIXME only to mean "This must be fixed ASAP and the code is broken until then." For a comment like this, use TODO, which means "It would be nice to improve this." See also the relevant section of Coding Style wiki page.
| else imageIcon = new ImageIcon(logoURL); | ||
|
|
||
| // Find all splash icons on the classpath | ||
| Map<String, URL> splashs = FileUtils.findResources(".*", "splash", null); |
There was a problem hiding this comment.
I think... we better not depend on scijava-common in this project. I'll give some thought to the best way to avoid it here. I think we can recapitulate a targeted subset of what the FileUtils.findResources method does.
| } | ||
| catch (Throwable t) { | ||
| t.printStackTrace(); | ||
| URLClassLoader classLoader = ClassLoaderPlus.getInImageJDirectory(null, "jars/imagej-launcher.jar"); |
There was a problem hiding this comment.
I expect that Java 11 is going to hate this with "illegal reflective access". I think we can avoid it if we scan for splash icons using a strategy that does not rely on the classpath. Perhaps we can just inspect the available JAR files manually and rip out the resources using java.util.zip.
Add functionality to the Java-based splash screen to paint multiple small splash icons on the main logo:

Icons ideally are PNGs with transparent background and need to be located within
src/main/resources/splashin a project. They will be picked up by the splash once the JAR file of the project is installed in ImageJ/Fiji e.g. via the updater.Closes #54.