-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from melissalinkert/api-updates
Add getter and setter for each command line option
- Loading branch information
Showing
6 changed files
with
377 additions
and
92 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/com/glencoesoftware/pyramid/CompressionQualityConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) 2023 Glencoe Software, Inc. All rights reserved. | ||
* | ||
* This software is distributed under the terms described by the LICENSE.txt | ||
* file you can find at the root of the distribution bundle. If the file is | ||
* missing please request a copy by contacting [email protected] | ||
*/ | ||
|
||
package com.glencoesoftware.pyramid; | ||
|
||
import loci.formats.codec.CodecOptions; | ||
import loci.formats.codec.JPEG2000CodecOptions; | ||
|
||
import picocli.CommandLine.ITypeConverter; | ||
|
||
/** | ||
* Convert a string to a CodecOptions. | ||
*/ | ||
public class CompressionQualityConverter | ||
implements ITypeConverter<CodecOptions> | ||
{ | ||
@Override | ||
public CodecOptions convert(String value) throws Exception { | ||
// JPEG2000CodecOptions used here as it's the only way to pass | ||
// a quality value through to the JPEG-2000 codecs | ||
// this could be changed later if/when we support options on other codecs | ||
CodecOptions options = JPEG2000CodecOptions.getDefaultOptions(); | ||
options.quality = Double.parseDouble(value); | ||
return options; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/com/glencoesoftware/pyramid/CompressionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Copyright (c) 2019-2020 Glencoe Software, Inc. All rights reserved. | ||
* | ||
* This software is distributed under the terms described by the LICENSE.txt | ||
* file you can find at the root of the distribution bundle. If the file is | ||
* missing please request a copy by contacting [email protected] | ||
*/ | ||
package com.glencoesoftware.pyramid; | ||
|
||
import java.util.EnumSet; | ||
import loci.formats.out.TiffWriter; | ||
import loci.formats.tiff.TiffCompression; | ||
|
||
/** | ||
* List of valid compression types for the output OME-TIFF file. | ||
*/ | ||
public enum CompressionType { | ||
UNCOMPRESSED( | ||
TiffWriter.COMPRESSION_UNCOMPRESSED, TiffCompression.UNCOMPRESSED), | ||
LZW(TiffWriter.COMPRESSION_LZW, TiffCompression.LZW), | ||
JPEG(TiffWriter.COMPRESSION_JPEG, TiffCompression.JPEG), | ||
JPEG_2000(TiffWriter.COMPRESSION_J2K, TiffCompression.JPEG_2000), | ||
JPEG_2000_LOSSY( | ||
TiffWriter.COMPRESSION_J2K_LOSSY, TiffCompression.JPEG_2000_LOSSY); | ||
|
||
private String compressionName; | ||
private TiffCompression compressionType; | ||
|
||
/** | ||
* Construct a list of valid compression types. | ||
* | ||
* @param name compression name (used in command line arguments) | ||
* @param type corresponding TIFF compression | ||
*/ | ||
private CompressionType(String name, TiffCompression type) { | ||
compressionName = name; | ||
compressionType = type; | ||
} | ||
|
||
/** | ||
* Find the compression corresponding to the given name. | ||
* If there is no matching name, return the uncompressed type. | ||
* | ||
* @param compressionName desired compression name | ||
* @return corresponding CompressionType, or UNCOMPRESSED if no match | ||
*/ | ||
public static CompressionType lookup(String compressionName) { | ||
for (CompressionType t : EnumSet.allOf(CompressionType.class)) { | ||
if (t.getName().equals(compressionName)) { | ||
return t; | ||
} | ||
} | ||
return UNCOMPRESSED; | ||
} | ||
|
||
/** | ||
* @return name of this compression type | ||
*/ | ||
public String getName() { | ||
return compressionName; | ||
} | ||
|
||
/** | ||
* @return TiffCompression for this compression type | ||
*/ | ||
public TiffCompression getTIFFCompression() { | ||
return compressionType; | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/glencoesoftware/pyramid/CompressionTypeConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright (c) 2023 Glencoe Software, Inc. All rights reserved. | ||
* | ||
* This software is distributed under the terms described by the LICENSE.txt | ||
* file you can find at the root of the distribution bundle. If the file is | ||
* missing please request a copy by contacting [email protected] | ||
*/ | ||
|
||
package com.glencoesoftware.pyramid; | ||
|
||
import picocli.CommandLine.ITypeConverter; | ||
|
||
/** | ||
* Convert a string to a CompressionType. | ||
*/ | ||
public class CompressionTypeConverter | ||
implements ITypeConverter<CompressionType> | ||
{ | ||
@Override | ||
public CompressionType convert(String value) throws Exception { | ||
return CompressionType.lookup(value); | ||
} | ||
} |
62 changes: 0 additions & 62 deletions
62
src/main/java/com/glencoesoftware/pyramid/CompressionTypes.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.