Skip to content

Commit c9a8eaa

Browse files
ctruedenmaarzt
authored andcommitted
Purge the imagej-legacy dependency
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.
1 parent b1f4558 commit c9a8eaa

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@
170170
<groupId>net.imglib2</groupId>
171171
<artifactId>imglib2-algorithm</artifactId>
172172
</dependency>
173-
<dependency>
174-
<groupId>net.imagej</groupId>
175-
<artifactId>imagej-legacy</artifactId>
176-
</dependency>
177173
<dependency>
178174
<groupId>net.imglib2</groupId>
179175
<artifactId>imglib2</artifactId>

src/main/java/sc/fiji/labkit/ui/LabkitFrame.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
import io.scif.services.DatasetIOService;
3333
import net.imagej.Dataset;
34-
import net.imagej.legacy.ui.LegacyApplicationFrame;
3534
import org.scijava.ui.ApplicationFrame;
3635
import org.scijava.ui.UIService;
3736
import org.scijava.widget.UIComponent;
@@ -113,11 +112,14 @@ private Image getImageJIcon(Context context) {
113112
// NB: get ImageJ icon form the main UI window
114113
UIService uiService = context.service(UIService.class);
115114
ApplicationFrame applicationFrame = uiService.getDefaultUI().getApplicationFrame();
116-
if (applicationFrame instanceof LegacyApplicationFrame)
117-
return ((LegacyApplicationFrame) applicationFrame).getComponent().getIconImage();
115+
Frame frame = null;
118116
if (applicationFrame instanceof Frame)
119-
return ((Frame) applicationFrame).getIconImage();
120-
return null;
117+
frame = (Frame) applicationFrame;
118+
else if (applicationFrame instanceof UIComponent) {
119+
Object uic = ((UIComponent) applicationFrame).getComponent();
120+
if (uic instanceof Frame) frame = (Frame) uic;
121+
}
122+
return frame == null ? null : frame.getIconImage();
121123
}
122124
catch (Exception e) {
123125
return null;

0 commit comments

Comments
 (0)