Package jmri.jmrit.timetable.swing
Class TimeTableGraphCommon
- java.lang.Object
-
- jmri.jmrit.timetable.swing.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.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int_arriveTime(package private) TimeTableDataManager_dataMgr(package private) int_departTime(package private) double_dimHeight(package private) double_dimWidth(package private) java.lang.String_direction(package private) int_duration(package private) boolean_firstStop(package private) double_firstX(package private) java.awt.Graphics2D_g2(package private) double_graphBottom(package private) double_graphHeight(package private) double_graphLeft(package private) double_graphRight(package private) double_graphTop(package private) double_graphWidth(package private) java.util.ArrayList<java.lang.Double>_hourGrid(package private) java.util.HashMap<java.lang.Integer,java.lang.Double>_hourMap(package private) double_hourOffset(package private) int_infoColWidth(package private) boolean_lastStop(package private) double_lastX(package private) Layout_layout(package private) double_maxDistance(package private) java.awt.print.PageFormat_pf(package private) Schedule_schedule(package private) int_scheduleId(package private) Segment_segment(package private) int_segmentId(package private) boolean_showTrainTimes(package private) double_sizeMinute(package private) java.awt.Font_smallFont(package private) int_startHour(package private) java.util.HashMap<java.lang.Integer,java.lang.Double>_stationGrid(package private) java.util.List<Station>_stations(package private) java.awt.Font_stdFont(package private) int_stopCnt(package private) int_stopIdx(package private) java.util.List<Stop>_stops(package private) java.util.ArrayList<java.awt.geom.Rectangle2D>_textLocation(package private) int_throttles(package private) double_throttleX(package private) java.awt.Color_trainColor(package private) java.awt.geom.Path2D_trainLine(package private) java.lang.String_trainName(package private) java.util.List<Train>_trains(package private) int_trainThrottle(package private) static java.awt.BasicStrokegridstroke(package private) static java.awt.BasicStrokestroke
-
Constructor Summary
Constructors Constructor Description TimeTableGraphCommon()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.awt.geom.Rectangle2DadjustText(java.awt.geom.Rectangle2D textRect)Move text that overlaps existing text.(package private) doublecalculateX(int time)Convert the time value, 0 - 1439 to the x graph position.voiddoPaint(java.awt.Graphics g)(package private) voiddrawGraphGrid()(package private) voiddrawHours()(package private) voiddrawInfoSection()(package private) voiddrawLine(Stop stop)Extend the train line with additional stops.(package private) voiddrawStationSection()(package private) voiddrawThrottleNumbers()(package private) voiddrawTrainName(double x, double y, java.lang.String justify, boolean invert, boolean throttle)Draw a train name on the graph.(package private) voiddrawTrains()Create the train line for each train with labels.(package private) voiddrawTrainTime(int time, java.lang.String mode, double x, double y)Draw the minutes value on the graph if enabled.(package private) voidinit(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) voidsetBegin(Stop stop)Set the starting point for the _trainLine path.(package private) voidsetDirection()Determine direction of travel on the graph: up or down(package private) voidsetEnd(Stop stop, boolean endSegment)Finish the train line, draw it, the train name and the throttle line if used.
-
-
-
Field Detail
-
_stdFont
final java.awt.Font _stdFont
-
_smallFont
final java.awt.Font _smallFont
-
gridstroke
static final java.awt.BasicStroke gridstroke
-
stroke
static final java.awt.BasicStroke stroke
-
_dataMgr
TimeTableDataManager _dataMgr
-
_segmentId
int _segmentId
-
_scheduleId
int _scheduleId
-
_throttles
int _throttles
-
_startHour
int _startHour
-
_duration
int _duration
-
_stationGrid
java.util.HashMap<java.lang.Integer,java.lang.Double> _stationGrid
-
_hourMap
java.util.HashMap<java.lang.Integer,java.lang.Double> _hourMap
-
_hourGrid
java.util.ArrayList<java.lang.Double> _hourGrid
-
_infoColWidth
int _infoColWidth
-
_hourOffset
double _hourOffset
-
_graphHeight
double _graphHeight
-
_graphWidth
double _graphWidth
-
_graphTop
double _graphTop
-
_graphBottom
double _graphBottom
-
_graphLeft
double _graphLeft
-
_graphRight
double _graphRight
-
_g2
java.awt.Graphics2D _g2
-
_showTrainTimes
boolean _showTrainTimes
-
_pf
java.awt.print.PageFormat _pf
-
_dimHeight
double _dimHeight
-
_dimWidth
double _dimWidth
-
_textLocation
java.util.ArrayList<java.awt.geom.Rectangle2D> _textLocation
-
_trainName
java.lang.String _trainName
-
_trainThrottle
int _trainThrottle
-
_trainColor
java.awt.Color _trainColor
-
_trainLine
java.awt.geom.Path2D _trainLine
-
_stopCnt
int _stopCnt
-
_stopIdx
int _stopIdx
-
_arriveTime
int _arriveTime
-
_departTime
int _departTime
-
_maxDistance
double _maxDistance
-
_direction
java.lang.String _direction
-
_firstStop
boolean _firstStop
-
_lastStop
boolean _lastStop
-
_firstX
double _firstX
-
_lastX
double _lastX
-
_sizeMinute
double _sizeMinute
-
_throttleX
double _throttleX
-
-
Constructor Detail
-
TimeTableGraphCommon
public TimeTableGraphCommon()
-
-
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 heightwidth- Display widthdisplayType- (not currently used)
-
doPaint
public void doPaint(java.awt.Graphics g)
-
drawInfoSection
void drawInfoSection()
-
drawStationSection
void drawStationSection()
-
drawHours
void drawHours()
-
drawThrottleNumbers
void drawThrottleNumbers()
-
drawGraphGrid
void drawGraphGrid()
-
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.
-
-