All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ncsa.hdf.view.ViewProperties Maven / Gradle / Ivy

The newest version!
/*****************************************************************************
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of the HDF Java Products distribution.                  *
 * The full copyright notice, including terms governing use, modification,   *
 * and redistribution, is contained in the files COPYING and Copyright.html. *
 * COPYING can be found at the root of the source code distribution tree.    *
 * Or, see http://hdfgroup.org/products/hdf-java/doc/Copyright.html.         *
 * If you do not have access to either file, you may request a copy from     *
 * [email protected].                                                        *
 ****************************************************************************/

package ncsa.hdf.view;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Vector;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import javax.swing.Icon;
import javax.swing.ImageIcon;

import ncsa.hdf.object.FileFormat;

/**
 * The ViewProperties holds all the HDFView static information.
 * 
 * @author Peter X. Cao
 * @version 2.4 9/6/2007
 */
public class ViewProperties extends Properties {
    private static final long   serialVersionUID     = -6411465283887959066L;

    /** the version of the HDFViewer */
    public static final String  VERSION              = "2.9";

    /** the local property file name */
    private static final String USER_PROPERTY_FILE   = ".hdfview" + VERSION.substring(0, 3);

    /** the maximum number of most recent files */
    public static final int     MAX_RECENT_FILES     = 15;

    /** name of the tab delimiter */
    public static final String  DELIMITER_TAB        = "Tab";

    /** name of the tab delimiter */
    public static final String  DELIMITER_COMMA      = "Comma";

    /** name of the tab delimiter */
    public static final String  DELIMITER_SPACE      = "Space";

    /** name of the tab delimiter */
    public static final String  DELIMITER_COLON      = "Colon";

    /** image origin: UpperLeft */
    public static final String  ORIGIN_UL            = "UpperLeft";

    /** image origin: LowerLeft */
    public static final String  ORIGIN_LL            = "LowerLeft";

    /** image origin: UpperRight */
    public static final String  ORIGIN_UR            = "UpperRight";

    /** image origin: LowerRight */
    public static final String  ORIGIN_LR            = "LowerRight";

    /** name of the tab delimiter */
    public static final String  DELIMITER_SEMI_COLON = "Semi-Colon";

    /**
     * Property keys how how the data is displayed.
     */
    public static enum DATA_VIEW_KEY {
        CHAR, CONVERTBYTE, TRANSPOSED, READONLY, OBJECT, BITMASK, BITMASKOP, BORDER, INFO, INDEXBASE1
    }

    /**
     * Property keys how how the data is displayed.
     */
    public static enum BITMASK_OP {
        AND, EXTRACT
    }

    /** user's guide */
    private static String           usersGuide             = System.getProperty("user.dir") + "/UsersGuide/index.html";

    /** the font size */
    private static int              fontSize               = 12;

    /** the font type */
    private static String           fontType               = null;

    /** the full path of H4toH5 converter */
    private static String           h4toh5                 = "";

    /** data delimiter */
    private static String           delimiter              = DELIMITER_TAB;

    /** image origin */
    private static String           origin                 = ORIGIN_UL;

    /** default index type */
    private static String           indexType              = "H5_INDEX_NAME";

    /** default index order */
    private static String           indexOrder             = "H5_ITER_INC";

    /** a list of most recent files */
    private static Vector   mrf;

    /** the root directory of the HDFView */
    private static String           rootDir;

    /** default starting file directory */
    private static String           workDir                = "user.dir";

    /** default HDF4 file extension */
    private static String           fileExt                = "hdf, h4, hdf4, h5, hdf5, he4, he5";

    private static ClassLoader      extClassLoader         = null;

    /** a list of srb accounts */
    private static Vector srbAccountList         = new Vector(5);

    /**
     * flag to indicate if auto contrast is used in image process. Do not use
     * autocontrast by default (2.6 change).
     */
    private static boolean          isAutoContrast         = false;

    private static boolean          showImageValues        = false;

    /**
     * flag to indicate if default open file is read only. By default, use
     * read/write.
     */
    private static boolean          isReadOnly             = false;
    
    private static boolean 			isEarlyLib 			   = true;

    /** a list of palette files */
    private static Vector   paletteList            = new Vector(5);

    /** flag to indicate if enum data is converted to strings */
    private static boolean          convertEnum            = true;

