JTraffic Screensaver

Sections, Groups, Lines, Scenes

The most important portions of the Timetable file are the Movements.  These are all of the lines that do not begin with the dollar sign ( $) and are not comment lines.  They describe trains and their behaviours on the screen.  For simplicity's sake in this document, all vehicles travelling across the screen will be described as "trains" even though images of many other types of vehicles (airplanes, ships, spaceships and even people and animals) can be used in Traffic and are controlled by these same commands.  A train is furthermore defined as one or more vehicles; therefore, a locomotive travelling "light" (without cars) across the screen is also called a train.\
\
The Movements all take place on a stretch of roadbed - with exception of the scenes.  They require a specific amount of vertical space to take place.  If not otherwise specified, the vertical position of the Movements on the screen is randomly selected.  This vertical position determines the placement and the Movement begins: foreground and background pictures are placed on the screen, trains appear, complete their Movement commands and foreground and background pictures are removed.  Then the next Movement is selected, placed on the screen, run and removed.  If there is not enough room on the screen for the next Movement command, the program will wait until there is sufficient space on the screen before running the next Movement - the Movements compete for the screen area in order to run.\
\
In contrary, a scene is a defined area - usually filled by a background picture, but that is not necessary. Inside the scene you can specify many paths - places where movements can take place. These paths can overlap - either fully, or only partially. Each path has its individual control - they behave as independent lines. The vehicles travelling on these paths are treated as if the paths lay in front of/behind each other in a predefined form.  One may even place background/foreground elements behind the "back" and/or before the "front" path, but also between the paths themselves.\

A Section (the command $SECTION, the corresponding end command $ENDSECTION and the Movements and any further subsections contained therein) behaves from outside just like a single Movement.  It reserves a specific amount of space on the screen, occupies it, runs for a specific time, ends and the area of the screen is free to be used again.

Essentially a Section inside behaves like the screen itself: it reserves space inside itself for further sub-Sections ("children"), the Movements and other Sections between the $SECTION and $ENDSECTION commands.

A Group is a much simpler construct.  It behaves not like a screen, but like an individual line.  It can only contain Movements; no $SECTION, $GROUP or $LINE commands may appear between $GROUP and $ENDGROUP commands.

