001 /*
002 * This file is part of McIDAS-V
003 *
004 * Copyright 2007-2013
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 http://www.gnu.org/licenses.
027 */
028
029 package edu.wisc.ssec.mcidasv.data;
030
031 import ucar.unidata.util.LogUtil;
032
033
034 import ucar.unidata.util.Misc;
035 import ucar.unidata.xml.XmlUtil;
036
037 import ucar.unidata.data.*;
038
039
040 import visad.*;
041
042 import visad.georef.*;
043
044 import java.rmi.RemoteException;
045
046 import java.util.ArrayList;
047 import java.util.Enumeration;
048 import java.util.Hashtable;
049 import java.util.List;
050 import 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 */
059 public 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.
086 *
087 * @param name The short name of this choice.
088 * @param data The data
089 */
090 public ComboDataChoice(String name, List categories, Hashtable props) {
091 super(Math.random(), name, name, categories, props);
092 }
093
094 public ComboDataChoice(final String id, final String name, final Hashtable props,
095 final Data data)
096 {
097 super(id, name, name, CATEGORIES, props);
098 this.data = data;
099 }
100
101 /**
102 * Clone me
103 *
104 * @return my clone
105 */
106 public DataChoice cloneMe() {
107 return new ComboDataChoice(this);
108 }
109
110 public void setData(Data data) {
111 this.data = data;
112 }
113
114 /**
115 * Return the {@link visad.Data} object that this DataChoice represents.
116 *
117 * @param category The {@link DataCategory} used to subset this
118 * call (usually not used but placed in here
119 * just in case it is needed.)
120 * @param dataSelection Allows one to subset the data request (e.g.,
121 * asking for a smaller set of times, etc.)
122 * @param requestProperties Extra selection properties
123 *
124 * @return The data.
125 *
126 * @throws DataCancelException if the request to get data is canceled
127 * @throws RemoteException problem accessing remote data
128 * @throws VisADException problem creating the Data object
129 */
130 protected Data getData(DataCategory category,
131 DataSelection dataSelection,
132 Hashtable requestProperties)
133 throws VisADException, RemoteException, DataCancelException {
134 return data;
135 }
136
137 public Data getData() {
138 return data;
139 }
140
141 /**
142 * add listener. This is a noop
143 *
144 * @param listener listener
145 */
146 public void addDataChangeListener(DataChangeListener listener) {}
147
148
149 /**
150 * Remove the {@link DataChangeListener}.
151 *
152 * @param listener The {@link DataChangeListener} to remove.
153 */
154 public void removeDataChangeListener(DataChangeListener listener) {}
155
156
157
158 }
159