    /** flag to indicate if data is 1-based index */
    private static boolean          isIndexBase1           = false;

    /**
     * Current Java application such as HDFView cannot handle files with large
     * number of objects such 1,000,000 objects. max_members defines the maximum
     * number of objects will be loaded into memory.
     */
    private static int              max_members            = Integer.MAX_VALUE;   // load all by default                                               // 1,000
    // by
    // default

    /**
     * Current Java application such as HDFView cannot handle files with large
     * number of objects such 1,000,000 objects. start_members defines the
     * starting index of objects will be loaded into memory.
     */
    private static int              start_members          = 0;                                                        // 0
    // by
    // default

    private static ImageIcon        hdfIcon, h4Icon, h5Icon, largeHdfIcon, blankIcon, helpIcon, fileopenIcon,
    filesaveIcon, filenewIcon, filecloseIcon, foldercloseIcon, folderopenIcon, foldercloseIconA,
    folderopenIconA, datasetIcon, imageIcon, tableIcon, textIcon, datasetIconA, imageIconA, tableIconA,
    textIconA, zoominIcon, zoomoutIcon, paletteIcon, chartIcon, brightIcon, autocontrastIcon, copyIcon,
    cutIcon, pasteIcon, previousIcon, nextIcon, firstIcon, lastIcon, animationIcon, datatypeIcon,
    datatypeIconA, linkIcon, iconAPPS, iconURL, iconVIDEO, iconXLS, iconPDF, iconAUDIO, questionIcon;

    private static String           propertyFile;

    /** a list of treeview module */
    private static Vector   moduleListTreeView     = new Vector(5);

    /** a list of metaview module */
    private static Vector   moduleListMetaDataView = new Vector(5);

    /** a list of textview module */
    private static Vector   moduleListTextView     = new Vector(5);

    /** a list of tableview module */
    private static Vector   moduleListTableView    = new Vector(5);

    /** a list of imageview module */
    private static Vector   moduleListImageView    = new Vector(5);

    /** a list of paletteview module */
    private static Vector   moduleListPaletteView  = new Vector(5);

    /** a list of helpview module */
    private static Vector   moduleListHelpView     = new Vector(5);

    /**
     * Creates a property list with given root directory of the HDFView.
     */
    public ViewProperties(String viewRoot) {
        super();
        rootDir = viewRoot;

        mrf = new Vector(MAX_RECENT_FILES + 5);

        // find the property file
        String uh = "", ud = "", h5v = "", fn;

        // look for the property file at the use home directory
        fn = USER_PROPERTY_FILE;
        uh = System.getProperty("user.home") + File.separator + fn;
        ud = System.getProperty("user.dir") + File.separator + fn;
        h5v = viewRoot + File.separator + "lib" + File.separator + fn;

        if ((new File(uh)).exists()) {
            propertyFile = uh;
        }
        else if ((new File(ud)).exists()) {
            propertyFile = ud;
        }
        else // create new property file at user home directory
        {
            propertyFile = uh;
            File pFile = new File(uh);
            try {
                pFile.createNewFile();
            }
            catch (Exception ex) {
                propertyFile = null;
            }
        }
    }

    /* the properties are sorted by keys */
    @SuppressWarnings("unchecked")
    public synchronized Enumeration keys() {
        Enumeration keysEnum = super.keys();
        @SuppressWarnings("rawtypes")
        Vector keyList = new Vector(50);
        while (keysEnum.hasMoreElements()) {
            keyList.add(keysEnum.nextElement());
        }
        Collections.sort(keyList);
        return keyList.elements();
    }