All Movements in a Group take place at exactly the same place on the screen.  If the $GROUP command contains any of the FG= ; BG= ; W= ; WP= ; parameters, foreground and background, or at least the type of roadbed specified, will be drawn on the screen before the beginning of the first Movement in the Group and will remain until the final Movement in the Group has completed.  This means that the identical background (if used) will remain on the screen for all of the trains in the Group.  The waypoints along the roadbed are defined by the specification of roadbed and/or foreground and background pictures in the $GROUP command.  Individual waypoints cannot be defined inside the Movements themselves. (In contrary, if you specify FG= ; BG= ; W= ; WP= ; parameters in a section, they will be only inherited by the movements and segments contained inside: each movement (having no own definition of these parameters) will show the same foreground/background, but these foreground/background will disappear at the end of the movement, and will be shown at the begging (perhaps on another vertical position).

The first version of the Traffic screensaver could only use Lines.  All Movements were based on lines and their position was fixed when the program started.  The number and position of the lines was determined mathematically on the values in the ABOVE, BELOW, MINSPACE, and MAXLINE parameter (and the IMGY parameter--the maximum vehicle height set in the Stock List file.)  In the present version, lines for Movements are generally placed on the screen at random, but the fixed line function from the earlier versions can be imitated by using the $LINE command in the Timetable file.  Since each $SECTION appears to its children as if it were the screen itself, it is possible to use $LINE commands not only in the Timetable file as a whole, but also inside a $SECTION.  Here too the possible number and position of fixed lines is dependent on the ABOVE, IMGY, BELOW, MINSPACE and MAXLINE parameters: the parameter MAXLINE determines the maximum number of lines.  If the height of the Section or screen divided by the space necessary for each individual line (the sum of the ABOVE, IMGY, MINSPACE and MAXLINE values) results in a different value, then the lower of the two is utilized.  The possible number of such lines and their positions (the distance between them) is computed.  This computation determines the possible number and placement of fixed lines inside a Section or within the screen parameters.

The Movements occurring between a $LINE and the following $ENDLINE command belong to this Line.  For compatibility reasons (and because a $LINE cannot recursively contain another $LINE) the composition of the Movements inside a $LINE must always be terminated with a corresponding $ENDLINE.  The composition is automatically terminated by the appearance of an $ENDSECTION, $GROUP, $SECTION or another $LINE command.

There are two formats of the $LINE command: with and without an   L= ; parameter for the Line number.  If a $LINE command has this parameter, it occupies exactly the Line(s) which are specified on the parameter.  If these number more than one line, the constructs belonging to the $LINE command are dynamically assigned to the containing Line.  Therefore, the roadbed, which has just seen a Movement, will receive another Movement (depending on the SEQUENCE parameter.)   If the default contains more Lines than are actually possible, the remainder will be discarded.  If all of the numbers of a $LINE command must be discarded then the applicable Movements will not take place.

If the $LINE command has no L= parameter, then all of the Movements belonging to this $LINE will occupy all available lines which are not yet assigned numbers by $LINE commands.  In this case, the entire available space inside the screen (or inside a Section) will be taken up by fixed Lines.  No further Groups, Sections, Segments or Movements beyond the Movements connected with this $LINE can run and will be ignored by the program.

If only $LINE commands with an explicit list of lines are used, it is possible that the remainder of the screen or Section is available.  Other elements not belonging to any of the $LINE s can run in this space.  These additional Movements are randomly positioned inside the area which has not already been reserved by the $LINE command.

The $SCENE command opens a combined structure. It allocates a vertical space given by its HEIGHT=; parameter. It can contain one or more $PATH commands. The $PATH commands define the tracks which the vehicles move on. The Y=; parameter of the $PATH command determines the track position - the base line the vehicles move on. The coordinate system of the $SCENE command starts at the bottom of the allocated area and expands upwards. The movements contained between the $PATH and the corresponding $ENDPATH command will be run at this position. The foreground and background definitions in the $PATH command have the usual coordinate system: 0 is the rail surface.

The $PATH track defined first will be positioned before all of the other paths.  The $PATH track defined last will be furthest to the "back" - it will be covered by all other paths. The height of the track - the maximum height of the vehicles running on it - should be defined. It normal cases the inherited value of the IMGY=; parameter fits most needs.   If you use the MM&MM-compatible vehicle set delivered by Traffic, the majority of the vehicles fit into 58-pixel height. If you want to use some of the few vehicles, which are higher, you should specify the height by the IMGY=; parameter--as well as for the other segmentation commands or simple movements too. The other two size parameters ( ABOVE=; and BELOW=; ) are non-existent for the $PATH command as the area occupied by background and foreground pictures is already fixed by the size of the containing $SCENE command and by the position of the $PATH.

Both the $SCENE and the $PATH commands can have background and foreground pictures. The sequence these will be placed (from the nearest to the farthest from viewer) is:

- foreground of the $SCENE

- foreground of the first $PATH

---- the vehicles of the first $PATH move here

- background of the first $PATH

- foreground of the second $PATH

---- the vehicles of the second $PATH move here

- background of the second $PATH

...

- foreground of the last $PATH

---- the vehicles of the first $PATH move here

- background of the last $PATH

- background of the $SCENE

As one can see, each layer between the moving vehicles or in front of the nearest / behind the furthest path can be accessed by two different ways. Of course, one can place objects in all of the aforementioned layers, but the same result occurs as when you use only one of the two possibilities.

Each $PATH command has its own movement set, which will run at the given position. These movements run independently from each other. The lifetime of the $SCENE segment is delimited similar way as for the $SEGMENT command. If all of the $PATH commands have terminated their movements, or the $SCENE is terminated (for example by the time it is allowed to run), the whole $SCENE will be cleared together. Even if no more movements will be started in a track defined by a $PATH command, the foreground / background elements remain on the screen: all of the foregrounds/backgrounds belong together.

In the actual version no animations are allowed on the foreground or background elements of a scene on of their path elements. This limitation will be removed in a futura version.

How long do these complex elements (Sections, Groups, fixed Lines) remain on the screen?  Fixed Lines have no individual lifetime.  They only exist as long as their parent section does.  The absolute Section (the window or the full-screen with the screensaver) "lives" until the user ends the program by pressing a key, selects something from a menu, or moves the mouse, depending on the settings of the $NOSTOPONMOVE, $NOSTOPONKEY and $NOSTOPONCLICK commands or the comparable configuration settings.  The default lifetime of a Section or Group is as long as it takes for all of its children to run once.  One can, however, specify the lifetime with parameters - the lifetime can be limited to a specific number of Movements, to an amount of time in seconds, or can also be unlimited.

All Sections, Groups and Lines have their own composition of Movements (or, in the case of Sections, also sub-Sections.)  They select their next Movements for display on the screen depending on default criteria.  If a specific value for the SEQUENCE = ; parameter is not specified, the default sequence is inherited from the parent Sections.  You can specify how the program will run each Section using the global $SEQUENCE command.  If this is not specified, then the default from the Configuration window are used (depending on whether the program is run full-screen or in windowed mode.)

The lifetime of a Section and the sequence of the Movements contained within are completely independent things.  Each section "remembers" which Movements have run.  If the lifetime is shorter than the time it will take to run all of the Movements in the Section and the selected sequence is not set to fully random, the Section will continue with its work of serving the lines to the screen whenever it next runs.  If the sequence is set to FIXED or CONTINUED, the next Movement will be the one immediately following the Movement that last ran in the previous lifetime.  If RANDOM_SEQUENCE is selected, the repetition of a Movement will be avoided until all other Movements have run once.  The only difference between FIXED and CONTINUED is, that after a stop and restart of the screensaver (or after a start caused by pressing the "Test" button in the Configuration window) FIXED will always start at the beginning and CONTINUED remembers where to start from based on where it stopped during its last lifetime.

In the following section the individual parameters of the $SECTION , $GROUP and $LINE commands are described.  The common parameters for determining dimensions, lifetime, pathway and descriptive text, run sequence are described in subchapters.

Overview
The Configuration Window
Program Window
Stock List
Description Editor
Graphic Testpad
Timetable Editor
Timetable Syntax and Semanics
The timetable header
Sections, Groups, Lines, Scenes
Actions
Stock List File