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

Add reset methods for each option #219

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
245 changes: 244 additions & 1 deletion src/main/java/com/glencoesoftware/bioformats2raw/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -799,13 +799,256 @@ public void setDimensionOrder(DimensionOrder order) {
dimensionOrder = order;
}

// Option resetters - reset to defaults

/**
* Reset all options to their default values.
*/
public void resetOptions() {
resetInputPath();
resetOutputPath();
resetOutputOptions();
resetResolutions();
resetSeriesList();
resetTileWidth();
resetTileHeight();
resetChunkDepth();
resetLogLevel();
resetProgressBars();
resetPrintVersionOnly();
resetMaxWorkers();
resetMaxCachedTiles();
resetCompression();
resetCompressionProperties();
resetExtraReaders();
resetCalculateOMEROMetadata();
resetNested();
resetPyramidName();
resetScaleFormat();
resetAdditionalScaleFormatCSV();
resetMemoDirectory();
resetKeepMemoFiles();
resetDownsampling();
resetOverwrite();
resetFillValue();
resetReaderOptions();
resetNoHCS();
resetNoOMEMeta();
resetNoRootGroup();
resetReuseExistingResolutions();
resetMinImageSize();
resetDimensionOrder();
}

/**
*/
public void resetInputPath() {
inputPath = null;
}

/**
*/
public void resetOutputPath() {
outputLocation = null;
}

/**
*/
public void resetOutputOptions() {
outputOptions = null;
}

/**
*/
public void resetResolutions() {
pyramidResolutions = null;
}

/**
*/
public void resetSeriesList() {
seriesList = new ArrayList<Integer>();
}

/**
*/
public void resetTileWidth() {
tileWidth = 1024;
}

/**
*/
public void resetTileHeight() {
tileHeight = 1024;
}

/**
*/
public void resetChunkDepth() {
chunkDepth = 1;
}

/**
*/
public void resetLogLevel() {
logLevel = "WARN";
}

/**
*/
public void resetProgressBars() {
progressBars = false;
}

/**
*/
public void resetPrintVersionOnly() {
printVersion = false;
}

/**
*/
public void resetMaxWorkers() {
maxWorkers = (int) Math.min(4, Runtime.getRuntime().availableProcessors());
}

/**
*/
public void resetMaxCachedTiles() {
maxCachedTiles = 64;
}

/**
*/
public void resetCompression() {
compressionType = ZarrCompression.blosc;
}

/**
*/
public void resetCompressionProperties() {
compressionProperties = new HashMap<String, Object>();
}

/**
*/
public void resetExtraReaders() {
extraReaders = new Class[] {
PyramidTiffReader.class, MiraxReader.class,
BioTekReader.class, ND2PlateReader.class
};
}

/**
*/
public void resetCalculateOMEROMetadata() {
omeroMetadata = true;
}

/**
*/
public void resetNested() {
nested = true;
}

/**
*/
public void resetPyramidName() {
pyramidName = null;
}

/**
*/
public void resetScaleFormat() {
scaleFormatString = "%d/%d";
}

/**
*/
public void resetAdditionalScaleFormatCSV() {
additionalScaleFormatStringArgsCsv = null;
additionalScaleFormatStringArgs = null;
}

/**
*/
public void resetMemoDirectory() {
memoDirectory = null;
}

/**
*/
public void resetKeepMemoFiles() {
keepMemoFiles = false;
}

/**
*/
public void resetDownsampling() {
downsampling = Downsampling.SIMPLE;
}

/**
*/
public void resetOverwrite() {
overwrite = false;
}

/**
*/
public void resetFillValue() {
fillValue = null;
}

/**
*/
public void resetReaderOptions() {
readerOptions = new ArrayList<String>();
}

/**
*/
public void resetNoHCS() {
noHCS = false;
}

/**
*/
public void resetNoOMEMeta() {
noOMEMeta = false;
}

/**
*/
public void resetNoRootGroup() {
noRootGroup = false;
}

/**
*/
public void resetReuseExistingResolutions() {
reuseExistingResolutions = false;
}

/**
*/
public void resetMinImageSize() {
minSize = MIN_SIZE;
}

/**
*/
public void resetDimensionOrder() {
dimensionOrder = DimensionOrder.XYZCT;
}

// Option getters

/**
* @return path to input data
*/
public String getInputPath() {
return inputPath.toString();
return inputPath == null ? null : inputPath.toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,40 @@ public void testOptionsAPI() throws Exception {
}
}

/**
* Check that setting and resetting options via API will reset options to
* their default values.
*/
@Test
public void testResetOptions() throws Exception {
input = fake("series", "2", "sizeX", "4096", "sizeY", "4096");

Converter apiConverter = new Converter();
apiConverter.setInputPath(input.toString());
apiConverter.setOutputPath(output.toString());
apiConverter.setSeriesList(Collections.singletonList(1));
apiConverter.setTileWidth(128);
apiConverter.setTileHeight(128);

assertEquals(apiConverter.getInputPath(), input.toString());
assertEquals(apiConverter.getOutputPath(), output.toString());
assertEquals(apiConverter.getSeriesList(), Collections.singletonList(1));
assertEquals(apiConverter.getTileWidth(), 128);
assertEquals(apiConverter.getTileHeight(), 128);

apiConverter.resetInputPath();
assertEquals(apiConverter.getInputPath(), null);

apiConverter.setInputPath(input.toString());

apiConverter.resetOptions();
assertEquals(apiConverter.getInputPath(), null);
assertEquals(apiConverter.getOutputPath(), null);
assertEquals(apiConverter.getSeriesList().size(), 0);
assertEquals(apiConverter.getTileWidth(), 1024);
assertEquals(apiConverter.getTileHeight(), 1024);
}

/**
* @param root dataset root path
* @param rowCount total rows the plate could contain
Expand Down
Loading