Railway Track is a graphical space markup element that represents a continuous rail track (i.e. the one that does not contain any switches) of arbitrary shape. Track may contain multiple linear and/or curved segments.
The track knows switches at the either end, if there are any. If there is no switch at one of the sides (an open-ended track), and a rail car exits the track at that side, the car leaves the rail yard model.
The track knows all cars that are (fully or partially) located on it, and you can obtain those cars using the track API.
Cars on a track
To draw a railway track
You can continue drawing the railway track after you finished it with the double-click.
To add a segment to the railway track
You can change a linear line to curved and vice versa as well as edit the curve shape anytime.To change a curved line into linear
Several railway tracks can be connected together, with or without the use of a railway switch. You can disconnect the track segments too.
To connect two or more railway tracks into one track
To connect two or more railway tracks with a switch
You can connect in one railway switch as many tracks as you need.
You might want to split the railway track into several tracks by segments.
To disconnect the railway track segments
Name – The name of the track. The name is used to identify and access the track from code and flowchart blocks properties.
Ignore – If selected, the track is excluded from the model.
Visible on upper level – If selected, the track is also visible on the upper level where this agent lives.
Lock – If selected, the railway track is locked. Locked shapes do not react to mouse clicks - it is impossible to select them in the graphical editor until you unlock them. It is frequently needed when you want to prevent editing this shape while drawing other shapes over it.
Visible – Here you specify whether the shape is visible on animation at model runtime, or not. Using the control, choose yes or no.
Bidirectional - Here you can enable movement on the railway track in both directions.
Type – The type of the element is Railroad.
Track gauge – The spacing of the rails on a railway track, which is measured between the inner faces of the load-bearing rails.
X – X-coordinate of the track's start point.
Y – Y-coordinate of the track's start point.
Z – [Enabled if Show in 3D option is selected] Z-coordinate of the track's start point.
The table located in the Points property section enables users to view and adjust coordinates of the track turning points.
Here you define
relative coordinates, not the absolute
ones. The first point always has coordinates (0, 0,
that can not be
Other rows of the table define relative coordinates of the successive points. Coordinates of each point are actually offsets of the corresponding point from the start point along X, Y (and optionally Z) axes correspondingly.
Show in - Here you can choose whether you want the shape to be shown both in 2D and 3D animation, or in 2D only, or in 3D only.
Show name – If selected, the track's name is displayed on the graphical diagram.
The track has start point and end point, and therefore has orientation. The exact position on the track may be defined by the specific markup element Position on Track.
To know the direction of the track, select it in the graphical diagram by a mouse click.
To change the direction of the track
int nCars() - Returns the number of cars on the track (including cars that are only partially there).
Agent getFirstCar() - Returns the car closest to the beginning of the track, or null if the track is empty.
Agent getLastCar() - Returns the car closest to the end of the track, or null if the track is empty.
Agent getCar( int index ) - Returns a car on the track with a given index counted from the beginning of the track. All cars count: moving, standing, coupled, and cars that are only partially on this track.
Parameter: index the index of the car
LinkedList< Agent > getCars() - Returns the list of rail cars that are (maybe, partially) located on this track.
boolean isEmpty() - Tests if the track is empty, i.e. there are no cars that are (even partially) on the track. Returns true if the track is empty, false otherwise.
double getFreeSpace( boolean fromstart ) - Tests the availability of space on the track. If there are no cars on the track, returns infinity. If there are cars, returns the distance from the track start or end point (depending on the fromstart parameter) to the nearest car. If there is a car that has partially entered or exited the track at a given side, the functions returns a negative value.
Parameter: fromstart - if true, space is checked from the start point of the track, otherwise from the end point
RailwaySwitch getStartSwitch() - Returns switch (Switch object) at the beginning of the track.
RailwaySwitch getEndSwitch() - Returns switch at the end of the track.
RailwaySwitch getSwitch( boolean atend ) - Returns the switch at the beginning or at the end of the track.
Parameter: atend - if true - the switch at the end is returned, otherwise at the beginning
RailwaySwitch getOtherSwitch(RailwaySwitch sw) - If the given switch is a 'start switch' of this track, the function returns current track's 'end switch', otherwise it returns 'source switch'. Note that this function doesn't check that the given is either 'start switch' or 'end switch': this is the responsibility of the user calling this function.
Parameters: sw - the switch (one of the track endings)
void setColor(Color color) - Sets the color of the shape.
Parameters: color - the new color, if null the track is not drawn
void setColor(Paint color) - Sets the texture of the shape.
Parameter: color - the new color, if null the track is not drawn
Color getColor() - Returns the color of the shape, or null if shape has no color or if it has texture (in this case getTexture() should be used instead).
Texture getTexture() - Returns the texture of the shape, if the shape has texture.
double length() - Returns the length of the track.
- Sets the width
of the track, 0 means thinest possible.
Parameter: width - the new width of the track, in pixels
setWidth(double width, LengthUnits units)
- Sets the width
of the track, 0 means thinest possible.
Parameters: width - the new width of the track, measured in given units
units - a constant defining the length units
double getWidth() - Returns the width of the track, measured in pixels.
- Returns the
of the track, measured in given units.
Parameter: units - a constant defining the length units
RailwayNetwork getRailYard() - Returns rail yard (railway network) this track belongs to, or null if it is not a part of a rail yard.
setVisible(boolean v) - Sets the visibility of the track.
Parameter: v - visibility of the track. If true, track is visible, if false - not visible.
boolean isVisible() - Returns the visibility of the track. If it returns true, the track is visible, if false - not visible.
Position on track
API reference: RailwayTrack class