Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
getAvailableModes should not map to String, make utils final/prevent …
…instantiation
  • Loading branch information
Brandon committed Feb 18, 2026
commit 83c1aeec2efa5303619bf7e7b9b2edc1b7963997
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
// Note: Each text string must be unique to support reliable lookup in fromString().

/**
* Acquisition modes for all microscope geometry types.
* Acquisition modes for all microscope geometries.
* <p>
* Use the {@code modesByType} method to get valid modes based on {@link GeometryType}.
*/
public enum AcquisitionMode {
NO_SCAN("No scan (fixed sheet)"),
Expand Down Expand Up @@ -85,13 +87,13 @@ public boolean isStageScanMode() {
* This list is filtered based on hardware capabilities: if {@code hasStageScanning}
* is {@code false}, all stage-scan related modes are excluded.
*
* @param geometry the {@link GeometryType} to query; if {@code null}, an empty list is returned
* @param geometryType the {@link GeometryType} to query; if {@code null}, an empty list is returned
* @param hasStageScanning {@code true} if stage scan hardware is available
* @return a {@code List} of {@link AcquisitionMode} constants
* @return an array of {@link AcquisitionMode} constants
*/
public static AcquisitionMode[] getValidModes(final GeometryType geometry, final boolean hasStageScanning) {
return Optional.ofNullable(geometry)
.map(MODES_BY_GEOMETRY::get) // returns null if geometry is not in map
public static AcquisitionMode[] modesByType(final GeometryType geometryType, final boolean hasStageScanning) {
return Optional.ofNullable(geometryType)
.map(MODES_BY_GEOMETRY::get) // returns null if geometryType is not in map
.orElse(Collections.emptyList())
.stream()
.filter(mode -> hasStageScanning || !mode.isStageScanMode())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ public static CameraMode[] getAvailableModes(CameraLibrary camLib) {
modes.add(CameraMode.VIRTUAL_SLIT);
}
}
return modes.stream()
.map(CameraMode::toString)
.toArray(CameraMode[]::new);
return modes.toArray(CameraMode[]::new);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ private void createUserInterface() {
// acquisition mode combo box
final boolean isUsingScanSettings = model_.devices().isUsingStageScanning();
final GeometryType geometryType = model_.devices().adapter().geometry();
cmbAcquisitionModes_ = new ComboBox<>(AcquisitionMode.getValidModes(geometryType, isUsingScanSettings),
cmbAcquisitionModes_ = new ComboBox<>(
AcquisitionMode.modesByType(geometryType, isUsingScanSettings),
acqSettings.acquisitionMode(),
180, 24);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
* A utility class for making dialog boxes.
*
*/
public class DialogUtils {
public final class DialogUtils {

/** This class should not be instantiated. */
private DialogUtils() {
throw new AssertionError("Utility class; do not instantiate.");
}

/**Standard error reporting or delegate to JTextArea component. */
public static boolean SEND_ERROR_TO_COMPONENT = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

public final class WindowUtils {

/** This class should not be instantiated. */
private WindowUtils() {
throw new AssertionError("Utility class; do not instantiate.");
}

/**
* Returns true if the window is displayable and not null.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,8 @@ private boolean doHardwareCalculations(PLogicSCAPE plc) {

// TODO: maybe wrap this up into a method for clarity
double cameraReadoutTime;
//final CameraBase camera = model_.devices().device(cameraName);
//final double cameraReadoutTime = camera.getReadoutTime(acqSettings_.cameraMode());
final CameraLibrary cameraLibrary = CameraLibrary.fromString(
model_.devices().device(cameraName).getDeviceLibrary());
switch (cameraLibrary) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package org.micromanager.lightsheetmanager.model.utils;

import org.micromanager.internal.MMStudio;

import java.io.File;
import java.io.IOException;

// TODO: show errors!
// TODO: better name


/**
* Read and write to text files using Apache Commons.
* Utilities to read and write to files.
*/
public class FileUtils {
public final class FileUtils {

/** This class should not be instantiated. */
private FileUtils() {
throw new AssertionError("Utility class; do not instantiate.");
}

/**
* Reads a text file with UTF-8 encoding into a String.
Expand All @@ -23,7 +26,7 @@ public static String readFileToString(final String filePath) {
try {
result = org.apache.commons.io.FileUtils.readFileToString(new File(filePath), "UTF-8");
} catch (IOException e) {
//ReportingUtils.showError("IOException: " + e.getMessage());
MMStudio.getInstance().logs().logError("FileUtils: readFileToString error");
}
return result;
}
Expand All @@ -38,7 +41,7 @@ public static void writeStringToFile(final String filePath, final String content
try {
org.apache.commons.io.FileUtils.writeStringToFile(new File(filePath), contents, "UTF-8");
} catch (IOException e) {
//ReportingUtils.showError("IOException: " + e.getMessage());
MMStudio.getInstance().logs().logError("FileUtils: writeStringToFile error");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package org.micromanager.lightsheetmanager.model.utils;

// TODO: make this generic for diSPIM/SCOPE or have separate static classes
public class GeometryUtils {
public final class GeometryUtils {

/** This class should not be instantiated. */
private GeometryUtils() {
throw new AssertionError("Utility class; do not instantiate.");
}

/***
* Compute how far we need to shift each image for deskew relative to Z-step size (orthogonal to image) based on user-specified angle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

import java.util.Objects;

public class JsonUtils {
public final class JsonUtils {

/** This class should not be instantiated. */
private JsonUtils() {
throw new AssertionError("Utility class; do not instantiate.");
}

public static void putJson(JSONObject json, final String property, final Object value) {
Objects.requireNonNull(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
/**
* Math utilities.
*/
public class MathUtils {
public final class MathUtils {

/** This class should not be instantiated. */
private MathUtils() {
// prevent instantiation
throw new AssertionError("Utility class; do not instantiate.");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
/**
* Utilities for dealing with double precision floating point numbers.
*/
public class NumberUtils {
public final class NumberUtils {

/** This class should not be instantiated. */
private NumberUtils() {
throw new AssertionError("Utility class; do not instantiate.");
}

/**
* Return true if the two doubles are equal according to Apache commons-math3 library.
Expand Down