CoordinateConverter.java
8.63 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
/*
* $Id: CoordinateConverter.java,v 1.2 2009/04/21 13:31:17 abrighto Exp $
*/
package jsky.coords;
import java.awt.geom.*;
/**
* This interface may be implemented by classes that display images and can
* convert between different coordinate systems, optionally including world
* coordinates. Methods are available for converting between the following
* coordinate systems:
* <p>
* <DL>
* <DT>Screen Coordinates</DT>
* <DD> The origin (0,0) is always at the upper left corner of the window.
* Whole pixels are counted and no transformations are taken into account.
* </DD>
*
* <DT>Canvas Coordinates</DT>
* <DD> The origin (0,0) is at the upper left corner of the image.
* Whole pixels are counted and no transformations are taken into account.
* </DD>
*
* <DT>Image Coordinates</DT>
* <DD> The origin is at lower left (FITS style) after all transformations are undone.
* At mag 1, the origin is (1, 1), otherwise it is a fraction of
* a pixel (0.5, 0.5). Image coordinates correspond to the coordinates in a
* FITS image.
* </DD>
*
* <DT>User Coordinates</DT>
* <DD> The origin (0.0, 0.0) is at upper left after all transformations undone.
* User coordinates are like image coordinates, except that the
* Y axis is reversed and the origin at mag 1 is (0., 0.) instead of (1. 1).
* </DD>
*
* <DT>World Coordinates</DT>
* <DD> World coordinates are converted from image coordinates based on the keywords
* in the image header, if available.
* </DD>
* </DL>
*
* @version $Revision: 1.2 $ $Date: 2009/04/21 13:31:17 $
* @author Allan Brighton
*/
public abstract interface CoordinateConverter extends WorldCoordinateConverter {
/** Constant for image coordinates */
public static final int IMAGE = 0;
/** Constant for screen coordinates */
public static final int SCREEN = 1;
/** Constant for canvas coordinates */
public static final int CANVAS = 2;
/** Constant for user coordinates */
public static final int USER = 3;
/** Constant for world coordinates (deg, in the equinox of the image) */
public static final int WORLD = 4;
/**
* Convert the given coordinates from inType to outType. The inType and
* outType arguments should be one of the constants defined in this interface
* (IMAGE for image coordinates, WCS for world coordinates, etc...).
*
* @param p The point to convert.
* @param inType the type of the input coordinates
* @param outType the type of the output coordinates
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void convertCoords(Point2D.Double p, int inType, int outType, boolean isDistance);
/**
* Convert the given canvas coordinates to image coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void canvasToImageCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given canvas coordinates to user coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void canvasToUserCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given user coordinates to image coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void userToImageCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given user coordinates to canvas coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void userToCanvasCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given image coordinates to canvas coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void imageToCanvasCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given image coordinates to user coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void imageToUserCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given canvas coordinates to screen coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void canvasToScreenCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given screen coordinates to canvas coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void screenToCanvasCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given screen coordinates to image coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void screenToImageCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given image coordinates to screen coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void imageToScreenCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given screen coordinates to user coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void screenToUserCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given user coordinates to screen coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void userToScreenCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given screen coordinates to world coordinates degrees in the equinox
* of the current image.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void screenToWorldCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given canvas coordinates to world coordinates degrees in the equinox
* of the current image.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void canvasToWorldCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given user coordinates to world coordinates degrees in the equinox
* of the current image.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void userToWorldCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given world coordinates (degrees, in the equinox of the current image)
* to canvas coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void worldToCanvasCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given world coordinates (degrees, in the equinox of the current image)
* to screen coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void worldToScreenCoords(Point2D.Double p, boolean isDistance);
/**
* Convert the given world coordinates (degrees, in the equinox of the current image)
* to user coordinates.
*
* @param p The point to convert.
* @param isDistance True if p should be interpreted as a distance instead
* of a point.
*/
public void worldToUserCoords(Point2D.Double p, boolean isDistance);
}