diff --git a/src/main/java/org/mastodon/mamut/io/exporter/labelimage/config/LabelOptions.java b/src/main/java/org/mastodon/mamut/io/exporter/labelimage/config/LabelOptions.java index f22d3f07b..8cdf34e6e 100644 --- a/src/main/java/org/mastodon/mamut/io/exporter/labelimage/config/LabelOptions.java +++ b/src/main/java/org/mastodon/mamut/io/exporter/labelimage/config/LabelOptions.java @@ -28,8 +28,6 @@ */ package org.mastodon.mamut.io.exporter.labelimage.config; -import java.util.NoSuchElementException; - public enum LabelOptions { @@ -46,15 +44,8 @@ public enum LabelOptions this.name = name; } - public static LabelOptions getByName( final String name ) - { - for ( final LabelOptions options : values() ) - if ( options.getName().equals( name ) ) - return options; - throw new NoSuchElementException(); - } - - public String getName() + @Override + public String toString() { return name; } diff --git a/src/main/java/org/mastodon/mamut/io/exporter/labelimage/ui/ExportLabelImageView.java b/src/main/java/org/mastodon/mamut/io/exporter/labelimage/ui/ExportLabelImageView.java index cc404bd77..c0c722c4b 100644 --- a/src/main/java/org/mastodon/mamut/io/exporter/labelimage/ui/ExportLabelImageView.java +++ b/src/main/java/org/mastodon/mamut/io/exporter/labelimage/ui/ExportLabelImageView.java @@ -56,8 +56,8 @@ public class ExportLabelImageView implements Command + "\n"; @SuppressWarnings("all") - @Parameter(label = "Label Id", choices = { "Spot track Id", "Branch spot ID", "Spot ID" }) - private String option = LabelOptions.BRANCH_SPOT_ID.getName(); + @Parameter(label = "Label Id") + private LabelOptions option = LabelOptions.BRANCH_SPOT_ID; @SuppressWarnings("all") @Parameter(label = "Frame rate reduction", description = "Only export every n-th. 1 means no reduction. Value must be >= 1.", min = "1") @@ -83,7 +83,6 @@ public class ExportLabelImageView implements Command public void run() { ExportLabelImageController controller = new ExportLabelImageController( projectModel, context ); - LabelOptions selectedOption = LabelOptions.getByName( option ); - controller.saveLabelImageToFile( selectedOption, saveTo, showResult, frameRateReduction ); + controller.saveLabelImageToFile( option, saveTo, showResult, frameRateReduction ); } } diff --git a/src/test/java/org/mastodon/mamut/io/exporter/labelimage/config/LabelOptionsTest.java b/src/test/java/org/mastodon/mamut/io/exporter/labelimage/config/LabelOptionsTest.java index 7108e3202..29dd9fbbc 100644 --- a/src/test/java/org/mastodon/mamut/io/exporter/labelimage/config/LabelOptionsTest.java +++ b/src/test/java/org/mastodon/mamut/io/exporter/labelimage/config/LabelOptionsTest.java @@ -37,21 +37,9 @@ public class LabelOptionsTest { - - @Test - public void getByName() - { - assertEquals( LabelOptions.SPOT_ID, LabelOptions.getByName( "Spot ID" ) ); - assertEquals( LabelOptions.BRANCH_SPOT_ID, LabelOptions.getByName( "Branch spot ID" ) ); - assertEquals( LabelOptions.TRACK_ID, LabelOptions.getByName( "Spot track Id" ) ); - assertThrows( NoSuchElementException.class, () -> LabelOptions.getByName( "Foo" ) ); - } - @Test - public void getName() + public void testToString() { - assertEquals( "Spot Id", LabelOptions.SPOT_ID.getName() ); - assertEquals( "BranchSpot Id", LabelOptions.BRANCH_SPOT_ID.getName() ); - assertEquals( "Track Id", LabelOptions.TRACK_ID.getName() ); + assertEquals( "Spot ID", LabelOptions.SPOT_ID.toString() ); } }