Class Route

java.lang.Object
id.klacak.bus_navigator.Route
Direct Known Subclasses:
Feeder

public class Route extends Object
A transit route with an ordered, circular sequence of stops.
  • Constructor Details

    • Route

      public Route(String shortName, String longName, String color, String textColor)
      Creates a route with its identifying names and display colors.
      Parameters:
      shortName - route code
      longName - descriptive route name
      color - route background color in hexadecimal format
      textColor - route text color in hexadecimal format
  • Method Details

    • getShortName

      public String getShortName()
      Gets the short code identifying this route.
      Returns:
      the route code
    • getLongName

      public String getLongName()
      Gets the full descriptive name of this route.
      Returns:
      the descriptive route name
    • getColor

      public String getColor()
      Gets the background color used to display this route.
      Returns:
      the route background color in hexadecimal format
    • getTextColor

      public String getTextColor()
      Gets the text color used to display this route.
      Returns:
      the route text color in hexadecimal format
    • getNameFormatted

      public String getNameFormatted()
      Formats the route code and name with ANSI terminal colors.
      Returns:
      colored route code and name
    • getStops

      public List<Stop> getStops()
      Gets the stops associated with this route, in travel order.
      Returns:
      the mutable list of stops
    • addStop

      public void addStop(Stop newStop)
      Appends a stop to the route and associates this route with that stop.
      Parameters:
      newStop - stop to append
    • stopPosition

      public int stopPosition(Stop targetStop)
      Finds the first position of a stop in this route.
      Parameters:
      targetStop - stop to locate
      Returns:
      zero-based position, or -1 if the stop is not on this route
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      a text map of this route and its stops in travel order