//
// Option.java
//
/*
LOCI Plugins for ImageJ: a collection of ImageJ plugins including the
Bio-Formats Importer, Bio-Formats Exporter, Bio-Formats Macro Extensions,
Data Browser and Stack Slicer. Copyright (C) 2005-@year@ Melissa Linkert,
Curtis Rueden and Christopher Peterson.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package loci.plugins.prefs;
import loci.common.IniTable;
/**
* Base class for an option for one of the LOCI plugins.
*
* <dl><dt><b>Source code:</b></dt>
* <dd><a href="http://trac.openmicroscopy.org.uk/ome/browser/bioformats.git/components/loci-plugins/src/loci/plugins/prefs/Option.java">Trac</a>,
* <a href="http://git.openmicroscopy.org/?p=bioformats.git;a=blob;f=components/loci-plugins/src/loci/plugins/prefs/Option.java;hb=HEAD">Gitweb</a></dd></dl>
*/
public abstract class Option {
// -- Constants --
/** Prefix to use for all LOCI plugins preferences. */
public static final String KEY_PREFIX = "bioformats.";
/** INI key indicating option's key. */
public static final String INI_KEY = IniTable.HEADER_KEY;
/** INI key indicating whether option should be saved to prefs file. */
public static final String INI_SAVE = "save";
/** INI key indicating option's label. */
public static final String INI_LABEL = "label";
/** INI key indicating option's info. */
public static final String INI_INFO = "info";
/** INI key indicating option's default value. */
public static final String INI_DEFAULT = "default";
// -- Fields --
/** Key name for ImageJ preferences file. */
protected String key;
/** Whether option state should be saved to ImageJ preferences file. */
protected boolean save;
/**
* Label describing the option, for use with ImageJ dialogs.
* May contain underscores to produce a better macro variable name.
*/
protected String label;
/** Documentation about the option, in HTML. */
protected String info;
// -- Constructor --
/** Constructs an option with the given parameters. */
public Option(String key, boolean save, String label, String info) {
this.key = key;
if (key == null) throw new IllegalArgumentException("Null key");
this.save = save;
this.label = label;
this.info = info;
}
// -- Option methods --
/** Gets the option's key name. */
public String getKey() {
return key;
}
/** Gets whether option should be saved to ImageJ preferences file. */
public boolean isSaved() {
return save;
}
/** Gets label describing the option. */
public String getLabel() {
return label;
}
/** Gets documentation about the option. */
public String getInfo() {
return info;
}
// -- Abstract Option methods --
/** Parses the option's value from the given argument string. */
public abstract void parseOption(String arg);
/** Loads the option's value from the ImageJ preferences file. */
public abstract void loadOption();
/** Saves the option's value to the ImageJ preferences file. */
public abstract void saveOption();
}