Skip to content

Commit

Permalink
Purge the imagej-legacy dependency
Browse files Browse the repository at this point in the history
We can check whether the application frame is a UIComponent,
then check whether its associated component is a Frame,
without having a hard dependency on the LegacyApplicationFrame.
This reduces labkit-ui's dependency footprint, and avoids downstream
issues with the too-late patching of net.imagej:ij that can occur in
some scenarios when imagej-legacy is on the classpath.
  • Loading branch information
ctrueden committed Mar 28, 2024
1 parent 9036b27 commit b53b1be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 0 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@
<groupId>net.imglib2</groupId>
<artifactId>imglib2-algorithm</artifactId>
</dependency>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej-legacy</artifactId>
</dependency>
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2</artifactId>
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/sc/fiji/labkit/ui/LabkitFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import io.scif.services.DatasetIOService;
import net.imagej.Dataset;
import net.imagej.legacy.ui.LegacyApplicationFrame;
import org.scijava.ui.ApplicationFrame;
import org.scijava.ui.UIService;
import org.scijava.widget.UIComponent;
Expand Down Expand Up @@ -113,11 +112,14 @@ private Image getImageJIcon(Context context) {
// NB: get ImageJ icon form the main UI window
UIService uiService = context.service(UIService.class);
ApplicationFrame applicationFrame = uiService.getDefaultUI().getApplicationFrame();
if (applicationFrame instanceof LegacyApplicationFrame)
return ((LegacyApplicationFrame) applicationFrame).getComponent().getIconImage();
Frame frame = null;
if (applicationFrame instanceof Frame)
return ((Frame) applicationFrame).getIconImage();
return null;
frame = (Frame) applicationFrame;
else if (applicationFrame instanceof UIComponent) {
Object uic = ((UIComponent) applicationFrame).getComponent();
if (uic instanceof Frame) frame = (Frame) uic;
}
return frame == null ? null : frame.getIconImage();
}
catch (Exception e) {
return null;
Expand Down

0 comments on commit b53b1be

Please sign in to comment.