001/*
002 * This file is part of McIDAS-V
003 *
004 * Copyright 2007-2024
005 * Space Science and Engineering Center (SSEC)
006 * University of Wisconsin - Madison
007 * 1225 W. Dayton Street, Madison, WI 53706, USA
008 * https://www.ssec.wisc.edu/mcidas/
009 * 
010 * All Rights Reserved
011 * 
012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
013 * some McIDAS-V source code is based on IDV and VisAD source code.  
014 * 
015 * McIDAS-V is free software; you can redistribute it and/or modify
016 * it under the terms of the GNU Lesser Public License as published by
017 * the Free Software Foundation; either version 3 of the License, or
018 * (at your option) any later version.
019 * 
020 * McIDAS-V is distributed in the hope that it will be useful,
021 * but WITHOUT ANY WARRANTY; without even the implied warranty of
022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023 * GNU Lesser Public License for more details.
024 * 
025 * You should have received a copy of the GNU Lesser Public License
026 * along with this program.  If not, see https://www.gnu.org/licenses/.
027 */
028
029package edu.wisc.ssec.mcidasv.data;
030
031import ucar.unidata.util.LogUtil;
032
033
034import ucar.unidata.util.Misc;
035import ucar.unidata.xml.XmlUtil;
036
037import ucar.unidata.data.*;
038
039
040import visad.*;
041
042import visad.georef.*;
043
044import java.rmi.RemoteException;
045
046import java.util.ArrayList;
047import java.util.Enumeration;
048import java.util.Hashtable;
049import java.util.List;
050import java.util.Vector;
051
052
053/**
054 * A data choice that simply holds a reference to a visad.Data object
055 *
056 * @author IDV development team
057 * @version $Revision$
058 */
059public class ComboDataChoice extends DataChoice {
060    private static final List<DataCategory> CATEGORIES = 
061        DataCategory.parseCategories("MultiSpectral;IMAGE;");
062
063    /** The data */
064    private Data data;
065
066
067    /**
068     *  The bean constructor. We need this for xml decoding.
069     */
070    public ComboDataChoice() {}
071
072
073    /**
074     * Create a new DataChoice, using the state of the given DataChoice to
075     * initialize the new object.
076     *
077     * @param other      The other data choice.
078     */
079    public ComboDataChoice(ComboDataChoice other) {
080        super(other);
081        this.data = other.data;
082    }
083
084    /**
085     * Create a new DataChoice with a random identifier.
086     *
087     * @param name Short name of this choice.
088     * @param categories List of {@link DataCategory DataCategories}.
089     * @param props Properties for this data choice. {@code null} is allowed.
090     */
091    public ComboDataChoice(String name, List categories, Hashtable props) {
092        super(Math.random(), name, name, categories, props);
093    }
094
095    public ComboDataChoice(final String id, final String name, final Hashtable props, 
096        final Data data) 
097    {
098        super(id, name, name, CATEGORIES, props);
099        this.data = data;
100    }
101
102    /**
103     * Clone me.
104     *
105     * @return my clone
106     */
107    public DataChoice cloneMe() {
108        return new ComboDataChoice(this);
109    }
110
111    public void setData(Data data) {
112      this.data = data;
113    }
114
115    /**
116     * Return the {@link visad.Data} object that this DataChoice represents.
117     *
118     * @param category          The {@link DataCategory} used to subset this
119     *                          call (usually not used but  placed in here
120     *                          just in case it is needed.)
121     * @param dataSelection     Allows one to subset the data request (e.g.,
122     *                          asking for a smaller set of times, etc.)
123     * @param requestProperties Extra selection properties
124     *
125     * @return The data.
126     *
127     * @throws DataCancelException   if the request to get data is canceled
128     * @throws RemoteException       problem accessing remote data
129     * @throws VisADException        problem creating the Data object
130     */
131    protected Data getData(DataCategory category,
132                           DataSelection dataSelection,
133                           Hashtable requestProperties)
134            throws VisADException, RemoteException, DataCancelException {
135        return data;
136    }
137
138    public Data getData() {
139      return data;
140    }
141
142    /**
143     * add listener. This is a noop
144     *
145     * @param listener listener
146     */
147    public void addDataChangeListener(DataChangeListener listener) {}
148
149
150    /**
151     * Remove the {@link DataChangeListener}.
152     *
153     * @param listener The {@link DataChangeListener} to remove.
154     */
155    public void removeDataChangeListener(DataChangeListener listener) {}
156
157
158
159}
160