001/*****************************************************************************
002 * Copyright by The HDF Group.                                               *
003 * Copyright by the Board of Trustees of the University of Illinois.         *
004 * All rights reserved.                                                      *
005 *                                                                           *
006 * This file is part of the HDF Java Products distribution.                  *
007 * The full copyright notice, including terms governing use, modification,   *
008 * and redistribution, is contained in the files COPYING and Copyright.html. *
009 * COPYING can be found at the root of the source code distribution tree.    *
010 * Or, see https://support.hdfgroup.org/products/licenses.html               *
011 * If you do not have access to either file, you may request a copy from     *
012 * help@hdfgroup.org.                                                        *
013 ****************************************************************************/
014
015package hdf.view;
016
017import java.io.File;
018import java.io.IOException;
019import java.io.InputStream;
020import java.net.MalformedURLException;
021import java.net.URL;
022import java.net.URLClassLoader;
023import java.util.Arrays;
024import java.util.Enumeration;
025import java.util.Vector;
026import java.util.jar.JarEntry;
027import java.util.jar.JarFile;
028
029import org.eclipse.jface.preference.PreferenceStore;
030import org.eclipse.swt.graphics.Image;
031
032import hdf.HDFVersions;
033import hdf.object.FileFormat;
034import hdf.view.ImageView.ImageViewFactory;
035import hdf.view.MetaDataView.MetaDataViewFactory;
036import hdf.view.PaletteView.PaletteViewFactory;
037import hdf.view.TableView.TableViewFactory;
038import hdf.view.TreeView.TreeViewFactory;
039
040public class ViewProperties extends PreferenceStore {
041    private static final long   serialVersionUID     = -6411465283887959066L;
042
043    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ViewProperties.class);
044
045    /** the version of the HDFViewer */
046    public static final String  VERSION              = HDFVersions.HDFVIEW_VERSION;
047
048    /** the local property file name */
049    private static final String USER_PROPERTY_FILE   = ".hdfview" + VERSION;
050
051    /** the maximum number of most recent files */
052    public static final int     MAX_RECENT_FILES     = 15;
053
054    /** name of the tab delimiter */
055    public static final String  DELIMITER_TAB        = "Tab";
056
057    /** name of the tab delimiter */
058    public static final String  DELIMITER_COMMA      = "Comma";
059
060    /** name of the tab delimiter */
061    public static final String  DELIMITER_SPACE      = "Space";
062
063    /** name of the tab delimiter */
064    public static final String  DELIMITER_COLON      = "Colon";
065
066    /** image origin: UpperLeft */
067    public static final String  ORIGIN_UL            = "UpperLeft";
068
069    /** image origin: LowerLeft */
070    public static final String  ORIGIN_LL            = "LowerLeft";
071
072    /** image origin: UpperRight */
073    public static final String  ORIGIN_UR            = "UpperRight";
074
075    /** image origin: LowerRight */
076    public static final String  ORIGIN_LR            = "LowerRight";
077
078    /** name of the tab delimiter */
079    public static final String  DELIMITER_SEMI_COLON = "Semi-Colon";
080
081    /**
082     * The names of the various default classes for each HDFView module interface
083     */
084
085    /** Text for default selection of modules */
086    public static final String DEFAULT_MODULE_TEXT = "Default";
087
088    /** Default TreeView class names */
089    public static final String DEFAULT_TREEVIEW_NAME = "hdf.view.TreeView.DefaultTreeView";
090
091    /** Default TableView class names */
092    public static final String DEFAULT_SCALAR_DATASET_TABLEVIEW_NAME = "hdf.view.TableView.DefaultScalarDSTableView";
093    public static final String DEFAULT_SCALAR_ATTRIBUTE_TABLEVIEW_NAME = "hdf.view.TableView.DefaultScalarAttributeTableView";
094    public static final String DEFAULT_COMPOUND_DATASET_TABLEVIEW_NAME = "hdf.view.TableView.DefaultCompoundDSTableView";
095    public static final String DEFAULT_COMPOUND_ATTRIBUTE_TABLEVIEW_NAME = "hdf.view.TableView.DefaultCompoundAttributeTableView";
096
097    /** Default MetaDataView class names */
098    public static final String DEFAULT_GROUP_METADATAVIEW_NAME = "hdf.view.MetaDataView.DefaultGroupMetaDataView";
099    public static final String DEFAULT_DATASET_METADATAVIEW_NAME = "hdf.view.MetaDataView.DefaultDatasetMetaDataView";
100    public static final String DEFAULT_DATATYPE_METADATAVIEW_NAME = "hdf.view.MetaDataView.DefaultDatatypeMetaDataView";
101    public static final String DEFAULT_LINK_METADATAVIEW_NAME = "hdf.view.MetaDataView.DefaultLinkMetaDataView";
102
103    /** Default ImageView class names */
104    public static final String DEFAULT_IMAGEVIEW_NAME = "hdf.view.ImageView.DefaultImageView";
105
106    /** Default PaletteView class names */
107    public static final String DEFAULT_PALETTEVIEW_NAME = "hdf.view.PaletteView.DefaultPaletteView";
108
109    /**
110     * Used to create different DataViews for a given HObject.
111     */
112    public static enum DataViewType {
113        TABLE, IMAGE, PALETTE, METADATA, TREEVIEW
114    }
115
116    /**
117     * Property keys control how the data is displayed.
118     */
119    public static enum DATA_VIEW_KEY {
120        CHAR, CONVERTBYTE, TRANSPOSED, READONLY, OBJECT, BITMASK, BITMASKOP, BORDER, INFO, INDEXBASE1, VIEW_NAME
121    }
122
123    /**
124     * Property keys control how the data is displayed.
125     */
126    public static enum BITMASK_OP {
127        AND, EXTRACT
128    }
129
130    /** the root directory of the HDFView */
131    private static String           rootDir                = System.getProperty("user.dir");
132
133    /** user's guide */
134    private static String           usersGuide             = rootDir + "/UsersGuide/index.html";
135
136    /** the font size */
137    private static int              fontSize               = 12;
138
139    /** the font type */
140    private static String           fontType               = "Serif";
141
142    /** the full path of H4toH5 converter */
143    private static String           h4toh5                 = "";
144
145    /** data delimiter */
146    private static String           delimiter              = DELIMITER_TAB;
147
148    /** image origin */
149    private static String           origin                 = ORIGIN_UL;
150
151    /** default index type */
152    private static String           indexType              = "H5_INDEX_NAME";
153
154    /** default index order */
155    private static String           indexOrder             = "H5_ITER_INC";
156
157    /** a list of most recent files */
158    private static Vector<String>   recentFiles;
159
160    /** default starting file directory */
161    private static String           workDir                = "user.home";
162
163    /** default HDF file extensions */
164    private static String           fileExt                = "hdf, h4, hdf4, h5, hdf5, he2, he5";
165
166    private static ClassLoader      extClassLoader         = null;
167
168    /** a list of srb accounts */
169    private static Vector<String[]> srbAccountList = new Vector<>(5);
170
171    /**
172     * flag to indicate if auto contrast is used in image processing. Do not use
173     * autocontrast by default (2.6 change).
174     */
175    private static boolean          isAutoContrast         = false;
176
177    private static boolean          showImageValues        = false;
178
179    private static boolean          showRegRefValues       = false;
180
181    /**
182     * flag to indicate if default open file mode is read only. By default, use read
183     * only to prevent accidental modifications to the file.
184     */
185    private static boolean          isReadOnly             = true;
186
187    private static String EarlyLib = "Latest";
188
189    private static String LateLib = "Latest";
190
191    /** a list of palette files */
192    private static Vector<String>   paletteList            = new Vector<>(5);
193
194    /** flag to indicate if enum data is converted to strings */
195    private static boolean          convertEnum            = true;
196
197    /** flag to indicate if data is 1-based index */
198    private static boolean          isIndexBase1           = false;
199
200    /**
201     * Current Java applications such as HDFView cannot handle files with a large
202     * number of objects such as 1,000,000 objects. max_members defines the maximum
203     * number of objects that will be loaded into memory.
204     */
205    private static int              max_members            = Integer.MAX_VALUE;   // load all by default
206    /**
207     * Current Java applications such as HDFView cannot handle files with a large
208     * number of objects such 1,000,000 objects. start_members defines the
209     * starting index of objects that will be loaded into memory.
210     */
211    private static int              start_members          = 0;
212
213    private static Image        hdfIcon, h4Icon, h4IconR, h5Icon, h5IconR, largeHdfIcon, blankIcon, helpIcon, fileopenIcon,
214    filesaveIcon, filenewIcon, filecloseIcon, foldercloseIcon, folderopenIcon, foldercloseIconA,
215    folderopenIconA, datasetIcon, imageIcon, tableIcon, textIcon, datasetIconA, imageIconA, tableIconA,
216    textIconA, zoominIcon, zoomoutIcon, paletteIcon, chartIcon, brightIcon, autocontrastIcon, copyIcon,
217    cutIcon, pasteIcon, previousIcon, nextIcon, firstIcon, lastIcon, animationIcon, datatypeIcon,
218    datatypeIconA, linkIcon, iconAPPS, iconURL, iconVIDEO, iconXLS, iconPDF, iconAUDIO, questionIcon;
219
220    private static String           propertyFile;
221
222    /** a list of treeview modules */
223    private static Vector<String>   moduleListTreeView     = new Vector<>(5);
224
225    /** a list of metaview modules */
226    private static Vector<String>   moduleListMetaDataView = new Vector<>(5);
227
228    /** a list of tableview modules */
229    private static Vector<String>   moduleListTableView    = new Vector<>(5);
230
231    /** a list of imageview modules */
232    private static Vector<String>   moduleListImageView    = new Vector<>(5);
233
234    /** a list of paletteview modules */
235    private static Vector<String>   moduleListPaletteView  = new Vector<>(5);
236
237    /** a list of helpview modules */
238    private static Vector<String>   moduleListHelpView     = new Vector<>(5);
239
240    /**
241     * Creates a property list with given root directory of the HDFView.
242     *
243     * @param viewRoot
244     *            the root directory of the HDFView
245     */
246    public ViewProperties(String viewRoot) {
247        super();
248        // find the property file
249        String userHome, userDir, propertyFileName, h5v;
250
251        // look for the property file in the user's home directory
252        propertyFileName = USER_PROPERTY_FILE;
253        userHome = System.getProperty("user.home") + File.separator + propertyFileName;
254        userDir = System.getProperty("user.dir") + File.separator + propertyFileName;
255        h5v = workDir + File.separator + propertyFileName;
256
257        if ((new File(userHome)).exists()) {
258            propertyFile = userHome;
259            log.trace("userHome propertyFile is {}", propertyFile);
260        }
261        else if ((new File(userDir)).exists()) {
262            propertyFile = userDir;
263            log.trace("userDir propertyFile is {}", propertyFile);
264        }
265        else {
266            propertyFile = h5v;
267            File pFile = new File(h5v);
268            try {
269                pFile.createNewFile();
270            }
271            catch (Exception ex) {
272                // Last resort: create new property file at user home directory
273                propertyFile = userHome;
274                try {
275                    pFile = new File(userHome);
276                    pFile.createNewFile();
277                }
278                catch (Exception ex2) {
279                    propertyFile = null;
280                }
281            }
282        }
283        setFilename(propertyFile);
284        log.trace("propertyFile is {}", propertyFile);
285
286        rootDir = viewRoot;
287        log.trace("rootDir is {}", rootDir);
288        String workPath = System.getProperty("hdfview.workdir");
289        log.trace("hdfview.workdir={}", workPath);
290        if (workPath != null) {
291            workDir = workPath;
292        }
293
294        recentFiles = new Vector<>(MAX_RECENT_FILES + 5);
295
296        setDefault("users.guide", System.getProperty("user.dir") + "/UsersGuide/index.html");
297        setDefault("image.contrast", false);
298        setDefault("image.showvalues", false);
299        setDefault("file.mode", "r");
300        setDefault("lib.lowversion", "Earliest");
301        setDefault("lib.highversion", "Latest");
302        setDefault("enum.conversion", false);
303        setDefault("regref.showvalues", false);
304        setDefault("index.base1", false);
305        setDefault("image.origin", ORIGIN_UL);
306        setDefault("h5file.indexType", "H5_INDEX_NAME");
307        setDefault("h5file.indexOrder", "H5_ITER_INC");
308        setDefault("h4toh5.converter", "");
309        setDefault("work.dir", "user.home");
310        setDefault("file.extension", "hdf, h4, hdf4, h5, hdf5, he2, he5");
311        setDefault("font.size", 12);
312        setDefault("font.type", "Serif");
313        setDefault("max.members", Integer.MAX_VALUE);
314        setDefault("recent.file", "");
315        setDefault("palette.file", "");
316        setDefault("data.delimiter", DELIMITER_TAB);
317    }
318
319    /**
320     * load module classes
321     *
322     * @return the ClassLoader
323     */
324    public static ClassLoader loadExtClass() {
325        log.trace("loadExtClass: start");
326        if (extClassLoader != null) {
327            return extClassLoader;
328        }
329        else {
330            // default classloader
331            extClassLoader = ClassLoader.getSystemClassLoader();
332        }
333        log.trace("loadExtClass: default classloader is {}", extClassLoader);
334
335        String rootPath = System.getProperty("hdfview.root");
336        if (rootPath == null) {
337            rootPath = rootDir;
338            log.debug("loadExtClass: rootDir rootPath is {}", rootPath);
339        }
340        log.debug("loadExtClass: rootPath is {}", rootPath);
341
342        String dirname = rootPath + File.separator + "lib" + File.separator + "ext" + File.separator;
343        String[] jars = null;
344        File extdir = null;
345        try {
346            extdir = new File(dirname);
347            jars = extdir.list();
348            log.trace("loadExtClass: dirname is {} with {} jars", dirname, jars.length);
349        }
350        catch (Exception ex0) {
351            log.debug("loadExtClass: load dirname: {}+lib/ext failed", rootPath, ex0);
352        }
353
354        if ((jars == null) || (jars.length <= 0)) {
355            return extClassLoader;
356        }
357
358        Vector<String> jarList = new Vector<>(50);
359        Vector<String> classList = new Vector<>(50);
360        for (int i = 0; i < jars.length; i++) {
361            log.trace("loadExtClass: load jar[{}]", i);
362            if (jars[i].endsWith(".jar")) {
363                jarList.add(jars[i]);
364                // add class names to the list of classes
365                File tmpFile = new File(extdir, jars[i]);
366                try {
367                    JarFile jarFile = new JarFile(tmpFile, false, JarFile.OPEN_READ);
368                    Enumeration<?> emu = jarFile.entries();
369                    while (emu.hasMoreElements()) {
370                        JarEntry jarEntry = (JarEntry) emu.nextElement();
371                        String entryName = jarEntry.getName();
372                        log.trace("loadExtClass: reading jar[{}] class={}", i, entryName);
373                        int idx = entryName.indexOf(".class");
374                        if ((idx > 0) && (entryName.indexOf('$') <= 0)) {
375                            entryName = entryName.replace('/', '.');
376                            classList.add(entryName.substring(0, idx));
377                        }
378                    }
379
380                    jarFile.close();
381                }
382                catch (Exception ex) {
383                    log.debug("loadExtClass: load jar[{}] failed", i, ex);
384                }
385            } // if (jars[i].endsWith(".jar")) {
386        } // for (int i=0; i<jars.length; i++) {
387
388        int n = jarList.size();
389        if (n <= 0) {
390            log.debug("loadExtClass: jarList empty");
391            return extClassLoader;
392        }
393
394        URL[] urls = new URL[n];
395        for (int i = 0; i < n; i++) {
396            try {
397                urls[i] = new URL("file:///" + rootPath + "/lib/ext/" + jarList.get(i));
398                log.trace("loadExtClass: load urls[{}] is {}", i, urls[i]);
399            }
400            catch (MalformedURLException mfu) {
401                log.debug("loadExtClass: load urls[{}] failed", i, mfu);
402            }
403        }
404
405        // try { extClassLoader = new URLClassLoader(urls); }
406        try {
407            extClassLoader = URLClassLoader.newInstance(urls);
408        }
409        catch (Exception ex) {
410            ex.printStackTrace();
411        }
412
413        // load user modules into their list
414        n = classList.size();
415        for (int i = 0; i < n; i++) {
416            String theName = classList.get(i);
417            log.trace("loadExtClass: load classList[{}] is {}", i, theName);
418            try {
419                // enables use of JHDF5 in JNLP (Web Start) applications, the
420                // system class loader with reflection first.
421                Class<?> theClass = null;
422                try {
423                    theClass = Class.forName(theName);
424                }
425                catch (Exception ex) {
426                    try {
427                        theClass = extClassLoader.loadClass(theName);
428                    }
429                    catch (Exception exc) {
430                        log.debug("load: loadClass({}) failed", theName, ex);
431                    }
432                }
433
434                if(theClass != null) {
435                    if (TableViewFactory.class.isAssignableFrom(theClass)) {
436                        if (!moduleListTableView.contains(theName))
437                            moduleListTableView.add(theName);
438                        log.trace("loadExtClass: TableViewFactory class {}", theName);
439                    }
440                    else if (MetaDataViewFactory.class.isAssignableFrom(theClass)) {
441                        if (!moduleListMetaDataView.contains(theName))
442                            moduleListMetaDataView.add(theName);
443                        log.trace("loadExtClass: MetaDataViewFactory class {}", theName);
444                    }
445                    else if (ImageViewFactory.class.isAssignableFrom(theClass)) {
446                        if (!moduleListImageView.contains(theName))
447                            moduleListImageView.add(theName);
448                        log.trace("loadExtClass: ImageViewFactory class {}", theName);
449                    }
450                    else if (TreeViewFactory.class.isAssignableFrom(theClass)) {
451                        if (!moduleListTreeView.contains(theName))
452                            moduleListTreeView.add(theName);
453                        log.trace("loadExtClass: TreeViewFactory class {}", theName);
454                    }
455                    else if (PaletteViewFactory.class.isAssignableFrom(theClass)) {
456                        if (!moduleListPaletteView.contains(theName))
457                            moduleListPaletteView.add(theName);
458                        log.trace("loadExtClass: PaletteViewFactory class {}", theName);
459                    }
460                }
461            }
462            catch (Exception ex) {
463                log.debug("loadExtClass: load classList[{}] of {} failed", i, theName, ex);
464            }
465        } // for (int i=0; i<n; i++)
466        log.trace("loadExtClass: finished");
467
468        return extClassLoader;
469    }
470
471    /** @return the root directory where the HDFView is installed. */
472    public static String getViewRoot() {
473        return rootDir;
474    }
475
476    public static Image getFoldercloseIcon() {
477        return foldercloseIcon;
478    }
479
480    public static Image getFoldercloseIconA() {
481        return foldercloseIconA;
482    }
483
484    public static Image getFolderopenIcon() {
485        return folderopenIcon;
486    }
487
488    public static Image getFolderopenIconA() {
489        return folderopenIconA;
490    }
491
492    public static Image getHdfIcon() {
493        return hdfIcon;
494    }
495
496    public static Image getH4Icon() {
497        return h4Icon;
498    }
499
500    public static Image getH4IconR() {
501        return h4IconR;
502    }
503
504    public static Image getH5Icon() {
505        return h5Icon;
506    }
507
508    public static Image getH5IconR() {
509        return h5IconR;
510    }
511
512    public static Image getDatasetIcon() {
513        return datasetIcon;
514    }
515
516    public static Image getDatasetIconA() {
517        return datasetIconA;
518    }
519
520    public static Image getDatatypeIcon() {
521        return datatypeIcon;
522    }
523
524    public static Image getDatatypeIconA() {
525        return datatypeIconA;
526    }
527
528    public static Image getLinkIcon() {
529        return linkIcon;
530    }
531
532    public static Image getFileopenIcon() {
533        return fileopenIcon;
534    }
535
536    public static Image getFilesaveIcon() {
537        return filesaveIcon;
538    }
539
540    public static Image getFilenewIcon() {
541        return filenewIcon;
542    }
543
544    public static Image getFilecloseIcon() {
545        return filecloseIcon;
546    }
547
548    public static Image getPaletteIcon() {
549        return paletteIcon;
550    }
551
552    public static Image getBrightIcon() {
553        return brightIcon;
554    }
555
556    public static Image getAutocontrastIcon() {
557        return autocontrastIcon;
558    }
559
560    public static Image getImageIcon() {
561        return imageIcon;
562    }
563
564    public static Image getTableIcon() {
565        return tableIcon;
566    }
567
568    public static Image getTextIcon() {
569        return textIcon;
570    }
571
572    public static Image getImageIconA() {
573        return imageIconA;
574    }
575
576    public static Image getTableIconA() {
577        return tableIconA;
578    }
579
580    public static Image getTextIconA() {
581        return textIconA;
582    }
583
584    public static Image getZoominIcon() {
585        return zoominIcon;
586    }
587
588    public static Image getZoomoutIcon() {
589        return zoomoutIcon;
590    }
591
592    public static Image getBlankIcon() {
593        return blankIcon;
594    }
595
596    public static Image getHelpIcon() {
597        return helpIcon;
598    }
599
600    public static Image getCopyIcon() {
601        return copyIcon;
602    }
603
604    public static Image getCutIcon() {
605        return cutIcon;
606    }
607
608    public static Image getPasteIcon() {
609        return pasteIcon;
610    }
611
612    public static Image getLargeHdfIcon() {
613        return largeHdfIcon;
614    }
615
616    public static Image getPreviousIcon() {
617        return previousIcon;
618    }
619
620    public static Image getNextIcon() {
621        return nextIcon;
622    }
623
624    public static Image getFirstIcon() {
625        return firstIcon;
626    }
627
628    public static Image getLastIcon() {
629        return lastIcon;
630    }
631
632    public static Image getChartIcon() {
633        return chartIcon;
634    }
635
636    public static Image getAnimationIcon() {
637        return animationIcon;
638    }
639
640    public static Image getAppsIcon() {
641        return iconAPPS;
642    }
643
644    public static Image getUrlIcon() {
645        return iconURL;
646    }
647
648    public static Image getVideoIcon() {
649        return iconVIDEO;
650    }
651
652    public static Image getXlsIcon() {
653        return iconXLS;
654    }
655
656    public static Image getPdfIcon() {
657        return iconPDF;
658    }
659
660    public static Image getAudioIcon() {
661        return iconAUDIO;
662    }
663
664    public static Image getQuestionIcon() {
665        return questionIcon;
666    }
667
668    public static void loadIcons() {
669        InputStream s = null;
670        log.trace("loadIcons: start");
671
672        // load icon images
673
674        try {
675            s = ViewProperties.class.getResourceAsStream("icons/hdf.gif");
676            hdfIcon = new Image(null, s);
677        }
678        catch (Exception ex) {
679            hdfIcon = null;
680            log.trace("hdfIcon: null");
681        }
682
683        try {
684            s = ViewProperties.class.getResourceAsStream("icons/hdf4.gif");
685            h4Icon = new Image(null, s);
686        }
687        catch (Exception ex) {
688            h4Icon = null;
689            log.trace("h4Icon: null");
690        }
691
692        try {
693            s = ViewProperties.class.getResourceAsStream("icons/hdf4R.gif");
694            h4IconR = new Image(null, s);
695        }
696        catch (Exception ex) {
697            h4IconR = null;
698            log.trace("h4IconR: null");
699        }
700
701        try {
702            s = ViewProperties.class.getResourceAsStream("icons/hdf5.gif");
703            h5Icon = new Image(null, s);
704        }
705        catch (Exception ex) {
706            h5Icon = null;
707            log.trace("h5Icon: null");
708        }
709
710        try {
711            s = ViewProperties.class.getResourceAsStream("icons/hdf5R.gif");
712            h5IconR = new Image(null, s);
713        }
714        catch (Exception ex) {
715            h5IconR = null;
716            log.trace("h5IconR: null");
717        }
718
719        try {
720            s = ViewProperties.class.getResourceAsStream("icons/folderclose.gif");
721            foldercloseIcon = new Image(null, s);
722        }
723        catch (Exception ex) {
724            foldercloseIcon = null;
725            log.trace("foldercloseIcon: null");
726        }
727
728        try {
729            s = ViewProperties.class.getResourceAsStream("icons/foldercloseA.gif");
730            foldercloseIconA = new Image(null, s);
731        }
732        catch (Exception ex) {
733            foldercloseIconA = null;
734            log.trace("foldercloseIconA: null");
735        }
736
737        try {
738            s = ViewProperties.class.getResourceAsStream("icons/folderopen.gif");
739            folderopenIcon = new Image(null, s);
740        }
741        catch (Exception ex) {
742            folderopenIcon = null;
743            log.trace("folderopenIcon: null");
744        }
745
746        try {
747            s = ViewProperties.class.getResourceAsStream("icons/folderopenA.gif");
748            folderopenIconA = new Image(null, s);
749        }
750        catch (Exception ex) {
751            folderopenIconA = null;
752            log.trace("folderopenIconA: null");
753        }
754
755        try {
756            s = ViewProperties.class.getResourceAsStream("icons/dataset.gif");
757            datasetIcon = new Image(null, s);
758        }
759        catch (Exception ex) {
760            datasetIcon = null;
761            log.trace("datasetIcon: null");
762        }
763
764        try {
765            s = ViewProperties.class.getResourceAsStream("icons/datasetA.gif");
766            datasetIconA = new Image(null, s);
767        }
768        catch (Exception ex) {
769            datasetIconA = null;
770            log.trace("datasetIconA: null");
771        }
772
773        try {
774            s = ViewProperties.class.getResourceAsStream("icons/datatype.gif");
775            datatypeIcon = new Image(null, s);
776        }
777        catch (Exception ex) {
778            datatypeIcon = null;
779            log.trace("datatypeIcon: null");
780        }
781
782        try {
783            s = ViewProperties.class.getResourceAsStream("icons/datatypeA.gif");
784            datatypeIconA = new Image(null, s);
785        }
786        catch (Exception ex) {
787            datatypeIconA = null;
788            log.trace("datatypeIconA: null");
789        }
790
791        try {
792            s = ViewProperties.class.getResourceAsStream("icons/link.gif");
793            linkIcon = new Image(null, s);
794        }
795        catch (Exception ex) {
796            linkIcon = null;
797            log.trace("linkIcon: null");
798        }
799
800        try {
801            s = ViewProperties.class.getResourceAsStream("icons/fileopen.gif");
802            fileopenIcon = new Image(null, s);
803        }
804        catch (Exception ex) {
805            fileopenIcon = null;
806            log.trace("fileopenIcon: null");
807        }
808
809        try {
810            s = ViewProperties.class.getResourceAsStream("icons/filesave.gif");
811            filesaveIcon = new Image(null, s);
812        }
813        catch (Exception ex) {
814            filesaveIcon = null;
815            log.trace("filesaveIcon: null");
816        }
817
818        try {
819            s = ViewProperties.class.getResourceAsStream("icons/filenew.gif");
820            filenewIcon = new Image(null, s);
821        }
822        catch (Exception ex) {
823            filenewIcon = null;
824            log.trace("filenewIcon: null");
825        }
826
827        try {
828            s = ViewProperties.class.getResourceAsStream("icons/fileclose.gif");
829            filecloseIcon = new Image(null, s);
830        }
831        catch (Exception ex) {
832            filecloseIcon = null;
833            log.trace("filecloseIcon: null");
834        }
835
836        try {
837            s = ViewProperties.class.getResourceAsStream("icons/palette.gif");
838            paletteIcon = new Image(null, s);
839        }
840        catch (Exception ex) {
841            paletteIcon = null;
842            log.trace("paletteIcon: null");
843        }
844
845        try {
846            s = ViewProperties.class.getResourceAsStream("icons/brightness.gif");
847            brightIcon = new Image(null, s);
848        }
849        catch (Exception ex) {
850            brightIcon = null;
851            log.trace("brightIcon: null");
852        }
853
854        try {
855            s = ViewProperties.class.getResourceAsStream("icons/autocontrast.gif");
856            autocontrastIcon = new Image(null, s);
857        }
858        catch (Exception ex) {
859            autocontrastIcon = null;
860            log.trace("autocontrastIcon: null");
861        }
862
863        try {
864            s = ViewProperties.class.getResourceAsStream("icons/image.gif");
865            imageIcon = new Image(null, s);
866        }
867        catch (Exception ex) {
868            imageIcon = null;
869            log.trace("imageIcon: null");
870        }
871
872        try {
873            s = ViewProperties.class.getResourceAsStream("icons/imageA.gif");
874            imageIconA = new Image(null, s);
875        }
876        catch (Exception ex) {
877            imageIconA = null;
878            log.trace("imageIconA: null");
879        }
880
881        try {
882            s = ViewProperties.class.getResourceAsStream("icons/table.gif");
883            tableIcon = new Image(null, s);
884        }
885        catch (Exception ex) {
886            tableIcon = null;
887            log.trace("tableIcon: null");
888        }
889
890        try {
891            s = ViewProperties.class.getResourceAsStream("icons/tableA.gif");
892            tableIconA = new Image(null, s);
893        }
894        catch (Exception ex) {
895            tableIconA = null;
896            log.trace("tableIconA: null");
897        }
898
899        try {
900            s = ViewProperties.class.getResourceAsStream("icons/text.gif");
901            textIcon = new Image(null, s);
902        }
903        catch (Exception ex) {
904            textIcon = null;
905            log.trace("textIcon: null");
906        }
907
908        try {
909            s = ViewProperties.class.getResourceAsStream("icons/textA.gif");
910            textIconA = new Image(null, s);
911        }
912        catch (Exception ex) {
913            textIconA = null;
914            log.trace("textIconA: null");
915        }
916
917        try {
918            s = ViewProperties.class.getResourceAsStream("icons/zoomin.gif");
919            zoominIcon = new Image(null, s);
920        }
921        catch (Exception ex) {
922            zoominIcon = null;
923            log.trace("iconAUzoominIconDIO: null");
924        }
925
926        try {
927            s = ViewProperties.class.getResourceAsStream("icons/zoomout.gif");
928            zoomoutIcon = new Image(null, s);
929        }
930        catch (Exception ex) {
931            zoomoutIcon = null;
932            log.trace("zoomoutIcon: null");
933        }
934
935        try {
936            s = ViewProperties.class.getResourceAsStream("icons/blank.gif");
937            blankIcon = new Image(null, s);
938        }
939        catch (Exception ex) {
940            blankIcon = null;
941            log.trace("blankIcon: null");
942        }
943
944        try {
945            s = ViewProperties.class.getResourceAsStream("icons/help.gif");
946            helpIcon = new Image(null, s);
947        }
948        catch (Exception ex) {
949            helpIcon = null;
950            log.trace("helpIcon: null");
951        }
952
953        try {
954            s = ViewProperties.class.getResourceAsStream("icons/copy.gif");
955            copyIcon = new Image(null, s);
956        }
957        catch (Exception ex) {
958            copyIcon = null;
959            log.trace("copyIcon: null");
960        }
961
962        try {
963            s = ViewProperties.class.getResourceAsStream("icons/cut.gif");
964            cutIcon = new Image(null, s);
965        }
966        catch (Exception ex) {
967            cutIcon = null;
968            log.trace("cutIcon: null");
969        }
970
971        try {
972            s = ViewProperties.class.getResourceAsStream("icons/paste.gif");
973            pasteIcon = new Image(null, s);
974        }
975        catch (Exception ex) {
976            pasteIcon = null;
977            log.trace("pasteIcon: null");
978        }
979
980        try {
981            s = ViewProperties.class.getResourceAsStream("icons/hdf_large.gif");
982            largeHdfIcon = new Image(null, s);
983        }
984        catch (Exception ex) {
985            largeHdfIcon = null;
986            log.trace("largeHdfIcon: null");
987        }
988
989        try {
990            s = ViewProperties.class.getResourceAsStream("icons/previous.gif");
991            previousIcon = new Image(null, s);
992        }
993        catch (Exception ex) {
994            previousIcon = null;
995            log.trace("previousIcon: null");
996        }
997
998        try {
999            s = ViewProperties.class.getResourceAsStream("icons/next.gif");
1000            nextIcon = new Image(null, s);
1001        }
1002        catch (Exception ex) {
1003            nextIcon = null;
1004            log.trace("nextIcon: null");
1005        }
1006
1007        try {
1008            s = ViewProperties.class.getResourceAsStream("icons/first.gif");
1009            firstIcon = new Image(null, s);
1010        }
1011        catch (Exception ex) {
1012            firstIcon = null;
1013            log.trace("firstIcon: null");
1014        }
1015
1016        try {
1017            s = ViewProperties.class.getResourceAsStream("icons/last.gif");
1018            lastIcon = new Image(null, s);
1019        }
1020        catch (Exception ex) {
1021            lastIcon = null;
1022            log.trace("lastIcon: null");
1023        }
1024
1025        try {
1026            s = ViewProperties.class.getResourceAsStream("icons/chart.gif");
1027            chartIcon = new Image(null, s);
1028        }
1029        catch (Exception ex) {
1030            chartIcon = null;
1031            log.trace("chartIcon: null");
1032        }
1033
1034        try {
1035            s = ViewProperties.class.getResourceAsStream("icons/animation.gif");
1036            animationIcon = new Image(null, s);
1037        }
1038        catch (Exception ex) {
1039            animationIcon = null;
1040            log.trace("animationIcon: null");
1041        }
1042
1043        try {
1044            s = ViewProperties.class.getResourceAsStream("icons/question.gif");
1045            questionIcon = new Image(null, s);
1046        }
1047        catch (Exception ex) {
1048            questionIcon = null;
1049            log.trace("questionIcon: null");
1050        }
1051
1052        try {
1053            s = ViewProperties.class.getResourceAsStream("icons/audio.gif");
1054            iconAUDIO = new Image(null, s);
1055        }
1056        catch (Exception ex) {
1057            iconAUDIO = null;
1058            log.trace("iconAUDIO: null");
1059        }
1060
1061        try {
1062            s = ViewProperties.class.getResourceAsStream("icons/xls.gif");
1063            iconXLS = new Image(null, s);
1064        }
1065        catch (Exception ex) {
1066            iconXLS = null;
1067            log.trace("iconXLS: null");
1068        }
1069
1070        try {
1071            s = ViewProperties.class.getResourceAsStream("icons/pdf.gif");
1072            iconPDF = new Image(null, s);
1073        }
1074        catch (Exception ex) {
1075            iconPDF = null;
1076            log.trace("iconPDF: null");
1077        }
1078
1079        try {
1080            s = ViewProperties.class.getResourceAsStream("icons/apps.gif");
1081            iconAPPS = new Image(null, s);
1082        }
1083        catch (Exception ex) {
1084            iconAPPS = null;
1085            log.trace("iconAPPS: null");
1086        }
1087
1088        try {
1089            s = ViewProperties.class.getResourceAsStream("icons/url.gif");
1090            iconURL = new Image(null, s);
1091        }
1092        catch (Exception ex) {
1093            iconURL = null;
1094            log.trace("iconURL: null");
1095        }
1096
1097        try {
1098            s = ViewProperties.class.getResourceAsStream("icons/video.gif");
1099            iconVIDEO = new Image(null, s);
1100        }
1101        catch (Exception ex) {
1102            iconVIDEO = null;
1103            log.trace("iconVIDEO: null");
1104        }
1105        log.trace("loadIcons: finish");
1106    }
1107
1108    /**
1109     * Load user properties from property file
1110     *
1111     * @throws IOException
1112     *             if a failure occurred
1113     */
1114    @Override
1115    @SuppressWarnings({ "rawtypes", "unchecked" })
1116    public void load() throws IOException {
1117        super.load();
1118
1119        log.trace("load user properties: begin");
1120
1121        if (propertyFile == null)
1122            return;
1123
1124        String propVal = null;
1125
1126        // add default module.
1127        log.trace("load user properties: add default modules");
1128        String[] moduleKeys = { "module.treeview", "module.metadataview", "module.tableview",
1129                "module.imageview", "module.paletteview" };
1130        Vector[] moduleList = { moduleListTreeView, moduleListMetaDataView, moduleListTableView,
1131                moduleListImageView, moduleListPaletteView };
1132        String[] moduleNames = { DEFAULT_MODULE_TEXT, DEFAULT_MODULE_TEXT, DEFAULT_MODULE_TEXT,
1133                DEFAULT_MODULE_TEXT, DEFAULT_MODULE_TEXT };
1134
1135        // add default implementation of modules
1136        log.trace("load user properties: modules");
1137        for (int i = 0; i < moduleNames.length; i++) {
1138            if (!moduleList[i].contains(moduleNames[i]))
1139                moduleList[i].addElement(moduleNames[i]);
1140            log.trace("load: add default moduleList[{}] is {}", i, moduleNames[i]);
1141        }
1142        log.trace("load Ext Class modules");
1143        if (extClassLoader == null) loadExtClass();
1144
1145        // set default selection of data views
1146        log.trace("load user properties: set default selection of data views");
1147        for (int i = 0; i < moduleNames.length; i++) {
1148            Vector<String> theList = moduleList[i];
1149            propVal = getString(moduleKeys[i]);
1150            log.trace("load: default theList is {}", Arrays.toString(theList.toArray()));
1151
1152            if ((propVal != null) && (propVal.length() > 0)) {
1153                // set default to the module specified in property file
1154                if (theList.size() > 1) {
1155                    if (theList.contains(propVal))
1156                        theList.remove(propVal);
1157                    theList.add(0, propVal);
1158                }
1159                log.trace("load user properties: module[{}]={}", i, propVal);
1160            }
1161            else {
1162                // use default module
1163                if (theList.size() > 1) {
1164                    if (theList.contains(moduleNames[i]))
1165                        theList.remove(moduleNames[i]);
1166                    theList.add(0, moduleNames[i]);
1167                }
1168                log.trace("load user properties: default module[{}]={}", i, moduleNames[i]);
1169            }
1170            log.trace("load: final theList is {}", Arrays.toString(theList.toArray()));
1171        }
1172
1173        // add fileformat modules
1174        log.trace("load user properties: fileformat modules");
1175        String[] local_enum = this.preferenceNames();
1176        String fExt = null;
1177        for (String theKey : local_enum) {
1178            log.trace("load: add prop {}", theKey);
1179            if (theKey.startsWith("module.fileformat")) {
1180                fExt = theKey.substring(18);
1181                try {
1182                    // enables use of JHDF5 in JNLP (Web Start) applications,
1183                    // the system class loader with reflection first.
1184                    String className = getString(theKey);
1185                    Class theClass = null;
1186                    try {
1187                        theClass = Class.forName(className);
1188                    }
1189                    catch (Exception ex) {
1190                        try {
1191                            theClass = extClassLoader.loadClass(className);
1192                        }
1193                        catch (Exception ex2) {
1194                            log.debug("load: extClassLoader.loadClass({}) failed", className, ex2);
1195                        }
1196                    }
1197
1198                    Object theObject = theClass.newInstance();
1199                    if (theObject instanceof FileFormat) {
1200                        FileFormat.addFileFormat(fExt, (FileFormat) theObject);
1201                    }
1202                }
1203                catch (Throwable err) {
1204                    log.debug("load: load file format failed", err);
1205                }
1206            }
1207        }
1208
1209        propVal = getString("users.guide");
1210        if (!isDefault("users.guide"))
1211            usersGuide = propVal;
1212
1213        propVal = getString("image.contrast");
1214        if (!isDefault("image.contrast"))
1215            isAutoContrast = ("auto".equalsIgnoreCase(propVal));
1216
1217        showImageValues = getBoolean("image.showvalues");
1218
1219        propVal = getString("file.mode");
1220        if (!isDefault("file.mode"))
1221            isReadOnly = ("r".equalsIgnoreCase(propVal));
1222
1223        EarlyLib = getString("lib.lowversion");
1224
1225        LateLib = getString("lib.highversion");
1226
1227        convertEnum = getBoolean("enum.conversion");
1228
1229        showRegRefValues = getBoolean("regref.showvalues");
1230
1231        isIndexBase1 = getBoolean("index.base1");
1232
1233        propVal = getString("data.delimiter");
1234        if (!isDefault("data.delimiter"))
1235            delimiter = propVal;
1236
1237        propVal = getString("image.origin");
1238        if (!isDefault("image.origin"))
1239            origin = propVal;
1240
1241        propVal = getString("h5file.indexType");
1242        if (!isDefault("h5file.indexType"))
1243            indexType = propVal;
1244
1245        propVal = getString("h5file.indexOrder");
1246        if (!isDefault("h5file.indexOrder"))
1247            indexOrder = propVal;
1248
1249        propVal = getString("h4toh5.converter");
1250        if (!isDefault("h4toh5.converter"))
1251            h4toh5 = propVal;
1252
1253        propVal = getString("work.dir");
1254        if (!isDefault("work.dir"))
1255            workDir = propVal;
1256
1257        propVal = getString("file.extension");
1258        if (!isDefault("file.extension")) {
1259            fileExt = propVal;
1260            FileFormat.addFileExtension(fileExt);
1261        }
1262
1263        fontSize = getInt("font.size");
1264
1265        propVal = getString("font.type");
1266        if (!isDefault("font.type"))
1267            fontType = propVal.trim();
1268
1269        max_members = getInt("max.members");
1270
1271        // load the most recent file list from the property file
1272        log.trace("load user properties: most recent file list");
1273        String theFile = null;
1274        for (int i = 0; i < MAX_RECENT_FILES; i++) {
1275            theFile = getString("recent.file" + i);
1276            if ((theFile != null) && !recentFiles.contains(theFile)) {
1277                if (theFile.startsWith("http://") || theFile.startsWith("ftp://") || (new File(theFile)).exists()) {
1278                    recentFiles.addElement(theFile);
1279                }
1280            }
1281            // else {
1282            // this.remove("recent.file" + i);
1283            // }
1284        }
1285
1286        // load the most recent palette file list from the property file
1287        log.trace("load user properties: most recent palette file list");
1288        theFile = null;
1289        for (int i = 0; i < MAX_RECENT_FILES; i++) {
1290            theFile = getString("palette.file" + i);
1291            if (theFile != null) theFile = theFile.trim();
1292
1293            if ((theFile != null && theFile.length() > 0) && !paletteList.contains(theFile)) {
1294                if ((new File(theFile)).exists()) {
1295                    paletteList.addElement(theFile);
1296                }
1297            }
1298            // else {
1299            // this.remove("palette.file" + i);
1300            // }
1301        }
1302
1303        // load srb account
1304        // log.trace("load user properties: srb account");
1305        // propVal = null;
1306        // String srbaccount[] = new String[7];
1307        // for (int i = 0; i < MAX_RECENT_FILES; i++) {
1308        // if (null == (srbaccount[0] = getString("srbaccount" + i + ".host")))
1309        // continue;
1310        //
1311        // if (null == (srbaccount[1] = getString("srbaccount" + i + ".port")))
1312        // continue;
1313        //
1314        // if (null == (srbaccount[2] = getString("srbaccount" + i + ".user")))
1315        // continue;
1316        //
1317        // if (null == (srbaccount[3] = getString("srbaccount" + i + ".password")))
1318        // continue;
1319        //
1320        // if (null == (srbaccount[4] = getString("srbaccount" + i + ".home")))
1321        // continue;
1322        //
1323        // if (null == (srbaccount[5] = getString("srbaccount" + i + ".domain")))
1324        // continue;
1325        //
1326        // if (null == (srbaccount[6] = getString("srbaccount" + i + ".resource")))
1327        // continue;
1328        //
1329        // srbAccountList.add(srbaccount);
1330        // srbaccount = new String[7];
1331        // }
1332        log.trace("load: finish");
1333    }
1334
1335    /**
1336     * Save user properties into property file
1337     *
1338     * @throws IOException
1339     *             if a failure occurred
1340     */
1341    @Override
1342    public void save() throws IOException {
1343        log.trace("save user properties: begin");
1344        if (propertyFile == null)
1345            return;
1346
1347        // update data saving options
1348        log.trace("save user properties: update data saving options");
1349        if (delimiter == null)
1350            setDefault("data.delimiter", DELIMITER_TAB);
1351        else
1352            setValue("data.delimiter", delimiter);
1353
1354        if (origin == null)
1355            setDefault("image.origin", ORIGIN_UL);
1356        else
1357            setValue("image.origin", origin);
1358
1359        if (indexType != null) setValue("h5file.indexType", indexType);
1360
1361        if (indexOrder != null) setValue("h5file.indexOrder", indexOrder);
1362
1363        if (usersGuide != null) setValue("users.guide", usersGuide);
1364
1365        if (workDir != null) setValue("work.dir", workDir);
1366
1367        if (fileExt != null) setValue("file.extension", fileExt);
1368
1369        if (h4toh5 != null) setValue("h4toh5.converter", h4toh5);
1370
1371        setValue("font.size", fontSize);
1372
1373        if (fontType != null) setValue("font.type", fontType);
1374
1375        setValue("max.members", max_members);
1376
1377        if (isAutoContrast)
1378            setValue("image.contrast", "auto");
1379        else
1380            setValue("image.contrast", "general");
1381
1382        setValue("image.showvalues", showImageValues);
1383
1384        if (isReadOnly)
1385            setValue("file.mode", "r");
1386        else
1387            setValue("file.mode", "rw");
1388
1389        log.trace("save user properties: lib.lowversion={}", EarlyLib);
1390        setValue("lib.lowversion", EarlyLib);
1391        log.trace("save user properties: lib.highversion={}", LateLib);
1392        setValue("lib.highversion", LateLib);
1393
1394        setValue("enum.conversion", convertEnum);
1395        setValue("regref.showvalues", showRegRefValues);
1396        setValue("index.base1", isIndexBase1);
1397
1398        // save the list of most recent files
1399        log.trace("save user properties: most recent files");
1400        String theFile;
1401        int size = recentFiles.size();
1402        int minSize = Math.min(size, MAX_RECENT_FILES);
1403        log.trace("save user properties: most recent files size={}", size);
1404        for (int i = 0; i < minSize; i++) {
1405            theFile = recentFiles.elementAt(i);
1406            if ((theFile != null) && (theFile.length() > 0)) setValue("recent.file" + i, theFile);
1407        }
1408
1409        // save the list of most recent palette files
1410        log.trace("save user properties: most recent palette files");
1411        size = paletteList.size();
1412        minSize = Math.min(size, MAX_RECENT_FILES);
1413        for (int i = 0; i < minSize; i++) {
1414            theFile = paletteList.elementAt(i);
1415            if ((theFile != null) && (theFile.length() > 0)) setValue("palette.file" + i, theFile);
1416        }
1417
1418        // save srb account
1419        // log.trace("save user properties: srb account");
1420        // String srbaccount[] = null;
1421        // size = srbAccountList.size();
1422        // minSize = Math.min(size, MAX_RECENT_FILES);
1423        // for (int i = 0; i < minSize; i++) {
1424        // srbaccount = srbAccountList.get(i);
1425        // if ((srbaccount[0] != null) && (srbaccount[1] != null) && (srbaccount[2] !=
1426        // null)
1427        // && (srbaccount[3] != null) && (srbaccount[4] != null) && (srbaccount[5] !=
1428        // null)
1429        // && (srbaccount[6] != null)) {
1430        // setValue("srbaccount" + i + ".host", srbaccount[0]);
1431        // setValue("srbaccount" + i + ".port", srbaccount[1]);
1432        // setValue("srbaccount" + i + ".user", srbaccount[2]);
1433        // setValue("srbaccount" + i + ".password", srbaccount[3]);
1434        // setValue("srbaccount" + i + ".home", srbaccount[4]);
1435        // setValue("srbaccount" + i + ".domain", srbaccount[5]);
1436        // setValue("srbaccount" + i + ".resource", srbaccount[6]);
1437        // }
1438        // }
1439
1440        // save default modules
1441        log.trace("save user properties: default modules");
1442        String moduleName = moduleListTreeView.elementAt(0);
1443        if ((moduleName != null) && (moduleName.length() > 0)) setValue("module.treeview", moduleName);
1444        log.trace("save user properties: module.treeview={}", moduleName);
1445
1446        moduleName = moduleListMetaDataView.elementAt(0);
1447        if ((moduleName != null) && (moduleName.length() > 0)) setValue("module.metadataview", moduleName);
1448        log.trace("save user properties: module.metadataview={}", moduleName);
1449
1450        moduleName = moduleListTableView.elementAt(0);
1451        if ((moduleName != null) && (moduleName.length() > 0)) setValue("module.tableview", moduleName);
1452        log.trace("save user properties: module.tableview={}", moduleName);
1453
1454        moduleName = moduleListImageView.elementAt(0);
1455        if ((moduleName != null) && (moduleName.length() > 0)) setValue("module.imageview", moduleName);
1456        log.trace("save user properties: module.imageview={}", moduleName);
1457
1458        moduleName = moduleListPaletteView.elementAt(0);
1459        if ((moduleName != null) && (moduleName.length() > 0)) setValue("module.paletteview", moduleName);
1460        log.trace("save user properties: module.paletteview={}", moduleName);
1461
1462        // save the current supported fileformat
1463        log.trace("save user properties: supported fileformat");
1464        Enumeration<?> keys = FileFormat.getFileFormatKeys();
1465        String theKey = null;
1466        while (keys.hasMoreElements()) {
1467            theKey = (String) keys.nextElement();
1468            FileFormat theformat = FileFormat.getFileFormat(theKey);
1469            setValue("module.fileformat." + theKey, theformat.getClass().getName());
1470        }
1471
1472        super.save();
1473        log.trace("save user properties: end");
1474    }
1475
1476    /** @return the name of the user property file */
1477    public static String getPropertyFile() {
1478        return propertyFile;
1479    }
1480
1481    /** @return the default work directory, where the open file starts. */
1482    public static String getWorkDir() {
1483        String workPath = workDir;
1484        log.trace("getWorkDir: workDir={}", workDir);
1485        if (workPath == null) {
1486            workPath = System.getProperty("hdfview.workdir");
1487            log.trace("getWorkDir: hdfview.workdir={}", workPath);
1488            if (workPath == null) {
1489                workPath = System.getProperty("user.home");
1490            }
1491        }
1492        log.trace("getWorkDir: final workPath={}", workPath);
1493        return workPath;
1494    }
1495
1496    /** @return the maximum number of the most recent file */
1497    public static int getMaxRecentFiles() {
1498        return MAX_RECENT_FILES;
1499    }
1500
1501    /** @return the path of the HDFView users guide */
1502    public static String getUsersGuide() {
1503        return usersGuide;
1504    };
1505
1506    /** @return the delimiter of data values */
1507    public static String getDataDelimiter() {
1508        return delimiter;
1509    }
1510
1511    /** @return the image origin */
1512    public static String getImageOrigin() {
1513        return origin;
1514    }
1515
1516    /** @return the default index type for display */
1517    public static String getIndexType() {
1518        return indexType;
1519    }
1520
1521    /** @return the default index order for display */
1522    public static String getIndexOrder() {
1523        return indexOrder;
1524    }
1525
1526    /** @return the font size */
1527    public static int getFontSize() {
1528        return fontSize;
1529    }
1530
1531    /** @return the font type */
1532    public static String getFontType() {
1533        return fontType;
1534    }
1535
1536    /** @return the file extensions of supported file formats */
1537    public static String getFileExtension() {
1538        return fileExt;
1539    }
1540
1541    /** sets the font size
1542     *
1543     * @param fsize
1544     *            the font size
1545     */
1546    public static void setFontSize(int fsize) {
1547        fontSize = (fsize / 2) * 2;
1548
1549        if (fontSize < 8) {
1550            fontSize = 8;
1551        }
1552    }
1553
1554    /** sets the font type
1555     *
1556     * @param ftype
1557     *            the font type
1558     */
1559    public static void setFontType(String ftype) {
1560        if (ftype != null) {
1561            fontType = ftype.trim();
1562        }
1563    }
1564
1565    /** @return the path of the H5toH5 converter */
1566    public static String getH4toH5() {
1567        return h4toh5;
1568    }
1569
1570    /** @return the list of most recent files */
1571    public static Vector<String> getMRF() {
1572        return recentFiles;
1573    }
1574
1575    /** @return the list of palette files */
1576    public static Vector<String> getPaletteList() {
1577        return paletteList;
1578    }
1579
1580    public static Vector<String[]> getSrbAccount() {
1581        return srbAccountList;
1582    }
1583
1584    /** @return a list of treeview modules */
1585    public static Vector<String> getTreeViewList() {
1586        return moduleListTreeView;
1587    }
1588
1589    /** @return a list of metadataview modules */
1590    public static Vector<String> getMetaDataViewList() {
1591        return moduleListMetaDataView;
1592    }
1593
1594    /** @return a list of tableview modules */
1595    public static Vector<String> getTableViewList() {
1596        return moduleListTableView;
1597    }
1598
1599    /** @return a list of imageview modules */
1600    public static Vector<String> getImageViewList() {
1601        return moduleListImageView;
1602    }
1603
1604    /** @return a list of paletteview modules */
1605    public static Vector<String> getPaletteViewList() {
1606        return moduleListPaletteView;
1607    }
1608
1609    /** @return a list of helpview modules */
1610    public static Vector<String> getHelpViewList() {
1611        return moduleListHelpView;
1612    }
1613
1614    /** set the path of H5View User's guide
1615     *
1616     * @param str
1617     *            the path
1618     */
1619    public static void setUsersGuide(String str) {
1620        if ((str == null) || (str.length() <= 0)) {
1621            return;
1622        }
1623        usersGuide = str;
1624    }
1625
1626    /** set the path of the H4 to H5 converter
1627     *
1628     * @param tool
1629     *            the path of the H4 to H5 converter
1630     */
1631    public static void setH4toH5(String tool) {
1632        h4toh5 = tool;
1633    }
1634
1635    /** set the path of the default work directory
1636     *
1637     * @param wDir
1638     *            the default work directory
1639     */
1640    public static void setWorkDir(String wDir) {
1641        log.trace("ViewProperties:setWorkDir wDir={}", wDir);
1642        workDir = wDir;
1643    }
1644
1645    /** set the file extension
1646     *
1647     * @param ext
1648     *            the file extension
1649     */
1650    public static void setFileExtension(String ext) {
1651        fileExt = ext;
1652    }
1653
1654    /** set the delimiter of data values
1655     *
1656     * @param delim
1657     *            the delimiter of data values
1658     */
1659    public static void setDataDelimiter(String delim) {
1660        delimiter = delim;
1661    }
1662
1663    /** set the image origin
1664     *
1665     * @param o
1666     *            the image origin
1667     */
1668    public static void setImageOrigin(String o) {
1669        origin = o;
1670    }
1671
1672    /** set the index type
1673     *
1674     * @param idxType
1675     *            the index type
1676     */
1677    public static void setIndexType(String idxType) {
1678        indexType = idxType;
1679    }
1680
1681    /** set the index order
1682     *
1683     * @param idxOrder
1684     *            the index order
1685     */
1686    public static void setIndexOrder(String idxOrder) {
1687        indexOrder = idxOrder;
1688    }
1689
1690    /**
1691     * Current Java applications such as HDFView cannot handle files with large
1692     * number of objects such as 1,000,000 objects. setMaxMembers() sets the
1693     * maximum number of objects that will be loaded into memory.
1694     *
1695     * @param n
1696     *            the maximum number of objects to load into memory
1697     */
1698    public static void setMaxMembers(int n) {
1699        max_members = n;
1700    }
1701
1702    /**
1703     * Current Java applications such as HDFView cannot handle files with large
1704     * number of objects such as 1,000,000 objects. setStartMember() sets the
1705     * starting index of objects that will be loaded into memory.
1706     *
1707     * @param idx
1708     *            the maximum number of objects to load into memory
1709     */
1710    public static void setStartMembers(int idx) {
1711        if (idx < 0) {
1712            idx = 0;
1713        }
1714
1715        start_members = idx;
1716    }
1717
1718    /**
1719     * Current Java applications such as HDFView cannot handle files with large
1720     * number of objects such as 1,000,000 objects. getMaxMembers() returns the
1721     * maximum number of objects that will be loaded into memory.
1722     *
1723     * @return the maximum members
1724     */
1725    public static int getMaxMembers() {
1726        if (max_members < 0)
1727            return Integer.MAX_VALUE; // load the whole file
1728
1729        return max_members;
1730    }
1731
1732    /**
1733     * Current Java applications such as HDFView cannot handle files with large
1734     * number of objects such as 1,000,000 objects. getStartMembers() returns the
1735     * starting index of objects that will be loaded into memory.
1736     *
1737     * @return the start members
1738     */
1739    public static int getStartMembers() {
1740        return start_members;
1741    }
1742
1743    /**
1744     * Returns true if auto contrast is used in image processing.
1745     *
1746     * @return true if auto contrast is used in image processing; otherwise,
1747     *         returns false.
1748     */
1749    public static boolean isAutoContrast() {
1750        return isAutoContrast;
1751    }
1752
1753    /**
1754     * Returns true if "show image values" is set.
1755     *
1756     * @return true if "show image values" is set; otherwise, returns false.
1757     */
1758    public static boolean showImageValues() {
1759        return showImageValues;
1760    }
1761
1762    /**
1763     * Set the flag to indicate if auto contrast is used in image process.
1764     *
1765     * @param b
1766     *            the flag to indicate if auto contrast is used in image
1767     *            process.
1768     */
1769    public static void setAutoContrast(boolean b) {
1770        isAutoContrast = b;
1771    }
1772
1773    /**
1774     * Set the flag to indicate if "show image values" is set.
1775     *
1776     * @param b
1777     *            the flag to indicate if if "show image values" is set.
1778     */
1779    public static void setShowImageValue(boolean b) {
1780        showImageValues = b;
1781    }
1782
1783    /**
1784     * Returns true if default file access is read only.
1785     *
1786     * @return true if default file access is read only; otherwise, returns
1787     *         false.
1788     */
1789    public static boolean isReadOnly() {
1790        return isReadOnly;
1791    }
1792
1793    /**
1794     * Set the flag to indicate if default file access is read only.
1795     *
1796     * @param b
1797     *            the flag to indicate if default file access is read only.
1798     */
1799    public static void setReadOnly(boolean b) {
1800        isReadOnly = b;
1801    }
1802
1803    /**
1804     * Returns value of default lib version for the earliest.
1805     *
1806     * @return value of default lib version for the earliest.
1807     */
1808    public static String getEarlyLib() {
1809        return EarlyLib;
1810    }
1811
1812    /**
1813     * Set the value of default lib version for the earliest.
1814     *
1815     * @param vers
1816     *            the value of default lib version for the earliest.
1817     */
1818    public static void setEarlyLib(String vers) {
1819        EarlyLib = vers;
1820    }
1821
1822    /**
1823     * Returns value of default lib version for the latest.
1824     *
1825     * @return value of default lib version for the latest.
1826     */
1827    public static String getLateLib() {
1828        return LateLib;
1829    }
1830
1831    /**
1832     * Set the value of default lib version for the latest.
1833     *
1834     * @param vers
1835     *            the value of default lib version for the latest.
1836     */
1837    public static void setLateLib(String vers) {
1838        LateLib = vers;
1839    }
1840
1841    /**
1842     * @return the convertEnum
1843     */
1844    public static boolean isConvertEnum() {
1845        return convertEnum;
1846    }
1847
1848    /**
1849     * Returns true if "show regref values" is set.
1850     *
1851     * @return true if "show regref values" is set; otherwise, returns false.
1852     */
1853    public static boolean showRegRefValues() {
1854        return showRegRefValues;
1855    }
1856
1857    /**
1858     * @return the isIndexBase1
1859     */
1860    public static boolean isIndexBase1() {
1861        return isIndexBase1;
1862    }
1863
1864    /**
1865     * @param convertEnum
1866     *            the convertEnum to set
1867     */
1868    public static void setConvertEnum(boolean convertEnum) {
1869        ViewProperties.convertEnum = convertEnum;
1870    }
1871
1872    /**
1873     * Set the flag to indicate if "show RegRef values" is set.
1874     *
1875     * @param b
1876     *            the flag to indicate if if "show RegRef values" is set.
1877     */
1878    public static void setShowRegRefValue(boolean b) {
1879        showRegRefValues = b;
1880    }
1881
1882    /**
1883     * Set the flag to indicate if IndexBase should start at 1.
1884     *
1885     * @param b
1886     *            the flag to indicate if IndexBase should start at 1.
1887     */
1888    public static void setIndexBase1(boolean b) {
1889        ViewProperties.isIndexBase1 = b;
1890    }
1891
1892    /**
1893     * Sets the list of most recently accessed files.
1894     *
1895     * @param recentFilesList
1896     *               The list of most recently accessed files.
1897     */
1898    public static void setRecentFiles(Vector<String> recentFilesList) {
1899        recentFiles = recentFilesList;
1900    }
1901}