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.BasicStroke
gridstroke
(package private) static java.awt.BasicStroke
stroke
-
Constructor Summary
Constructors Constructor Description TimeTableGraphCommon()
-
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.
-
-
-
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.
-
-