    /** load module classes */
    public static ClassLoader loadExtClass() {
        if (extClassLoader != null) {
            return extClassLoader;
        }
        else {
            // default classloader
            extClassLoader = ClassLoader.getSystemClassLoader();
        }

        String rootPath = System.getProperty("hdfview.root");
        if (rootPath == null) rootPath = System.getProperty("user.dir");

        String dirname = rootPath + File.separator + "lib" + File.separator + "ext" + File.separator;
        File extdir = new File(dirname);
        String[] jars = extdir.list();

        if ((jars == null) || (jars.length <= 0)) {
            return extClassLoader;
        }

        Vector jarList = new Vector(50);
        Vector classList = new Vector(50);
        for (int i = 0; i < jars.length; i++) {
            if (jars[i].endsWith(".jar")) {
                jarList.add(jars[i]);
                // add class names to the list of classes
                File tmpFile = new File(extdir, jars[i]);
                try {
                    JarFile jarFile = new JarFile(tmpFile, false, JarFile.OPEN_READ);
                    Enumeration emu = jarFile.entries();
                    while (emu.hasMoreElements()) {
                        JarEntry jarEntry = (JarEntry) emu.nextElement();
                        String entryName = jarEntry.getName();
                        int idx = entryName.indexOf(".class");
                        if ((idx > 0) && (entryName.indexOf('$') <= 0)) {
                            entryName = entryName.replace('/', '.');
                            classList.add(entryName.substring(0, idx));
                        }
                    }
                }
                catch (Exception ex) {
                }
            } // if (jars[i].endsWith(".jar")) {
        } // for (int i=0; i theClass = null;
                try {
                    theClass = Class.forName(theName);
                }
                catch (Exception ex) {
                    theClass = extClassLoader.loadClass(theName);
                }

                Class[] interfaces = theClass.getInterfaces();
                if (interfaces != null) {
                    for (int j = 0; j < interfaces.length; j++) {
                        String interfaceName = interfaces[j].getName();

                        if ("ncsa.hdf.view.TreeView".equals(interfaceName) && !moduleListTreeView.contains(theName)) {
                            moduleListTreeView.add(theName);
                            break;
                        }
                        else if ("ncsa.hdf.view.MetaDataView".equals(interfaceName)
                                && !moduleListMetaDataView.contains(theName)) {
                            moduleListMetaDataView.add(theName);
                            break;
                        }
                        else if ("ncsa.hdf.view.TextView".equals(interfaceName)
                                && !moduleListTextView.contains(theName)) {
                            moduleListTextView.add(theName);
                            break;
                        }
                        else if ("ncsa.hdf.view.TableView".equals(interfaceName)
                                && !moduleListTableView.contains(theName)) {
                            moduleListTableView.add(theName);
                            break;
                        }
                        else if ("ncsa.hdf.view.ImageView".equals(interfaceName)
                                && !moduleListImageView.contains(theName)) {
                            moduleListImageView.add(theName);
                            break;
                        }
                        else if ("ncsa.hdf.view.PaletteView".equals(interfaceName)
                                && !moduleListPaletteView.contains(theName)) {
                            moduleListPaletteView.add(theName);
                            break;
                        }
                        else if ("ncsa.hdf.view.HelpView".equals(interfaceName)
                                && !moduleListHelpView.contains(theName)) {
                            moduleListHelpView.add(theName);
                            break;
                        }
                    } // for (int j=0; j theList = moduleList[i];
            propVal = (String) get(moduleKeys[i]);

            if (propVal != null) {
                // set default to the module specified in property file
                theList.remove(propVal);
                theList.add(0, propVal);
            }
            else {
                // use default module
                theList.remove(moduleNames[i]);
                theList.add(0, moduleNames[i]);
            }
        }

        // add netcdf and fits file formats

        try {
            FileInputStream fis = new FileInputStream(propertyFile);
            load(fis);
            fis.close();
        }
        catch (Exception e) {
            ;
        }

        // add fileformat modules
        Enumeration local_enum = this.keys();
        String theKey = null;
        String fExt = null;
        while (local_enum.hasMoreElements()) {
            theKey = (String) local_enum.nextElement();
            if (theKey.startsWith("module.fileformat")) {
                fExt = theKey.substring(18);
                try {
                    // enables use of JHDF5 in JNLP (Web Start) applications,
                    // the system class loader with reflection first.
                    String className = (String) get(theKey);
                    Class theClass = null;
                    try {
                        theClass = Class.forName(className);
                    }
                    catch (Exception ex) {
                        try {
                            theClass = extClassLoader.loadClass(className);
                        }
                        catch (Exception ex2) {
                        }
                    }

                    Object theObject = theClass.newInstance();
                    if (theObject instanceof FileFormat) {
                        FileFormat.addFileFormat(fExt, (FileFormat) theObject);
                    }
                }
                catch (Throwable err) {
                    ;
                }
            }
        }

        propVal = (String) get("users.guide");
        if (propVal != null) {
            usersGuide = propVal;
        }

        propVal = (String) get("image.contrast");
        if (propVal != null) {
            isAutoContrast = ("auto".equalsIgnoreCase(propVal));
        }

        propVal = (String) get("image.showvalues");
        if (propVal != null) {
            showImageValues = ("true".equalsIgnoreCase(propVal));
        }

        propVal = (String) get("file.mode");
        if (propVal != null) {
            isReadOnly = ("r".equalsIgnoreCase(propVal));
        }
        
        propVal = (String) get("lib.version");
        if (propVal != null) {
            isEarlyLib = ("early".equalsIgnoreCase(propVal));
        }

        propVal = (String) get("enum.conversion");
        if (propVal != null) {
            convertEnum = ("true".equalsIgnoreCase(propVal));
        }

        propVal = (String) get("index.base1");
        if (propVal != null) {
            isIndexBase1 = ("true".equalsIgnoreCase(propVal));
        }

        propVal = (String) get("data.delimiter");
        if ((propVal != null) && (propVal.length() > 0)) {
            delimiter = propVal;
        }

        propVal = (String) get("image.origin");
        if ((propVal != null) && (propVal.length() > 0)) {
            origin = propVal;
        }

        propVal = (String) get("h5file.indexType");
        if ((propVal != null) && (propVal.length() > 0)) {
            indexType = propVal;
        }

        propVal = (String) get("h5file.indexOrder");
        if ((propVal != null) && (propVal.length() > 0)) {
            indexOrder = propVal;
        }

        propVal = (String) get("h4toh5.converter");
        if ((propVal != null) && (propVal.length() > 0)) {
            h4toh5 = propVal;
        }

        propVal = (String) get("work.dir");
        if ((propVal != null) && (propVal.length() > 0)) {
            workDir = propVal;
        }

        propVal = (String) get("file.extension");
        if ((propVal != null) && (propVal.length() > 0)) {
            fileExt = propVal;
            FileFormat.addFileExtension(fileExt);
        }

        propVal = (String) get("font.size");
        if ((propVal != null) && (propVal.length() > 0)) {
            try {
                fontSize = Integer.parseInt(propVal);
            }
            catch (Exception ex) {
            }
        }

        propVal = (String) get("font.type");
        if ((propVal != null) && (propVal.length() > 0)) {
            fontType = propVal.trim();
        }

        propVal = (String) get("max.members");
        if ((propVal != null) && (propVal.length() > 0)) {
            try {
                max_members = Integer.parseInt(propVal);
            }
            catch (Exception ex) {
            }
        }

        // load the most recent file list from the property file
        String theFile = null;
        for (int i = 0; i < MAX_RECENT_FILES; i++) {
            theFile = getProperty("recent.file" + i);
            if ((theFile != null) && !mrf.contains(theFile)) {
                if (theFile.startsWith("http://") || theFile.startsWith("ftp://") || (new File(theFile)).exists()) {
                    mrf.addElement(theFile);
                }
            }
            else {
                this.remove("recent.file" + i);
            }
        }

        // load the most recent palette file list from the property file
        theFile = null;
        for (int i = 0; i < MAX_RECENT_FILES; i++) {
            theFile = getProperty("palette.file" + i);
            if (theFile != null) theFile = theFile.trim();

            if ((theFile != null && theFile.length() > 0) && !paletteList.contains(theFile)) {
                if ((new File(theFile)).exists()) {
                    paletteList.addElement(theFile);
                }
            }
            else {
                this.remove("palette.file" + i);
            }
        }

        // load srb account
        propVal = null;
        String srbaccount[] = new String[7];
        for (int i = 0; i < MAX_RECENT_FILES; i++) {
            if (null == (srbaccount[0] = getProperty("srbaccount" + i + ".host"))) {
                continue;
            }
            if (null == (srbaccount[1] = getProperty("srbaccount" + i + ".port"))) {
                continue;
            }
            if (null == (srbaccount[2] = getProperty("srbaccount" + i + ".user"))) {
                continue;
            }
            if (null == (srbaccount[3] = getProperty("srbaccount" + i + ".password"))) {
                continue;
            }
            if (null == (srbaccount[4] = getProperty("srbaccount" + i + ".home"))) {
                continue;
            }
            if (null == (srbaccount[5] = getProperty("srbaccount" + i + ".domain"))) {
                continue;
            }
            if (null == (srbaccount[6] = getProperty("srbaccount" + i + ".resource"))) {
                continue;
            }
            srbAccountList.add(srbaccount);
            srbaccount = new String[7];
        }

        // set default modules from user property files
        for (int i = 0; i < 6; i++) {
            String moduleName = (String) get(moduleKeys[i]);
            if ((moduleName != null) && (moduleName.length() > 0)) {
                if (moduleList[i].contains(moduleName)) moduleList[i].remove(moduleName);
                moduleList[i].add(0, moduleName);
            }
        }
    }

