com.pegacat.vcf.data
Class VoyagerLocation

java.lang.Object
  |
  +--com.pegacat.vcf.data.VoyagerLocation

public class VoyagerLocation
extends java.lang.Object

A location in voyager, being a) a star, world, moon location, and b) an x,y,z starmap position


Field Summary
 int moon
           
 int starNo
           
static java.util.Hashtable starpos
           
static int UNKNOWN
           
static char UNKNOWNC
           
static java.lang.String UNKNOWNS
           
 char world
           
 int x
           
 int y
           
 int z
           
 
Constructor Summary
VoyagerLocation(int X, int Y, int Z)
          Sets a voyager location purely in terms of starmap x,y,z co-ordinates.
VoyagerLocation(int starNo, int X, int Y, int Z)
          Sets a voyager location purely in terms of starmap x,y,z co-ordinates.
VoyagerLocation(java.lang.String position)
          Creates a location specified by a string of form [s]SSS[World letter][Moon number] such as '105a2', '497', 's497', 'w232b'.
 
Method Summary
 double distanceFrom(VoyagerLocation other)
          return distance from another location.
static int[] getPosition(java.lang.String position)
          Returns the starNo map position of a starNo, world or moon as a three int array [x,y,z].
static java.lang.String getStarName(java.lang.String position)
          Returns the unadorned starNo name from a starNo, world or moon string.
 int getX()
          returns the starNo map x co-ordinate.
 int getY()
          returns the starNo map y co-ordinate.
 int getZ()
          returns the starNo map z co-ordinate.
 int hashCode()
           
static void registerDataLayer(DataLayer current)
          Registers the current data layer.
protected  void setCoOrds()
          This attempts to look up the Star array, using this object's starNo number, and thus set the x/y/z position of the object.
 void setNamedPosition()
          returns the named position, such as 's112' or 'w212b5', in canonical '[char][number][char][number]' form.
protected  void setPosition(java.lang.String position)
          This sets the canonical position of the location by parsing any of the generic world/star description strings.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static int UNKNOWN

UNKNOWNS

public static java.lang.String UNKNOWNS

UNKNOWNC

public static char UNKNOWNC

starNo

public int starNo

world

public char world

moon

public int moon

x

public int x

y

public int y

z

public int z

starpos

public static java.util.Hashtable starpos
Constructor Detail

VoyagerLocation

public VoyagerLocation(java.lang.String position)
Creates a location specified by a string of form [s]SSS[World letter][Moon number] such as '105a2', '497', 's497', 'w232b'. If the internal location map has been set, the VoyagerLocation object will be able to translate this into x,y,z co-ordinates.

VoyagerLocation

public VoyagerLocation(int X,
                       int Y,
                       int Z)
Sets a voyager location purely in terms of starmap x,y,z co-ordinates. There is no corresponding named location.

VoyagerLocation

public VoyagerLocation(int starNo,
                       int X,
                       int Y,
                       int Z)
Sets a voyager location purely in terms of starmap x,y,z co-ordinates. There is no corresponding named location.
Method Detail

setPosition

protected void setPosition(java.lang.String position)
This sets the canonical position of the location by parsing any of the generic world/star description strings.

getX

public int getX()
returns the starNo map x co-ordinate.
Returns:
x co-ordinate, or UNKNOWN.

getY

public int getY()
returns the starNo map y co-ordinate.
Returns:
y co-ordinate, or UNKNOWN.

getZ

public int getZ()
returns the starNo map z co-ordinate.
Returns:
z co-ordinate, or UNKNOWN.

setCoOrds

protected void setCoOrds()
This attempts to look up the Star array, using this object's starNo number, and thus set the x/y/z position of the object.

setNamedPosition

public void setNamedPosition()
returns the named position, such as 's112' or 'w212b5', in canonical '[char][number][char][number]' form.
Returns:
voyager location as a string.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

distanceFrom

public double distanceFrom(VoyagerLocation other)
return distance from another location. Assumes both locations have x/y/z fields. Creation date: (12/06/2001 8:58:06 PM)
Returns:
double distance

getStarName

public static java.lang.String getStarName(java.lang.String position)
Returns the unadorned starNo name from a starNo, world or moon string. (e.g. translates w12b8 to '12', '143' to '143', and 'WORLD122A1' to '122'). The algorithm is simply to scan the string for the first group of integers encountered, and use that for the starNo name. (e.g. FNorDle45Spling would return '45'). updated by Korny to use the RE package for sanity...

getPosition

public static int[] getPosition(java.lang.String position)
Returns the starNo map position of a starNo, world or moon as a three int array [x,y,z].
Parameters:
the - string name of a location (e.g. 's178' or 'w133b4'
Returns:
x,y,z pos of main starNo as an int array, or null if no starNo known at that position.

registerDataLayer

public static void registerDataLayer(DataLayer current)
Registers the current data layer. Just possible this might be used when viewing multiple games simultaneously, but I suspect stuff will need to be rewritten for that...

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object