001/******************************************************************************* 002 * This software is provided as a supplement to the authors' textbooks on digital 003 * image processing published by Springer-Verlag in various languages and editions. 004 * Permission to use and distribute this software is granted under the BSD 2-Clause 005 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause). 006 * Copyright (c) 2006-2023 Wilhelm Burger, Mark J. Burge. All rights reserved. 007 * Visit https://imagingbook.com for additional details. 008 ******************************************************************************/ 009package Tools_; 010 011import ij.gui.GenericDialog; 012import ij.plugin.PlugIn; 013import imagingbook.core.jdoc.JavaDocHelp; 014import imagingbook.core.resource.ImageResource; 015import imagingbook.sampleimages.GeneralSampleImage; 016 017import static imagingbook.common.util.ClassUtils.getEnumConstantsSorted; 018 019/** 020 * ImageJ plugin, allows the user to select and open one of the internal sample images. The pull-down menu lists all 021 * available sample images in alphabetic order. The image is loaded from the associated JAR file. 022 * 023 * @author WB 024 * @see GeneralSampleImage 025 * @see ImageResource 026 */ 027public class Open_Sample_Image implements PlugIn, JavaDocHelp { 028 029 @Override 030 public void run(String arg) { 031 GenericDialog gd = new GenericDialog(this.getClass().getSimpleName()); 032 gd.addHelp(getJavaDocUrl()); 033 GeneralSampleImage[] sortedItems = getEnumConstantsSorted(GeneralSampleImage.class); 034 gd.addEnumChoice("Select image", sortedItems, sortedItems[0]); // available since ImageJ 1.54a 035 036 gd.showDialog(); 037 if (gd.wasCanceled()) 038 return; 039 040 ImageResource ir = gd.getNextEnumChoice(GeneralSampleImage.class); 041 ir.getImagePlus().show(); 042 } 043 044}