001 /*
002 * $Id: StormParam.java,v 1.1 2012/01/04 20:40:51 tommyj 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.cyclone;
032
033 import java.util.List;
034
035 import ucar.unidata.data.DataChoice;
036 import ucar.unidata.util.TwoFacedObject;
037 import ucar.visad.Util;
038 import visad.Real;
039 import visad.RealType;
040 import visad.Unit;
041 import visad.VisADException;
042
043 /**
044 * Created by IntelliJ IDEA. User: yuanho Date: Apr 18, 2008 Time: 1:45:38 PM To
045 * change this template use File | Settings | File Templates.
046 */
047
048 public class StormParam {
049
050 /** _more_ */
051 RealType type;
052
053 /** _more_ */
054 private boolean canDoDifference = true;
055
056 /** _more_ */
057 private boolean derived = false;
058
059 /** _more_ */
060 private boolean isChartParam = true;
061
062 /**
063 * _more_
064 */
065 public StormParam() {
066 }
067
068 /**
069 * _more_
070 *
071 * @param type
072 * _more_
073 */
074 public StormParam(RealType type) {
075 this.type = type;
076 if (type != null) {
077 DataChoice.addCurrentName(new TwoFacedObject("Storm Track>" + type,
078 Util.cleanTypeName(type)));
079 }
080 }
081
082 /**
083 * _more_
084 *
085 * @param type
086 * _more_
087 * @param derived
088 * _more_
089 */
090 public StormParam(RealType type, boolean derived) {
091 this(type);
092 this.derived = derived;
093 }
094
095 /**
096 * _more_
097 *
098 * @param type
099 * _more_
100 * @param derived
101 * _more_
102 * @param canDoDiff
103 * _more_
104 */
105 public StormParam(RealType type, boolean derived, boolean canDoDiff) {
106 this(type);
107 this.derived = derived;
108 this.canDoDifference = canDoDiff;
109 }
110
111 /**
112 * _more_
113 *
114 * @param type
115 * _more_
116 * @param derived
117 * _more_
118 * @param canDoDiff
119 * _more_
120 * @param chartList
121 * _more_
122 */
123 public StormParam(RealType type, boolean derived, boolean canDoDiff,
124 boolean chartList) {
125 this(type);
126 this.derived = derived;
127 this.canDoDifference = canDoDiff;
128 this.isChartParam = chartList;
129 }
130
131 /**
132 * _more_
133 *
134 * @param value
135 * _more_
136 *
137 * @return _more_
138 *
139 * @throws VisADException
140 * _more_
141 */
142 public Real getReal(double value) throws VisADException {
143 return new Real(type, value);
144 }
145
146 /**
147 * _more_
148 *
149 * @return _more_
150 */
151 public Unit getUnit() {
152 return type.getDefaultUnit();
153 }
154
155 /**
156 * _more_
157 *
158 * @return _more_
159 */
160 public int hashCode() {
161 return type.hashCode();
162 }
163
164 /**
165 * Set the CanDoDifference property.
166 *
167 * @param value
168 * The new value for CanDoDifference
169 */
170 public void setCanDoDifference(boolean value) {
171 canDoDifference = value;
172 }
173
174 /**
175 * Get the CanDoDifference property.
176 *
177 * @return The CanDoDifference
178 */
179 public boolean getCanDoDifference() {
180 return canDoDifference;
181 }
182
183 /**
184 * Set the CanDoDifference property.
185 *
186 * @param value
187 * The new value for CanDoDifference
188 */
189 public void setIsChartParam(boolean value) {
190 isChartParam = value;
191 }
192
193 /**
194 * Get the CanDoDifference property.
195 *
196 * @return The CanDoDifference
197 */
198 public boolean getIsChartParam() {
199 return isChartParam;
200 }
201
202 /**
203 * _more_
204 *
205 * @param attributes
206 * _more_
207 *
208 * @return _more_
209 */
210 public Real getAttribute(List<Real> attributes) {
211 if (attributes == null) {
212 return null;
213 }
214 for (Real attr : attributes) {
215 if (attr.getType().equals(type)) {
216 return attr;
217 }
218 }
219 return null;
220 }
221
222 /**
223 * _more_
224 *
225 * @param o
226 * _more_
227 *
228 * @return _more_
229 */
230 public boolean equals(Object o) {
231 if (!this.getClass().equals(o.getClass())) {
232 return false;
233 }
234 StormParam that = (StormParam) o;
235 return this.type.equals(that.type);
236 }
237
238 /**
239 * _more_
240 *
241 * @return _more_
242 */
243 public String toString() {
244 return Util.cleanTypeName(type.getName()).replace("_", " ");
245 }
246
247 /**
248 * _more_
249 *
250 * @return _more_
251 */
252 public String getName() {
253 return Util.cleanTypeName(type.getName());
254 }
255
256 /**
257 * Set the Type property.
258 *
259 * @param value
260 * The new value for Type
261 */
262 public void setType(RealType value) {
263 type = value;
264 }
265
266 /**
267 * Get the Type property.
268 *
269 * @return The Type
270 */
271 public RealType getType() {
272 return type;
273 }
274
275 /**
276 * Set the Derived property.
277 *
278 * @param value
279 * The new value for Derived
280 */
281 public void setDerived(boolean value) {
282 derived = value;
283 }
284
285 /**
286 * Get the Derived property.
287 *
288 * @return The Derived
289 */
290 public boolean getDerived() {
291 return derived;
292 }
293
294 }