    /** Save user properties into property file */
    public void save() {
        if (propertyFile == null) {
            return;
        }
        else {
            clear();
        }

        // update data saving options
        if (delimiter == null) {
            put("data.delimiter", DELIMITER_TAB);
        }
        else {
            put("data.delimiter", delimiter);
        }

        if (origin == null) {
            put("image.origin", ORIGIN_UL);
        }
        else {
            put("image.origin", origin);
        }

        if (indexType != null) {
            put("h5file.indexType", indexType);
        }

        if (indexOrder != null) {
            put("h5file.indexOrder", indexOrder);
        }

        if (usersGuide != null) {
            put("users.guide", usersGuide);
        }

        if (workDir != null) {
            put("work.dir", workDir);
        }

        if (fileExt != null) {
            put("file.extension", fileExt);
        }

        if (h4toh5 != null) {
            put("h4toh5.converter", h4toh5);
        }

        put("font.size", String.valueOf(fontSize));

        if (fontType != null) {
            put("font.type", fontType);
        }

        put("max.members", String.valueOf(max_members));

        if (isAutoContrast) {
            put("image.contrast", "auto");
        }
        else {
            put("image.contrast", "general");
        }

        if (showImageValues)
            put("image.showvalues", "true");
        else
            put("image.showvalues", "false");

        if (isReadOnly) {
            put("file.mode", "r");
        }
        else {
            put("file.mode", "rw");
        }
        
        if (isEarlyLib) {
            put("lib.version", "early");
        }
        else {
            put("lib.version", "latest");
        }

        put("enum.conversion", String.valueOf(convertEnum));
        put("index.base1", String.valueOf(isIndexBase1));

        // save the list of most recent files
        String theFile;
        int size = mrf.size();
        int minSize = Math.min(size, MAX_RECENT_FILES);
        for (int i = 0; i < minSize; i++) {
            theFile = mrf.elementAt(i);
            if ((theFile != null) && (theFile.length() > 0)) {
                put("recent.file" + i, theFile);
            }
        }

        // save the list of most recent palette files
        size = paletteList.size();
        minSize = Math.min(size, MAX_RECENT_FILES);
        for (int i = 0; i < minSize; i++) {
            theFile = paletteList.elementAt(i);
            if ((theFile != null) && (theFile.length() > 0)) {
                put("palette.file" + i, theFile);
            }
        }

        // save srb account
        String srbaccount[] = null;
        size = srbAccountList.size();
        minSize = Math.min(size, MAX_RECENT_FILES);
        for (int i = 0; i < minSize; i++) {
            srbaccount = srbAccountList.get(i);
            if ((srbaccount[0] != null) && (srbaccount[1] != null) && (srbaccount[2] != null)
                    && (srbaccount[3] != null) && (srbaccount[4] != null) && (srbaccount[5] != null)
                    && (srbaccount[6] != null)) {
                put("srbaccount" + i + ".host", srbaccount[0]);
                put("srbaccount" + i + ".port", srbaccount[1]);
                put("srbaccount" + i + ".user", srbaccount[2]);
                put("srbaccount" + i + ".password", srbaccount[3]);
                put("srbaccount" + i + ".home", srbaccount[4]);
                put("srbaccount" + i + ".domain", srbaccount[5]);
                put("srbaccount" + i + ".resource", srbaccount[6]);
            }
        }

        // save default modules
        String moduleName = moduleListTreeView.elementAt(0);
        if ((moduleName != null) && (moduleName.length() > 0)) {
            put("module.treeview", moduleName);
        }

        moduleName = moduleListMetaDataView.elementAt(0);
        if ((moduleName != null) && (moduleName.length() > 0)) {
            put("module.metadataview", moduleName);
        }

        moduleName = moduleListTextView.elementAt(0);
        if ((moduleName != null) && (moduleName.length() > 0)) {
            put("module.textview", moduleName);
        }

        moduleName = moduleListTableView.elementAt(0);
        if ((moduleName != null) && (moduleName.length() > 0)) {
            put("module.tableview", moduleName);
        }

        moduleName = moduleListImageView.elementAt(0);
        if ((moduleName != null) && (moduleName.length() > 0)) {
            put("module.imageview", moduleName);
        }

        moduleName = moduleListPaletteView.elementAt(0);
        if ((moduleName != null) && (moduleName.length() > 0)) {
            put("module.paletteview", moduleName);
        }

        // save the current supported fileformat
        Enumeration keys = FileFormat.getFileFormatKeys();
        String theKey = null;
        while (keys.hasMoreElements()) {
            theKey = (String) keys.nextElement();
            FileFormat theformat = FileFormat.getFileFormat(theKey);
            put("module.fileformat." + theKey, theformat.getClass().getName());
        }

        try {
            FileOutputStream fos = new FileOutputStream(propertyFile);
            store(fos, "User properties modified on ");
            fos.close();
        }
        catch (Exception e) {
            ;
        }
    }

