SkyObject.java
8.55 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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
package osp;
import java.awt.Color;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import jsky.coords.WorldCoords;
/**
* This class represents a sky object.
* Object coords are stored in image coord.
*/
public class SkyObject
{
// Attributes
//-----------
// Attributes needed to be saved
/** Position in pixels */
private Point2D.Double posPix; // In Image coord
/** Center position in Ra-Dec world Coordinates */
private WorldCoords objWorldCenter;
/** Recalculated position in pixels */
private Point2D.Double posPixRecalc; // In Image coord
/** Position of recalculated center in Ra-Dec world Coordinates */
private WorldCoords objWorldRecalc;
// Attributes not needed to be saved for masks
/** Number of the object on project image */
private int numIm;
/** object id When loaded */
// private int id=0;
private String targetId="";
/** Specifying if the object is a reference or not */
private boolean isRef;
/** Origin of the object (C: for catalogue, L : local catalog, M: loaded from a mask, S : Selected from image) */
private String src;
/**Properties **/
private ArrayList<String> properties;
private String prop;
/** catalog group number where the object is from when loaded */
private int group=0;
/** Object priority */
private int priority;
/* display object color */
private Color col;
// Constructors
//-----------
/**
* Constructs a temporary new sky object only to display.
* @param n Object number in image objects list
* @param iR true if the object is a reference object, false otherwise
* @param p Center of the object (in image coordinates)
* @param pRecalc Center of the object once recalculated (in image coordinates)
* @param c Color following priority.
*/
public SkyObject(int n, boolean iR, Point2D.Double p, Point2D.Double pRecalc, Color c)
{
// System.out.print("SkyObj 1 "+n+" ");
numIm = n;
isRef = iR;
posPix = new Point2D.Double();
setPosPix(p);
// if (pRecalc!= null)
// {
// System.out.println("SkyObj - pRecal "+pRecalc.getX()+" "+pRecalc.getY());
// setPosPixRecalc(pRecalc);
// c=Color.green;
// }
if (isRef )c=Color.red;
// System.out.println("SkyObj -"+n+" const temp color "+c.toString());
this.setColor(c);
// WorldCoords coords = new WorldCoords(wc.getRA(),wc.getDec());
// setObjWorldCenter(coords);
// setObjWorldRecalc(coords);
// System.out.println("Sk Obj Nw "+n+" "+ p.x +" "+p.y);
}
/**
* Constructs a new sky object when loading a project, loading a catalog,
* or selecting manually on image.
* @param id Object id from a project or a catalog
* @param n Object number in project
* @param iR true if the object is a reference object, false otherwise
* @param fi nbCat : number of catalogs loaded
* @param props Object Properties/catalog name/ ...
* @param p Center of the object (in canvas coordinates)
* @param wc Object world coordinates in J2000
* @param prior Object priority
*/
// public SkyObject(int idO, int n, boolean iR, int fi, String fr, Point2D.Double p, WorldCoords wc, int prior)
public SkyObject(String idO, int n, boolean iR, int fi, String props, Point2D.Double p, WorldCoords wc, int prior)
{
//System.out.println(" SkyObj 2 num "+n+" id "+idO);
targetId = idO;
numIm=n;
isRef = iR;
group=fi;
prop=props;
posPix = new Point2D.Double();
setPosPix(p);
posPixRecalc = null;
objWorldCenter=new WorldCoords(wc.getRA(),wc.getDec());
objWorldRecalc=new WorldCoords(0,0);
priority = prior;
Color c=Color.blue;
switch (prior)
{
case 1:
c=Color.RED;
break;
case 2:
c=Color.WHITE;
break;
default:
c=Color.BLUE;
break;
}
if (isRef )c=Color.RED;
setColor(c);
// System.out.println("SkyObj - "+n+ " const Norm color "+c.toString());
}
// Methods
//-----------
/**
* Sets the position of the object.
* @param mouse Center of the object
*/
public void setPosPix( Point2D.Double point )
{ posPix.x = point.x; posPix.y = point.y; }
/**
* Sets the recalculated position of the object.
* @param point Recalculated center of the object
*/
public void setPosPixRecalc( Point2D.Double point )
{
if (point == null)
posPixRecalc = null;
else
posPixRecalc = new Point2D.Double(point.x, point.y);
}
/**
* Returns the object priority
* @return Object priority
*/
public int getPriority() { return priority; }
/**
* Set object's priority
*
*/
public void setPriority(int n)
{
priority=n;
}
/**
* Returns the actual position of the center of the object. If the center has been
* recalculated, returns the recalculated position.
* @return Center of the object.
*/
public Point2D.Double getPosition()
{
if (posPixRecalc != null)
{
return posPixRecalc;
}
else
return posPix;
}
/**
* Returns the original position of the object
* (position before any recalculation).
* @return Initial center of the object
*/
public Point2D.Double getPosPix() { return posPix; }
/**
* Returns the recalculated position of the object.
* @return Recalculated center of the object
*/
public Point2D.Double getPosPixRecalc() { return posPixRecalc; }
/**
* Returns the number of the object for project image
* @return Object number
*/
public int getNum() { return numIm; }
/**
* Repositions the object's id in the image objects list
*
*/
public void reSetNum(int n)
{
numIm=n;
}
/**
* Returns the object id (when loaded by a local cat and has yet an identifier)
* @return Object id
*/
public String getTargetId() { return targetId; }
/**
* Sets if the object is a reference on the image.
* @param b true if the object is a reference
*/
public void setRef(boolean b) {
this.isRef = b;
Color c=Color.red;
setColor(c);
}
/**
* Returns whether the object is a reference on the image or not.
* @return true if the object is a reference, false otherwise.
*/
public boolean isRef() { return this.isRef; }
/**
* Sets the object origin : catalog ('C') or user picked ('S')
* or local catalog ('L') or charged with a mask ('M')
* @param f Origin of the object
*/
public void setSrc(String ff) { src = ff; }
/**
* Returns the object origin: catalog ('C') or user picked ('S')
* or local catalog ('L') or charged with a mask ('M')
* or loaded from a mask ('load').
* @return Origin of the object
*/
public String getSrc() { return src; }
/**
* Sets the object properties
*/
// Used
public void setObjectProp(String pr)
{
// System.out.println("skObj prop "+pr);
prop=pr;
}
/**
* Returns some object properties stored in String (Last array column)
*/
public String getProperty() { return prop; }
/**
* Returns <i>true</i> if the center of the object has been recalculated.
* @return true if the center has been recalculated
*/
public boolean isCenterRecalc ()
{
boolean err=false;
if (posPixRecalc != null)
{
Color c = new Color(0, 255, 0);
this.setColor(c);
err=true;
}
return err;
}
public WorldCoords getObjWorldCenter() {
return objWorldCenter;
}
public void setObjWorldCenter(WorldCoords objWorldCenter) {
this.objWorldCenter = objWorldCenter;
}
public WorldCoords getObjWorldRecalc() {
return objWorldRecalc;
}
public void setObjWorldRecalc(WorldCoords objWorldRecalc) {
this.objWorldRecalc = objWorldRecalc;
}
/**
* Get the color to draw the object with
* @return Color col : object color
*/
public Color getColor() {
return col;
}
/**
* Set the color the object will be drawn with
* @param col : color
*/
public void setColorWithPriority(int p) {
Color c;
switch (p)
{
case 1:
c=Color.RED;
break;
case 2:
c=Color.WHITE;
break;
default:
c=Color.BLUE;
break;
}
this.col=c;
}
/**
* Set the color the object will be drawn with
* @param col : color
*/
public void setColor(Color col) {
this.col = col;
}
/**
* Get the catalog group where the object is from
* @return int group
*/
public int getGroup() {
return group;
}
}