astro
Class SkyPath

java.lang.Object
  extended by astro.SkyPath

public class SkyPath
extends Object

A sky path uses a Morphing object to convert a ra-dec path on the sky to a pixel path. GeneralPath is decalred final, thus we cannot extend it.


Field Summary
private  GeneralPath path
          The general path used to construct pixel coordinates.
private  CoordinateTransforming radec
          The morpher converting radec into pixels.
 
Constructor Summary
SkyPath(CoordinateTransforming sphere)
          Constructs a new general sky path that defines a Morphing instance to convert spherical coordinates into pixel coordinates.
 
Method Summary
 void closePath()
          Closes the path.
 Shape getPath()
          Returns the general path on the sky in pixel coordinates as a shape.
 void lineTo(VectorG star)
          Similar to the general path line to, we move out path iterator to a new point on the sphere.
 void moveTo(VectorG star)
          Similar to the general path move to, we move out path iterator to a new point on the sphere.
static Shape parse(String wind, CoordinateTransforming sky)
          Converts a string into a sky path.
private static int parseNext(GeneralPath path, CoordinateTransforming radec, String wind, int index)
          Parses a single operation starting from index in the specified string.
private static int parsePosition(String wind, int index, Vector2D sky)
          Parse a position starting at the specified index.
 void reset()
          Reset the path in the sky.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

radec

private CoordinateTransforming radec
The morpher converting radec into pixels.


path

private GeneralPath path
The general path used to construct pixel coordinates.

Constructor Detail

SkyPath

public SkyPath(CoordinateTransforming sphere)
Constructs a new general sky path that defines a Morphing instance to convert spherical coordinates into pixel coordinates.

Method Detail

moveTo

public void moveTo(VectorG star)
Similar to the general path move to, we move out path iterator to a new point on the sphere.

Parameters:
star - A sky position, x is ra in degrees, y declination.

lineTo

public void lineTo(VectorG star)
Similar to the general path line to, we move out path iterator to a new point on the sphere.

Parameters:
star - A sky position, x is ra in degrees, y declination.

getPath

public Shape getPath()
Returns the general path on the sky in pixel coordinates as a shape.


reset

public void reset()
Reset the path in the sky.


closePath

public void closePath()
Closes the path. New points may be added later.


parse

public static Shape parse(String wind,
                          CoordinateTransforming sky)
                   throws ParseException
Converts a string into a sky path. The format of the string supports moving to a sky position, lining to a sky position and closing of a sky path. Any sky position is given as a comma-separated pair of doubles, in degrees. Moving to a point is abbreviated with 'm', line to is 'l'. Closing a path can be done after any position with the 'c' character. E.g.
       m123.456,-67.45l176.23,-77.45cm111.23,-45.67l133.45-54.67
       
       The returned shape is a newly allocated general path. It can later
       be queried with getPath().
       Note that legal string must always start with a move.

Throws:
IllegalPathStateException - If string does not start with move.
ParseException - In case of parsing errors.

parseNext

private static int parseNext(GeneralPath path,
                             CoordinateTransforming radec,
                             String wind,
                             int index)
                      throws ParseException
Parses a single operation starting from index in the specified string. The character at index must be either of 'm' 'l' or 'c', indicating a move, line, or close operation. The index of the next parsing position is returned. Case is ignored.

Throws:
ParseException

parsePosition

private static int parsePosition(String wind,
                                 int index,
                                 Vector2D sky)
                          throws ParseException
Parse a position starting at the specified index. The position are to degree doubles, separated by a comma. The sky argument must be a pre-allocated Point2D object into which the parses position is squeezed into.

Throws:
ParseException