Package skyview.data
Class CoordinateFormatter
java.lang.Object
skyview.data.CoordinateFormatter
This class provides methods to encode coordinates
to a variety of precisions in both sexagesimal and decimal representations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecimal
(double value, int precision) Format a number with a specified precision.format
(double value, int precision) Render a value using the current rules.static void
void
setSeparators
(String[] separators) Specify the two separators to be used between the three numbers in sexagesimal output.void
setSexagesimal
(boolean flag) void
setZeroFill
(boolean flag) sexagesimal
(double value, int precision) Create a sexagesimal string representing the coordinate value.
-
Constructor Details
-
CoordinateFormatter
public CoordinateFormatter()
-
-
Method Details
-
sexagesimal
Create a sexagesimal string representing the coordinate value.- Parameters:
value
- A double precision value which is to be converted to a string representation. The user should convert to hours prior to this call if the string is to be in hours.precision
- A integer value giving the precision to which the value is to be shown.- Less than 3
- Degrees (or hours), e.g. 24
- 3
- Deg.f e.g., 24.3
- 4
- Deg mm e.g., 24 18
- 5
- Deg mm.f e.g., 25 18.3
- 6
- Deg mm ss e.g., 25 18 18
- 7
- Deg mm ss.s e.g., 25 18 18.2
- 8
- Deg mm ss.ss e.g., 25 18 18.24
- Greater than 8
- Deg mm ss.sss e.g., 25 18 18.238
-
decimal
Format a number with a specified precision. The precision is 2 more than the number of decimal places. E.g., to get 4 decimal places use a precision of 6. -
setZeroFill
public void setZeroFill(boolean flag) -
setSexagesimal
public void setSexagesimal(boolean flag) -
setSeparators
Specify the two separators to be used between the three numbers in sexagesimal output. The default is blank separators. E.g., to get output of the form 10:20:30 then this.setSeparators(new String[]{":", ":"}); before rendering.- Parameters:
separators
-
-
format
Render a value using the current rules. Note that any scaling between hours/degrees should be done before rendering. -
main
-