    /** returns the name of the user property file */
    public static String getPropertyFile() {
        return propertyFile;
    }

    /** returns the default work directory, where the open file starts. */
    public static String getWorkDir() {
        if (workDir.equals("user.dir")) {
            workDir = System.getProperty("user.dir");
        }

        return workDir;
    }

    /** returns the maximum number of the most recent file */
    public static int getMaxRecentFiles() {
        return MAX_RECENT_FILES;
    }

    /** return the path of the H5View uers guide */
    public static String getUsersGuide() {
        return usersGuide;
    };

    /** returns the delimiter of data values */
    public static String getDataDelimiter() {
        return delimiter;
    }

    /** returns the image origin */
    public static String getImageOrigin() {
        return origin;
    }

    /** returns the default index type for display */
    public static String getIndexType() {
        return indexType;
    }

    /** returns the default index order for display */
    public static String getIndexOrder() {
        return indexOrder;
    }

    /** returns the font size */
    public static int getFontSize() {
        return fontSize;
    }

    /** returns the font type */
    public static String getFontType() {
        return fontType;
    }

    /** gets the file extensions of supported file formats */
    public static String getFileExtension() {
        return fileExt;
    }

    /** sets the font size */
    public static void setFontSize(int fsize) {
        fontSize = (fsize / 2) * 2;

        if (fontSize < 8) {
            fontSize = 8;
        }
    }

