    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 hdf.view.ViewProperties.DataViewType;
    018import hdf.view.ImageView.ImageViewFactory;
    019import hdf.view.MetaDataView.MetaDataViewFactory;
    020import hdf.view.PaletteView.PaletteViewFactory;
    021import hdf.view.TableView.TableViewFactory;
    022import hdf.view.TreeView.TreeViewFactory;
    023
    024/**
    025 * Following the Abstract Factory Pattern, represents a class to produce
    026 * different types of DataView factory classes depending on the given
    027 * DataViewType enum value.
    028 *
    029 * @author jhenderson
    030 * @version 1.0 4/17/2018
    031 */
    032public class DataViewFactoryProducer {
    033
    034    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(DataViewFactoryProducer.class);
    035
    036    public static DataViewFactory getFactory(DataViewType viewType) {
    037        log.trace("getFactory(): start");
    038
    039        if (viewType == DataViewType.TABLE) {
    040            log.trace("getFactory(): returning TableView factory instance");
    041            log.trace("getFactory(): finish");
    042
    043            return new TableViewFactory();
    044        }
    045        else if (viewType == DataViewType.IMAGE) {
    046            log.trace("getFactory(): returning ImageView factory instance");
    047            log.trace("getFactory(): finish");
    048
    049            return new ImageViewFactory();
    050        }
    051        else if (viewType == DataViewType.PALETTE) {
    052            log.trace("getFactory(): returning PaletteView factory instance");
    053            log.trace("getFactory(): finish");
    054
    055            return new PaletteViewFactory();
    056        }
    057        else if (viewType == DataViewType.METADATA) {
    058            log.trace("getFactory(): returning MetaDataView factory instance");
    059            log.trace("getFactory(): finish");
    060
    061            return new MetaDataViewFactory();
    062        }
    063        else if (viewType == DataViewType.TREEVIEW) {
    064            log.trace("getFactory(): returning TreeView factory instance");
    065            log.trace("getFactory(): finish");
    066
    067            return new TreeViewFactory();
    068        }
    069
    070        log.trace("getFactory(): no suitable factory class found");
    071        log.trace("getFactory(): finish");
    072
    073        return null;
    074    }
    075}