Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple splash icons #63

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

stelfrich
Copy link
Member

@stelfrich stelfrich commented Jan 17, 2019

Add functionality to the Java-based splash screen to paint multiple small splash icons on the main logo:
launcher-splash-icons

Icons ideally are PNGs with transparent background and need to be located within src/main/resources/splash in 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.

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.
Copy link
Member

@ctrueden ctrueden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. No dependencies.
  2. No reflection.
  3. Therefore, no reliance on the classpath, but rather scanning for resources using "lower level" approaches. Probably java.util.zip.ZipFile and/or File.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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants