-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRTMLImageData.java
More file actions
282 lines (257 loc) · 7.36 KB
/
RTMLImageData.java
File metadata and controls
282 lines (257 loc) · 7.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
Copyright 2006, Astrophysics Research Institute, Liverpool John Moores University.
This file is part of org.estar.rtml.
org.estar.rtml is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
org.estar.rtml is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with org.estar.rtml; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// RTMLImageData.java
// $Header: /space/home/eng/cjm/cvs/org_estar_rtml/RTMLImageData.java,v 1.5 2008-05-27 14:15:55 cjm Exp $
package org.estar.rtml;
import java.io.*;
import java.net.*;
/**
* This class is a data container for information contained in the ImageData nodes/tags of an RTML document.
* @author Chris Mottram
* @version $Revision$
*/
public class RTMLImageData implements Serializable
{
/**
* Revision control system version id.
*/
public final static String RCSID = "$Id$";
/**
* Serial version ID. Fixed as these documents can be used as parameters in RMI calls across JVMs.
*/
static final long serialVersionUID = -6324753364425492455L;
/**
* The type of the object list belonging to this observation. Either "xml", "cluster" or "votable-url".
*/
private String objectListType = null;
/**
* A string, containing the contents of a cluster format object list file.
*/
private String objectListClusterString = null;
/**
* The URL containing the location of a VOTable containing information about objects in the image.
*/
private URL objectListVOTableURL = null;
/**
* The ImageData type string containing the format of the image data.
* Should be a valid %imageFormats; ENTITY, see DTD (FITS|FITS16|gif|jpg|JPEG).
*/
private String imageDataType = null;
/**
* The URL containing the location of the image data.
*/
private URL imageDataURL = null;
/**
* A string, containing the FITS header from the image data/observation.
*/
private String fitsHeader = null;
/**
* Default constructor.
*/
public RTMLImageData()
{
super();
}
/**
* Set the object list type.
* @param s The type of the object list. Should be either "cluster", "xml" or "votable-url".
* See DTD, %objectListTypes;.
* @exception IllegalArgumentException Thrown if the type is nor legal.
* @see #objectListType
*/
public void setObjectListType(String s)
{
if((s.equals("xml") == false)&&(s.equals("cluster") == false)&&(s.equals("votable-url") == false))
{
throw new IllegalArgumentException(this.getClass().getName()+
":setObjectListType:Object List Type "+
s+" not legal.");
}
objectListType = s;
}
/**
* Return the object list.
*/
public String getObjectListType()
{
return objectListType;
}
/**
* Return whether the object list type is "cluster".
* @return True if the object list type is cluster, false if it is not, or has not been set yet.
*/
public boolean isObjectListTypeCluster()
{
if(objectListType == null)
return false;
return objectListType.equals("cluster");
}
public void setObjectListCluster(String s)
{
objectListClusterString = s;
}
public String getObjectListCluster()
{
return objectListClusterString;
}
/**
* Return whether the object list type is "votable-url".
* @return True if the object list type is votable-url, false if it is not, or has not been set yet.
*/
public boolean isObjectListTypeVOTableURL()
{
if(objectListType == null)
return false;
return objectListType.equals("votable-url");
}
/**
* Set the VOTable URL.
* @param u The URL.
* @see #objectListVOTableURL
*/
public void setObjectListVOTableURL(URL u)
{
objectListVOTableURL = u;
}
/**
* Routine to set the VOTable URL.
* @param s The string to create a URL from.
* @exception RTMLException Thrown if the string is not a valid URL.
*/
public void setObjectListVOTableURL(String s) throws RTMLException
{
try
{
objectListVOTableURL = new URL(s);
}
catch(MalformedURLException e)
{
throw new RTMLException(this.getClass().getName()+"setObjectListVOTableURL:Malformed URL:"+s,e);
}
}
/**
* Get the VOTable URL.
* @return The URL.
* @see #objectListVOTableURL
*/
public URL getObjectListVOTableURL()
{
return objectListVOTableURL;
}
/**
* Routine to set the image data Type.
* @param s The string containing a valid type. See %imageFormats; ENTITY in DTD.
* @exception RTMLException Thrown if the image data type string is not a valid type.
* @see #imageDataType
*/
public void setImageDataType(String s) throws RTMLException
{
if(!(s.equals("FITS")||s.equals("FITS16")||s.equals("gif")||s.equals("jpg")||s.equals("JPEG")))
throw new RTMLException(this.getClass().getName()+":setImageDataType:Illegal Type:"+s);
imageDataType = s;
}
/**
* Get the image data type.
* @see #imageDataType
*/
public String getImageDataType()
{
return imageDataType;
}
/**
* Routine to set the image data URL.
* @param s The string to create a URL from.
* @exception RTMLException Thrown if the image data string is not a valid URL.
*/
public void setImageDataURL(String s) throws RTMLException
{
try
{
imageDataURL = new URL(s);
}
catch(MalformedURLException e)
{
throw new RTMLException(this.getClass().getName()+"setImageDataURL:Malformed URL:"+s,e);
}
}
public URL getImageDataURL()
{
return imageDataURL;
}
public void setFITSHeader(String s)
{
fitsHeader = s;
}
public String getFITSHeader()
{
return fitsHeader;
}
/**
* Method to print out a string representation of this node.
*/
public String toString()
{
return toString("");
}
/**
* Method to print out a string representation of this node, with a prefix.
* @param prefix A string to prefix to each line of data we print out.
* @see #objectListClusterString
* @see #objectListVOTableURL
* @see #objectListType
* @see #imageDataType
* @see #imageDataURL
* @see #fitsHeader
*/
public String toString(String prefix)
{
StringBuffer sb = null;
sb = new StringBuffer();
sb.append(prefix+"ImageData\n");
if(isObjectListTypeCluster()&&(objectListClusterString != null))
{
sb.append(prefix+"\tObjectList: type = cluster\n");
sb.append(prefix+"\t"+objectListClusterString+"\n");
}
if(isObjectListTypeVOTableURL()&&(objectListVOTableURL != null))
{
sb.append(prefix+"\tObjectList: type = votable-url\n");
sb.append(prefix+"\t"+objectListVOTableURL+"\n");
}
if(imageDataType != null)
sb.append(prefix+"\tImageDataType: "+imageDataType+"\n");
if(imageDataURL != null)
sb.append(prefix+"\tImageData: "+imageDataURL+"\n");
if(fitsHeader != null)
sb.append(prefix+"\tFITSHeader: "+fitsHeader+"\n");
return sb.toString();
}
}
/*
** $Log: not supported by cvs2svn $
** Revision 1.4 2008/05/23 14:25:33 cjm
** Comment changes.
**
** Revision 1.3 2007/01/30 18:31:16 cjm
** gnuify: Added GNU General Public License.
**
** Revision 1.2 2005/08/19 17:00:44 cjm
** Added VOTable URL support.
**
** Revision 1.1 2005/05/04 18:54:26 cjm
** Initial revision
**
*/