    /** sets the font size */
    public static void setFontType(String ftype) {
        if (ftype != null) {
            fontType = ftype.trim();
        }
    }

    /** returns the path of the H5toH5 converter */
    public static String getH4toH5() {
        return h4toh5;
    };

    /** returns the list of most recent files */
    public static Vector getMRF() {
        return mrf;
    }

    /** returns the list of palette files */
    public static Vector getPaletteList() {
        return paletteList;
    }

    public static Vector getSrbAccount() {
        return srbAccountList;
    }

    /** returns a list of treeview modules */
    public static Vector getTreeViewList() {
        return moduleListTreeView;
    }

    /** returns a list of metadataview modules */
    public static Vector getMetaDataViewList() {
        return moduleListMetaDataView;
    }

    /** returns a list of textview modules */
    public static Vector getTextViewList() {
        return moduleListTextView;
    }

    /** returns a list of tableview modules */
    public static Vector getTableViewList() {
        return moduleListTableView;
    }

    /** returns a list of imageview modules */
    public static Vector getImageViewList() {
        return moduleListImageView;
    }

    /** returns a list of paletteview modules */
    public static Vector getPaletteViewList() {
        return moduleListPaletteView;
    }

    /** returns a list of helpview modules */
    public static Vector getHelpViewList() {
        return moduleListHelpView;
    }

    /** set the path of H5View User's guide */
    public static void setUsersGuide(String str) {
        if ((str == null) || (str.length() <= 0)) {
            return;
        }
        usersGuide = str;
    }

    /** set the path of the H5to H5 converter */
    public static void setH4toH5(String tool) {
        h4toh5 = tool;
    }

    /** set the path of the default work directory */
    public static void setWorkDir(String wDir) {
        workDir = wDir;
    }

