Skip to content

Commit f45f11b

Browse files
author
Stefan Hahmann
committed
Use enum LabelOptions directly in ExportLabelImageView
* LabelOptions.getByName() method is no longer needed
1 parent 5a1730a commit f45f11b

3 files changed

Lines changed: 7 additions & 29 deletions

File tree

src/main/java/org/mastodon/mamut/io/exporter/labelimage/config/LabelOptions.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
*/
2929
package org.mastodon.mamut.io.exporter.labelimage.config;
3030

31-
import java.util.NoSuchElementException;
32-
3331

3432
public enum LabelOptions
3533
{
@@ -46,15 +44,8 @@ public enum LabelOptions
4644
this.name = name;
4745
}
4846

49-
public static LabelOptions getByName( final String name )
50-
{
51-
for ( final LabelOptions options : values() )
52-
if ( options.getName().equals( name ) )
53-
return options;
54-
throw new NoSuchElementException();
55-
}
56-
57-
public String getName()
47+
@Override
48+
public String toString()
5849
{
5950
return name;
6051
}

src/main/java/org/mastodon/mamut/io/exporter/labelimage/ui/ExportLabelImageView.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public class ExportLabelImageView implements Command
5656
+ "</html>\n";
5757

5858
@SuppressWarnings("all")
59-
@Parameter(label = "Label Id", choices = { "Spot track Id", "Branch spot ID", "Spot ID" })
60-
private String option = LabelOptions.BRANCH_SPOT_ID.getName();
59+
@Parameter(label = "Label Id")
60+
private LabelOptions option = LabelOptions.BRANCH_SPOT_ID;
6161

6262
@SuppressWarnings("all")
6363
@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
8383
public void run()
8484
{
8585
ExportLabelImageController controller = new ExportLabelImageController( projectModel, context );
86-
LabelOptions selectedOption = LabelOptions.getByName( option );
87-
controller.saveLabelImageToFile( selectedOption, saveTo, showResult, frameRateReduction );
86+
controller.saveLabelImageToFile( option, saveTo, showResult, frameRateReduction );
8887
}
8988
}

src/test/java/org/mastodon/mamut/io/exporter/labelimage/config/LabelOptionsTest.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,9 @@
3737

3838
public class LabelOptionsTest
3939
{
40-
41-
@Test
42-
public void getByName()
43-
{
44-
assertEquals( LabelOptions.SPOT_ID, LabelOptions.getByName( "Spot ID" ) );
45-
assertEquals( LabelOptions.BRANCH_SPOT_ID, LabelOptions.getByName( "Branch spot ID" ) );
46-
assertEquals( LabelOptions.TRACK_ID, LabelOptions.getByName( "Spot track Id" ) );
47-
assertThrows( NoSuchElementException.class, () -> LabelOptions.getByName( "Foo" ) );
48-
}
49-
5040
@Test
51-
public void getName()
41+
public void testToString()
5242
{
53-
assertEquals( "Spot Id", LabelOptions.SPOT_ID.getName() );
54-
assertEquals( "BranchSpot Id", LabelOptions.BRANCH_SPOT_ID.getName() );
55-
assertEquals( "Track Id", LabelOptions.TRACK_ID.getName() );
43+
assertEquals( "Spot ID", LabelOptions.SPOT_ID.toString() );
5644
}
5745
}

0 commit comments

Comments
 (0)