Class Direction


  • public class Direction
    extends java.lang.Object
    A class that handles directions like in ships or borders. There are three direction formats and the conversions between them supported: integer representation (0 = north west and clockwise up), string representation (like 'NW' or 'Nordwesten') and relative coordinate representation (coordinate with x = -1, y = 1).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DIR_INVALID
      Code for the invalid direction that does not correspond to any direction on the map
      static Direction INVALID
      An invalid direction that does not correspond to any direction on the map
    • Constructor Summary

      Constructors 
      Constructor Description
      Direction​(int direction, StringID id, CoordinateID coord, java.lang.String iconName)
      Creates a new Direction object interpreting the specified integer as a direction according to the direction constants of this class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      int getDirCode()
      Returns the internal code of this direction (used in the CR, for example)
      java.lang.String getIcon()
      Returns a map icon for an arrow in this direction on the graphical map.
      StringID getId()
      Returns the id that identifies this direction in the Rules
      int hashCode()  
      CoordinateID toCoordinate()
      Returns the coordinate corresponding to the direction (i.e. the neighbor of (0,0,0) in this direction).
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DIR_INVALID

        public static final int DIR_INVALID
        Code for the invalid direction that does not correspond to any direction on the map
        See Also:
        Constant Field Values
      • INVALID

        public static final Direction INVALID
        An invalid direction that does not correspond to any direction on the map
    • Constructor Detail

      • Direction

        public Direction​(int direction,
                         StringID id,
                         CoordinateID coord,
                         java.lang.String iconName)
        Creates a new Direction object interpreting the specified integer as a direction according to the direction constants of this class.
        Parameters:
        direction - The internal direction code
        id - The id that identifies this direction in the Rules
        coord - A coordinate corresponding to the direction (i.e. the neighbor of (0,0,0) in this direction.
        iconName - A map icon for an arrow in this direction on the graphical map.
    • Method Detail

      • toString

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

        public StringID getId()
        Returns the id that identifies this direction in the Rules
      • getIcon

        public java.lang.String getIcon()
        Returns a map icon for an arrow in this direction on the graphical map.
      • toCoordinate

        public CoordinateID toCoordinate()
        Returns the coordinate corresponding to the direction (i.e. the neighbor of (0,0,0) in this direction).
      • getDirCode

        public int getDirCode()
        Returns the internal code of this direction (used in the CR, for example)
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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