    /** set the file extension */
    public static void setFileExtension(String ext) {
        fileExt = ext;
    }

    /** set the delimiter of data values */
    public static void setDataDelimiter(String delim) {
        delimiter = delim;
    }

    /** set the image origin */
    public static void setImageOrigin(String o) {
        origin = o;
    }

    /** set the index type */
    public static void setIndexType(String idxType) {
        indexType = idxType;
    }

    /** set the index order */
    public static void setIndexOrder(String idxOrder) {
        indexOrder = idxOrder;
    }

    /**
     * Current Java application such as HDFView cannot handle files with large
     * number of objects such 1,000,000 objects. setMaxMembers() sets the
     * maximum number of objects will be loaded into memory.
     * 
     * @param n
     *            the maximum number of objects to load into memory
     */
    public static void setMaxMembers(int n) {
        max_members = n;
    }

    /**
     * Current Java application such as HDFView cannot handle files with large
     * number of objects such 1,000,000 objects. setStartMember() sets the
     * starting index of objects will be loaded into memory.
     * 
     * @param idx
     *            the maximum number of objects to load into memory
     */
    public static void setStartMembers(int idx) {
        if (idx < 0) {
            idx = 0;
        }

        start_members = idx;
    }

    /**
     * Current Java application such as HDFView cannot handle files with large
     * number of objects such 1,000,000 objects. getMaxMembers() returns the
     * maximum number of objects will be loaded into memory.
     */
    public static int getMaxMembers() {
    	if (max_members < 0)
    		return Integer.MAX_VALUE; // load the whole file
    	
        return max_members;
    }

    /**
     * Current Java application such as HDFView cannot handle files with large
     * number of objects such 1,000,000 objects. getStartMembers() returns the
     * starting index of objects will be loaded into memory.
     */
    public static int getStartMembers() {
        return start_members;
    }

    /**
     * Returns true if auto contrast is used in image process.
     * 
     * @return true if auto contrast is used in image process; otherwise,
     *         returns false.
     */
    public static boolean isAutoContrast() {
        return isAutoContrast;
    }

    /**
     * Returns true if "show image values" is set.
     * 
     * @return true if "show image values" is set; otherwise, returns false.
     */
    public static boolean showImageValues() {
        return showImageValues;
    }

    /**
     * Set the flag to indicate if auto contrast is used in image process.
     * 
     * @param b
     *            the flag to indicate if auto contrast is used in image
     *            process.
     */
    public static void setAutoContrast(boolean b) {
        isAutoContrast = b;
    }

    /**
     * Set the flag to indicate if "show image values" is set.
     * 
     * @param b
     *            the flag to indicate if if "show image values" is set.
     */
    public static void setShowImageValue(boolean b) {
        showImageValues = b;
    }

    /**
     * Returns true if default file access is read only.
     * 
     * @return true if default file access is read only; otherwise, returns
     *         false.
     */
    public static boolean isReadOnly() {
        return isReadOnly;
    }
  
    /**
     * Set the flag to indicate if default file access is read only.
     * 
     * @param b
     *            the flag to indicate if default file access is read only.
     */
    public static void setReadOnly(boolean b) {
        isReadOnly = b;
    }
    
    /**
     * Returns true if default lib version is the earliest.
     * 
     * @return true if default lib version is the earliest; otherwise, returns
     *         false.
     */
    public static boolean isEarlyLib() {
        return isEarlyLib;
    }

    /**
     * Set the flag to indicate if default lib version is the earliest.
     * 
     * @param b
     *            the flag to indicate if default lib version is the earliest.
     */
    public static void setEarlyLib(boolean b) {
    	isEarlyLib = b;
    }

    /**
     * @return the convertEnum
     */
    public static boolean isConvertEnum() {
        return convertEnum;
    }

    /**
     * @return the convertEnum
     */
    public static boolean isIndexBase1() {
        return isIndexBase1;
    }

    /**
     * @param convertEnum
     *            the convertEnum to set
     */
    public static void setConvertEnum(boolean convertEnum) {
        ViewProperties.convertEnum = convertEnum;
    }

    /**
     * @param convertEnum
     *            the convertEnum to set
     */
    public static void setIndexBase1(boolean b) {
        ViewProperties.isIndexBase1 = b;
    }

}