Genma Saotome, on 02 October 2020 - 10:02 AM, said:
The text algorithm for the labels in Timetable Tab is the same as the DIspatch Tab and quite interesting.
The display is split into rows of equal height and associated to an array with a matching number of rows and 4 columns for each row. Each column holds the distance from the left side of the window to the start and end of the label text.
When zoomed out, there may not be room for every label.
To find the position for a label, find the nearest row vertically and draw the label if adding it would not overlap with any labels already drawn in that row.If not drawn, try one or two rows above and one or two rows below.
To avoid conflict between the platform labels and the platforms themselves, only the righmost end of the platform gets a label. The train labels are not subject to this algorithm, presumably because they are often moving.
An array is used instead of a dynamic list to avoid glitches while recovering released memory.