Class TimeTableGraphCommon


  • public class TimeTableGraphCommon
    extends java.lang.Object
    The left column has the layout information along with the station names next to the diagram box. The column width is dynamic based on the width of the items. Across the top, lined up with the diagram box, are the throttle lines. The main section is the diagram box. Across the bottom, lined up with the diagram box, is the hours section.
           +--------- canvas -------------+
           | info    | throttle lines     |
           |         |+------------------+|
           | station ||                  ||
           | station || diagram box      ||
           | station ||                  ||
           |         |+------------------+|
           |         | hours              |
           +------------------------------+
     
    A normal train line will be "a-b-c-d-e" for a through train, or "a-b-c-b-a" for a turn.

    A multi-segment train will be "a1-b1-c1-x2-y2-z2" where c is the junction. The reverse will be "z2-y2-z2-c2-b1-a1". Notice: While c is in both segments, for train stop purposes, the arrival "c" is used and the departure "c" is skipped.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) java.awt.geom.Rectangle2D adjustText​(java.awt.geom.Rectangle2D textRect)
      Move text that overlaps existing text.
      (package private) double calculateX​(int time)
      Convert the time value, 0 - 1439 to the x graph position.
      void doPaint​(java.awt.Graphics g)  
      (package private) void drawGraphGrid()  
      (package private) void drawHours()  
      (package private) void drawInfoSection()  
      (package private) void drawLine​(Stop stop)
      Extend the train line with additional stops.
      (package private) void drawStationSection()  
      (package private) void drawThrottleNumbers()  
      (package private) void drawTrainName​(double x, double y, java.lang.String justify, boolean invert, boolean throttle)
      Draw a train name on the graph.
      (package private) void drawTrains()
      Create the train line for each train with labels.
      (package private) void drawTrainTime​(int time, java.lang.String mode, double x, double y)
      Draw the minutes value on the graph if enabled.
      (package private) void init​(int segmentId, int scheduleId, boolean showTrainTimes, double height, double width, boolean displayType)
      Initialize the data used by paint() and supporting methods when the panel is displayed.
      (package private) void setBegin​(Stop stop)
      Set the starting point for the _trainLine path.
      (package private) void setDirection()
      Determine direction of travel on the graph: up or down
      (package private) void setEnd​(Stop stop, boolean endSegment)
      Finish the train line, draw it, the train name and the throttle line if used.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • init

        void init​(int segmentId,
                  int scheduleId,
                  boolean showTrainTimes,
                  double height,
                  double width,
                  boolean displayType)
        Initialize the data used by paint() and supporting methods when the panel is displayed.
        Parameters:
        segmentId - The segment to be displayed. For multiple segment layouts separate graphs are required.
        scheduleId - The schedule to be used for this graph.
        showTrainTimes - When true, include the minutes portion of the train times at each station.
        height - Display height
        width - Display width
        displayType - (not currently used)
      • doPaint

        public void doPaint​(java.awt.Graphics g)
      • drawTrains

        void drawTrains()
        Create the train line for each train with labels. Include times if selected.

        All defined trains their stops are processed. If a stop has a station in the segment, it is included. Most trains only use a single segment.

      • drawTrainName

        void drawTrainName​(double x,
                           double y,
                           java.lang.String justify,
                           boolean invert,
                           boolean throttle)
        Draw a train name on the graph.

        The base location is provided by x and y. justify is used to offset the x axis. invert is used to flip the y offsets.

        Parameters:
        x - The x coordinate.
        y - The y coordinate.
        justify - "Center" moves the string left half of the distance. "Right" moves the string left the full width of the string.
        invert - If true, the y coordinate offset is flipped.
        throttle - If true, a throttle line item.
      • drawTrainTime

        void drawTrainTime​(int time,
                           java.lang.String mode,
                           double x,
                           double y)
        Draw the minutes value on the graph if enabled.
        Parameters:
        time - The time in total minutes. Converted to remainder minutes.
        mode - Used to set the x and y offsets based on type of time.
        x - The base x coordinate.
        y - The base y coordinate.
      • adjustText

        java.awt.geom.Rectangle2D adjustText​(java.awt.geom.Rectangle2D textRect)
        Move text that overlaps existing text.
        Parameters:
        textRect - The proposed text rectangle.
        Returns:
        The resulting rectangle
      • setDirection

        void setDirection()
        Determine direction of travel on the graph: up or down
      • setBegin

        void setBegin​(Stop stop)
        Set the starting point for the _trainLine path. The normal case will be the first stop (aka start) for the train.

        The other case is a multi-segment train. The first stop in the current segment will be the station AFTER the junction. That means the start will actually be at the junction station.

        Parameters:
        stop - The current stop.
      • drawLine

        void drawLine​(Stop stop)
        Extend the train line with additional stops.
        Parameters:
        stop - The current stop.
      • setEnd

        void setEnd​(Stop stop,
                    boolean endSegment)
        Finish the train line, draw it, the train name and the throttle line if used.
        Parameters:
        stop - The current stop.
        endSegment - final segment
      • calculateX

        double calculateX​(int time)
        Convert the time value, 0 - 1439 to the x graph position.
        Parameters:
        time - The time value.
        Returns:
        the x value.