1 | /* |
---|
2 | * $Id: SGTVector.java,v 1.11 2002/05/16 22:41:29 dwd Exp $ |
---|
3 | * |
---|
4 | * This software is provided by NOAA for full, free and open release. It is |
---|
5 | * understood by the recipient/user that NOAA assumes no liability for any |
---|
6 | * errors contained in the code. Although this software is released without |
---|
7 | * conditions or restrictions in its use, it is expected that appropriate |
---|
8 | * credit be given to its author and to the National Oceanic and Atmospheric |
---|
9 | * Administration should the software be included by the recipient as an |
---|
10 | * element in other product development. |
---|
11 | */ |
---|
12 | |
---|
13 | package gov.noaa.pmel.sgt.dm; |
---|
14 | |
---|
15 | import gov.noaa.pmel.sgt.SGLabel; |
---|
16 | import gov.noaa.pmel.util.SoTRange; |
---|
17 | |
---|
18 | import java.beans.PropertyChangeListener; |
---|
19 | import java.io.Serializable; |
---|
20 | |
---|
21 | /** |
---|
22 | * Defines a data object to be a Vector. Interpretation |
---|
23 | * of U and V is determined by the <code>CoordinateSystem</code>. For |
---|
24 | * <code>Cartesian</code>, U and V are the Cartesian vector |
---|
25 | * components. For <code>Polar</code> , |
---|
26 | * U and V are R (radius) and Theta (angle) vector components, |
---|
27 | * respectively. |
---|
28 | * |
---|
29 | * @author Donald Denbo |
---|
30 | * @version $Revision: 1.11 $, $Date: 2002/05/16 22:41:29 $ |
---|
31 | * @since 1.0 |
---|
32 | * @see SGTData |
---|
33 | * @see CoordinateSystem |
---|
34 | */ |
---|
35 | public class SGTVector implements SGTData, Cloneable, Serializable { |
---|
36 | String title_; |
---|
37 | SGLabel keyTitle_ = null; |
---|
38 | String id_ = null; |
---|
39 | /**@shapeType AggregationLink |
---|
40 | * @clientRole u comp*/ |
---|
41 | SGTGrid uComp_; |
---|
42 | /**@shapeType AggregationLink |
---|
43 | * @clientRole v comp*/ |
---|
44 | SGTGrid vComp_; |
---|
45 | /** |
---|
46 | * Default constructor. |
---|
47 | */ |
---|
48 | public SGTVector() { |
---|
49 | } |
---|
50 | /** |
---|
51 | * Construct a SGTVector from two components. The two components |
---|
52 | * must match in both SGTData and CoordinateSystem Interfaces. |
---|
53 | * Both components must be the same shape. |
---|
54 | * |
---|
55 | * @param uComp U component of the vector |
---|
56 | * @param vComp V component of the vector |
---|
57 | */ |
---|
58 | public SGTVector(SGTGrid uComp,SGTGrid vComp) { |
---|
59 | uComp_ = uComp; |
---|
60 | vComp_ = vComp; |
---|
61 | } |
---|
62 | /** |
---|
63 | * Create a copy. Creates a shallow copy. |
---|
64 | * |
---|
65 | * @see SGTData |
---|
66 | */ |
---|
67 | public SGTData copy() { |
---|
68 | SGTVector newSGTVector; |
---|
69 | try { |
---|
70 | newSGTVector = (SGTVector)clone(); |
---|
71 | } catch (CloneNotSupportedException e) { |
---|
72 | newSGTVector = new SGTVector(this.uComp_, this.vComp_); |
---|
73 | } |
---|
74 | return (SGTData)newSGTVector; |
---|
75 | } |
---|
76 | /** |
---|
77 | * Get the U component. |
---|
78 | * |
---|
79 | * @return U component |
---|
80 | */ |
---|
81 | public SGTGrid getU() { |
---|
82 | return uComp_; |
---|
83 | } |
---|
84 | /** |
---|
85 | * Get the V component. |
---|
86 | * |
---|
87 | * @return V component |
---|
88 | */ |
---|
89 | public SGTGrid getV() { |
---|
90 | return vComp_; |
---|
91 | } |
---|
92 | /** |
---|
93 | * Set the U component. |
---|
94 | * |
---|
95 | * @param uComp U component |
---|
96 | */ |
---|
97 | public void setU(SGTGrid uComp) { |
---|
98 | uComp_ = uComp; |
---|
99 | } |
---|
100 | /** |
---|
101 | * Set the V component. |
---|
102 | * |
---|
103 | * @param vComp V component |
---|
104 | */ |
---|
105 | public void setV(SGTGrid vComp) { |
---|
106 | vComp_ = vComp; |
---|
107 | } |
---|
108 | /** |
---|
109 | * Set the vector components. |
---|
110 | * |
---|
111 | * @param uComp U component |
---|
112 | * @param vComp V component |
---|
113 | */ |
---|
114 | public void setComponents(SGTGrid uComp, SGTGrid vComp) { |
---|
115 | uComp_ = uComp; |
---|
116 | vComp_ = vComp; |
---|
117 | } |
---|
118 | /** |
---|
119 | * Set the vector's title. |
---|
120 | * |
---|
121 | * @param title |
---|
122 | */ |
---|
123 | public void setTitle(String title) { |
---|
124 | title_ = title; |
---|
125 | } |
---|
126 | public SGLabel getKeyTitle() { |
---|
127 | return keyTitle_; |
---|
128 | } |
---|
129 | /** Set the title formatted for the <code>VectorKey</code>. */ |
---|
130 | public void setKeyTitle(SGLabel title) { |
---|
131 | keyTitle_ = title; |
---|
132 | } |
---|
133 | /** |
---|
134 | * Get the unique identifier. The presence of the identifier |
---|
135 | * is optional, but if it is present it should be unique. This |
---|
136 | * field is used to search for the layer that contains the data. |
---|
137 | * |
---|
138 | * @return unique identifier |
---|
139 | * @see gov.noaa.pmel.sgt.Pane |
---|
140 | * @see gov.noaa.pmel.sgt.Layer |
---|
141 | */ |
---|
142 | public String getId() { |
---|
143 | return id_; |
---|
144 | } |
---|
145 | /** |
---|
146 | * Set the unique identifier. |
---|
147 | */ |
---|
148 | public void setId(String ident) { |
---|
149 | id_ = ident; |
---|
150 | } |
---|
151 | /** |
---|
152 | * Get the vector's title. |
---|
153 | * |
---|
154 | * @return the title |
---|
155 | */ |
---|
156 | public String getTitle() { |
---|
157 | return title_; |
---|
158 | } |
---|
159 | public boolean isXTime() { |
---|
160 | return uComp_.isXTime(); |
---|
161 | } |
---|
162 | public boolean isYTime() { |
---|
163 | return uComp_.isYTime(); |
---|
164 | } |
---|
165 | public SGTMetaData getXMetaData() { |
---|
166 | return uComp_.getXMetaData(); |
---|
167 | } |
---|
168 | public SGTMetaData getYMetaData() { |
---|
169 | return uComp_.getYMetaData(); |
---|
170 | } |
---|
171 | public SoTRange getXRange() { |
---|
172 | return uComp_.getXRange(); |
---|
173 | } |
---|
174 | public SoTRange getYRange() { |
---|
175 | return uComp_.getYRange(); |
---|
176 | } |
---|
177 | public void addPropertyChangeListener(PropertyChangeListener l) { |
---|
178 | uComp_.addPropertyChangeListener(l); |
---|
179 | vComp_.addPropertyChangeListener(l); |
---|
180 | } |
---|
181 | public void removePropertyChangeListener(PropertyChangeListener l) { |
---|
182 | uComp_.removePropertyChangeListener(l); |
---|
183 | vComp_.removePropertyChangeListener(l); |
---|
184 | } |
---|
185 | } |
---|