Package jmri.jmrit.timetable.swing
Class TimeTableGraphCommon
java.lang.Object
jmri.jmrit.timetable.swing.TimeTableGraphCommon
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
FieldsModifier and TypeFieldDescription(package private) int(package private) TimeTableDataManager(package private) int(package private) double(package private) double(package private) String(package private) int(package private) boolean(package private) double(package private) Graphics2D(package private) double(package private) double(package private) double(package private) double(package private) double(package private) double(package private) double(package private) int(package private) boolean(package private) double(package private) Layout(package private) double(package private) PageFormat(package private) Schedule(package private) int(package private) Segment(package private) int(package private) boolean(package private) double(package private) final Font(package private) int(package private) final Font(package private) int(package private) int(package private) ArrayList<Rectangle2D>(package private) int(package private) double(package private) Color(package private) Path2D(package private) String(package private) int(package private) static final BasicStroke(package private) static final BasicStroke -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Rectangle2DadjustText(Rectangle2D textRect) Move text that overlaps existing text.(package private) doublecalculateX(int time) Convert the time value, 0 - 1439 to the x graph position.void(package private) void(package private) void(package private) void(package private) voidExtend the train line with additional stops.(package private) void(package private) void(package private) voiddrawTrainName(double x, double y, String justify, boolean invert, boolean throttle) Draw a train name on the graph.(package private) voidCreate the train line for each train with labels.(package private) voiddrawTrainTime(int time, 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) voidSet the starting point for the _trainLine path.(package private) voidDetermine direction of travel on the graph: up or down(package private) voidFinish the train line, draw it, the train name and the throttle line if used.
-
Field Details
-
_stdFont
-
_smallFont
-
gridstroke
-
stroke
-
_dataMgr
-
_segmentId
int _segmentId -
_scheduleId
int _scheduleId -
_layout
-
_throttles
int _throttles -
_segment
-
_schedule
-
_startHour
int _startHour -
_duration
int _duration -
_stations
-
_trains
-
_stops
-
_stationGrid
-
_hourMap
-
_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
-
_showTrainTimes
boolean _showTrainTimes -
_pf
-
_dimHeight
double _dimHeight -
_dimWidth
double _dimWidth -
_textLocation
-
_trainName
-
_trainThrottle
int _trainThrottle -
_trainColor
-
_trainLine
-
_stopCnt
int _stopCnt -
_stopIdx
int _stopIdx -
_arriveTime
int _arriveTime -
_departTime
int _departTime -
_maxDistance
double _maxDistance -
_direction
-
_firstStop
boolean _firstStop -
_lastStop
boolean _lastStop -
_firstX
double _firstX -
_lastX
double _lastX -
_sizeMinute
double _sizeMinute -
_throttleX
double _throttleX
-
-
Constructor Details
-
TimeTableGraphCommon
public TimeTableGraphCommon()
-
-
Method Details
-
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
-
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
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
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
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
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
Extend the train line with additional stops.- Parameters:
stop- The current stop.
-
setEnd
Finish the train line, draw it, the train name and the throttle line if used.- Parameters:
stop- The current stop.endSegment- final segment
-
calculateX
Convert the time value, 0 - 1439 to the x graph position.- Parameters:
time- The time value.- Returns:
- the x value.
-