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