Skip to content

Commit 82933c0

Browse files
committed
API cleanup: Detection of stream mode should not rely on any GUI
1 parent 2c3aa25 commit 82933c0

15 files changed

Lines changed: 95 additions & 80 deletions

‎src/main/java/sc/fiji/snt/BookmarkManager.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ private void goToRow(final int tableRow) {
339339

340340
private void noImageOpenError() {
341341
assert sntui != null;
342-
sntui.guiUtils.error((sntui.isStreamMode())
342+
sntui.guiUtils.error(sntui.plugin.isStreamMode()
343343
? "No image is currently open. This table can be better accessed from BDV/BVV's <i>Markers</i> pane."
344344
: "No image is currently open.");
345345
}

‎src/main/java/sc/fiji/snt/CurationManager.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ private JPopupMenu getToolsMenu() {
10641064
final JPopupMenu popup = new JPopupMenu();
10651065
GuiUtils.addSeparator(popup, "Navigation:");
10661066
final JMenu zMenu = visitingZoom.zoomControls("Visiting Zoom Level", "issues");
1067-
zMenu.setEnabled(sntui != null && !sntui.isStreamMode());
1067+
zMenu.setEnabled(sntui != null && !sntui.plugin.isStreamMode());
10681068
popup.add(zMenu);
10691069
GuiUtils.addSeparator(popup, "Path Tagging:");
10701070
final JMenuItem colorMenuItem = new JMenuItem("Color Affected Paths by Issue Severity");

‎src/main/java/sc/fiji/snt/FillManagerUI.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public FillManagerUI(final SNT plugin, final SNTUI ui) {
116116
getRootPane().putClientProperty("JRootPane.menuBarEmbedded", false);
117117

118118
this.plugin = plugin;
119-
final boolean streamMode = ui != null && ui.isStreamMode();
119+
final boolean streamMode = plugin.isStreamMode();
120120
pathAndFillManager = plugin.getPathAndFillManager();
121121
pathAndFillManager.addPathAndFillListener(this);
122122
listModel = new DefaultListModel<>();
@@ -850,7 +850,7 @@ private void assembleExportFillsMenu() {
850850
try {
851851
action.execute();
852852
} catch (final UnsupportedOperationException ex) {
853-
final String msg = (plugin.getUI() != null && plugin.getUI().isStreamMode())
853+
final String msg = (plugin.isStreamMode())
854854
? "An error occurred: This operation likely requires the entire image to be loaded into memory (RAM)."
855855
: "An error occurred.";
856856
gUtils.error(msg + " See Console for details.");

‎src/main/java/sc/fiji/snt/PathManagerUI.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5894,7 +5894,7 @@ private JButton zoomToNodeButton() {
58945894
});
58955895
menu.addSeparator();
58965896
final JMenu zMenu = visitingZoom.zoomControls("Zoom to Node", "nodes");
5897-
zMenu.setEnabled(plugin.getUI() != null && !plugin.getUI().isStreamMode());
5897+
zMenu.setEnabled(!plugin.isStreamMode());
58985898
zMenu.setText("Visiting Zoom Level");
58995899
zMenu.setToolTipText("The magnification to be used when zooming into a node");
59005900
menu.add(zMenu);

‎src/main/java/sc/fiji/snt/SNT.java‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ public String toString() {
350350

351351
/* GUI */
352352
protected SNTUI ui;
353+
// Whether this session is running in stream mode ("SNT Stream"), i.e., without access to a full
354+
// in-core materialized image (see BigDataLoaderCmd)
355+
private boolean bigDataMode;
353356
protected volatile boolean tracingHalted = false; // Tracing functions paused?
354357
protected volatile boolean rubberBandTracing = false; // Rubber band (live preview) tracing mode
355358

@@ -981,6 +984,7 @@ public void startUI(final boolean bigDataMode) {
981984
}
982985

983986
private void startUIOnEDT(final boolean bigDataMode) {
987+
setBigDataMode(bigDataMode);
984988
GuiUtils.setLookAndFeel();
985989
final SNT thisPlugin = this;
986990
ui = new SNTUI(thisPlugin, bigDataMode);
@@ -3559,7 +3563,7 @@ public void enableSecondaryLayerTracing(final boolean enable) {
35593563
// NB: enableSecondaryLayerTracing() is reached from several off-EDT callers but showSecondaryData()
35603564
// does BVV/BDV Swing/OpenGL setup that. Calling it directly from a worker thread is a silent EDT/GL
35613565
// threading violation (no exception, just a hang), hence the explicit invokeLater() below
3562-
if (getUI() != null && getUI().isStreamMode()) {
3566+
if (isStreamMode() && getUI() != null) {
35633567
final var viewer = getUI().getActiveBigViewer();
35643568
if (viewer != null) {
35653569
SwingUtilities.invokeLater(() -> {
@@ -3598,7 +3602,7 @@ public void flushSecondaryData() {
35983602
// Bdv/Bvv viewer (see enableSecondaryLayerTracing()'s showSecondaryData() hook); flushing it
35993603
// here should remove that source toot. Same invokeLater() rationale as that hook:
36003604
// hideSecondaryData() touches Swing/OpenGL state and may be reached from off-EDT callers.
3601-
if (getUI().isStreamMode()) {
3605+
if (isStreamMode()) {
36023606
final var viewer = getUI().getActiveBigViewer();
36033607
if (viewer != null) {
36043608
SwingUtilities.invokeLater(() -> {
@@ -4441,7 +4445,7 @@ public void closeAndResetAllPanes() {
44414445
// Dispose xz/zy images unless the user stored some annotations (ROIs)
44424446
// on the image overlay or modified them somehow.
44434447
removeMIPOverlayAllPanes();
4444-
final boolean bvvMode = getUI() != null && getUI().isStreamMode();
4448+
final boolean bvvMode = isStreamMode();
44454449
if (!single_pane) {
44464450
final ImagePlus[] impPanes = { xz, zy };
44474451
for (final ImagePlus imp : impPanes) {
@@ -4516,6 +4520,29 @@ public SNTUI getUI() {
45164520
return ui;
45174521
}
45184522

4523+
/**
4524+
* Returns whether this session is running in stream mode ("SNT Stream"), i.e., without access to
4525+
* a full in-core materialized image but rather a lazily-loaded BDV/BVV-backed source (typically
4526+
* an OME-Zarr/N5 dataset; see {@link sc.fiji.snt.gui.cmds.BigDataLoaderCmd}).
4527+
*
4528+
* @return true if in stream mode
4529+
*/
4530+
public boolean isStreamMode() {
4531+
return bigDataMode;
4532+
}
4533+
4534+
/**
4535+
* Sets the stream-mode flag returned by {@link #isStreamMode()}. Package-private: the only
4536+
* legitimate callers are {@link #startUIOnEDT(boolean)} (before constructing {@link SNTUI}) and
4537+
* {@link SNTUI}'s own constructor (covering direct {@code new SNTUI(plugin, bigDataMode)}
4538+
* construction that bypasses {@link #startUI(boolean)}).
4539+
*
4540+
* @param bigDataMode the new stream-mode flag
4541+
*/
4542+
void setBigDataMode(final boolean bigDataMode) {
4543+
this.bigDataMode = bigDataMode;
4544+
}
4545+
45194546
/* (non-Javadoc)
45204547
* @see MultiDThreePanes#showStatus(int, int, java.lang.String)
45214548
*/

‎src/main/java/sc/fiji/snt/SNTService.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public boolean isActive() {
141141
*/
142142
public boolean isStreamMode() {
143143
final SNT instance = SNTUtils.getInstance();
144-
return instance != null && instance.getUI() != null && instance.getUI().isStreamMode();
144+
return instance != null && instance.isStreamMode();
145145
}
146146

147147
/**

0 commit comments

Comments
 (0)