AnyLogic
Expand
Font size
All Implemented Interfaces:
AggregatableAnimationElement, HasLevel, RailMarkup, SVGElement, java.io.Serializable

public class RailwaySwitch
extends AbstractRailwayMarkup
See Also:
Serialized Form

Nested Class Summary

Nested Classes 
static interface  RailwaySwitch.IRailwaySwitchType  
Modifier and Type Class Description

Constructor Summary

Constructors 
RailwaySwitch()  
RailwaySwitch​(Agent owner, ShapeDrawMode drawMode, boolean isPublic)
Deprecated.
deprecated in version 8.4, will be removed in the future releases
RailwaySwitch​(Agent owner, ShapeDrawMode drawMode, boolean isPublic, double radius, java.awt.Color selectionColor, java.awt.Paint color, RailwaySwitch.IRailwaySwitchType type, RailwayTrack... tracks)  
RailwaySwitch​(Agent owner, ShapeDrawMode drawMode, boolean isPublic, double radius, java.awt.Color selectionColor, java.awt.Paint color, RailwayTrack track, RailwayTrack... alternativeTracks)
Deprecated.
deprecated in version 8.4, will be removed in the future releases
Constructor Description

Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods 
void connectTracks​(RailwayTrack source, RailwayTrack target)
The switch is set to the state (one of them, if several) which allows the travel from source to target track
boolean contains​(double px, double py)
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e.
RailwayTrack currentStateNextTrack​(RailwayTrack source)
Returns the next track (for the current state), if the switch is approached from a given track.
java.util.List<RailwayTrack> getAlternativeTracks()
Deprecated.
Switches with more than 3 connected tracks do not have a notion of "Alternative Tracks"
java.util.List<RailwayTrack> getAvailableTracks​(RailwayTrack source)
Finds all the tracks that are available to go to if we approach the switch from source track
java.awt.Paint getColor()
Returns the color (or texture) of the switch.
SwitchDataSource getDataSource()  
RailwayTrack getMainTrack()
Deprecated.
Switches with more than 3 connected tracks do not have a notion of "Main Track"
double getRadius()
Returns the radius of this switch
RailwayTrack getSelectedTrack()
Deprecated.
Switches with more than 3 connected tracks do not have a notion of "Selected Track".
java.awt.Color getSelectionColor()
Returns the color of the line animating the current switch position at model runtime.
int getToggleCount()
Get the number of times the switch was toggled
RailwayTrack getTrack​(int index)
Returns the track with a given index connected to the switch.
java.util.List<RailwayTrack> getTracks()
Returns the list of all tracks connected to this switch
double getX()
Returns X coordinate of this element
double getY()
Returns Y coordinate of this element
double getZ()
Returns Z coordinate of this element
boolean isTrailingPoint​(RailwayTrack from)
Tests if movement from a given track through the switch is a trailing point movement or face point.
RailwayTrack nextTrack​(RailwayTrack source)
Returns the next track, if the switch is approached from a given track.
boolean onClick​(double clickx, double clicky)
Should be overridden to define the shape reaction on mouse click.
void setAllToAllType()
Sets the type of the switch to All to All.
void setColor​(java.awt.Paint color)
Sets the color (or texture) of the switch.
void setDoubleSlipType()
Sets the type of the switch to Double Slip.
void setNextFeasibleState​(RailwayTrack source)  
void setRadius​(double radius)
Sets the radius of this switch
void setSelectedTrack​(RailwayTrack track)
Deprecated.
Switches with more than 3 connected tracks do not have a notion of "Selected Track" Use connectTracks(RailwayTrack, RailwayTrack) to set a switch state in which 2 specified tracks are connected (if such state exists)
void setSelectionColor​(java.awt.Color selectionColor)
Sets the color of the line animating the current switch position at model runtime.
void setSingleSlipType​(RailwayTrack track)
Sets the type of the switch to Single Slip.
void setSwitch​(RailwayTrack track, RailwayTrack... alternativeTracks)
Deprecated.
void setTracks​(RailwayTrack... tracks)
Sets the tracks that are connected to the switch.
void setType​(RailwaySwitch.IRailwaySwitchType type)  
boolean stateExists​(RailwayTrack source, RailwayTrack target)
Checks if there is a state in which you can travel through switch from source track to target track
void toggle()
Toggles the selected tracks.
boolean trackStarts​(RailwayTrack track)
Returns true if a given track start at the switch, and false if it ends there.
Modifier and Type Method Description

Methods inherited from class com.anylogic.engine.markup.AbstractRailwayMarkup

getDrawMode, getLevel, getOutsideLevelZ, getRailYard

Methods inherited from class com.anylogic.engine.markup.MarkupShape

error, getFullName, getPresentable, getSpace, initialize, isClickHandled, isPublic, remove, setDrawMode, setOwner

Methods inherited from class com.anylogic.engine.markup.AbstractMarkup

discardOwner, executeUserAction, findSVGElement, getName, getSVGId, initializeInternal, isVisible, onAggregatorInitialized, onAggregatorVisibilityChanged, removeSVGFromOwner, resetSVGState, setVisible, updateDynamicProperties, updateDynamicPropertiesStructural, updateSVGProperties

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement

postInitialize

Constructor Detail

RailwaySwitch

public RailwaySwitch()

RailwaySwitch

@Deprecated
public RailwaySwitch​(Agent owner,
                     ShapeDrawMode drawMode,
                     boolean isPublic)
Deprecated.
deprecated in version 8.4, will be removed in the future releases
Parameters:
owner -
drawMode -
isPublic -

RailwaySwitch

@AnyLogicInternalCodegenAPI
public RailwaySwitch​(Agent owner,
                     ShapeDrawMode drawMode,
                     boolean isPublic,
                     double radius,
                     java.awt.Color selectionColor,
                     java.awt.Paint color,
                     RailwaySwitch.IRailwaySwitchType type,
                     RailwayTrack... tracks)
Parameters:
owner -
drawMode -
isPublic -
radius -
selectionColor -
color -
type -
tracks -

RailwaySwitch

@AnyLogicInternalAPI
@Deprecated
public RailwaySwitch​(Agent owner,
                     ShapeDrawMode drawMode,
                     boolean isPublic,
                     double radius,
                     java.awt.Color selectionColor,
                     java.awt.Paint color,
                     RailwayTrack track,
                     RailwayTrack... alternativeTracks)
Deprecated.
deprecated in version 8.4, will be removed in the future releases
Parameters:
owner -
drawMode -
isPublic -
radius -
selectionColor -
color -
track -
alternativeTracks -

Method Detail

getDataSource

@AnyLogicInternalAPI
public SwitchDataSource getDataSource()

setTracks

public void setTracks​(RailwayTrack... tracks)
Sets the tracks that are connected to the switch. Can be used only when creating the switch by code.
Parameters:
tracks - tracks that are connected to the switch

setType

@AnyLogicInternalAPI
public void setType​(RailwaySwitch.IRailwaySwitchType type)

setSingleSlipType

public void setSingleSlipType​(RailwayTrack track)
Sets the type of the switch to Single Slip. Can be used only when creating the switch by code.
Parameters:
track - the track that allows switching the lane. That is there will be two available tracks to go to when approaching the switch from this track.

setDoubleSlipType

public void setDoubleSlipType()
Sets the type of the switch to Double Slip. Can be used only when creating the switch by code.

setAllToAllType

public void setAllToAllType()
Sets the type of the switch to All to All. Can be used only when creating the switch by code.

setSwitch

@Deprecated
public void setSwitch​(RailwayTrack track,
                      RailwayTrack... alternativeTracks)
Deprecated.

getX

public double getX()
Returns X coordinate of this element
Returns:
X coordinate of this element

getY

public double getY()
Returns Y coordinate of this element
Returns:
Y coordinate of this element

getZ

public double getZ()
Returns Z coordinate of this element
Returns:
Z coordinate of this element

getRadius

public double getRadius()
Returns the radius of this switch
Returns:
the radius of this switch

setRadius

public void setRadius​(double radius)
Sets the radius of this switch
Parameters:
radius - of this switch

getSelectionColor

public java.awt.Color getSelectionColor()
Returns the color of the line animating the current switch position at model runtime.
Returns:
the color of the line animating the current switch position at model runtime.

setSelectionColor

public void setSelectionColor​(java.awt.Color selectionColor)
Sets the color of the line animating the current switch position at model runtime.
Parameters:
selectionColor - new selection color

getColor

public java.awt.Paint getColor()
Returns the color (or texture) of the switch.
Returns:
the color (or texture) of the switch.

setColor

public void setColor​(java.awt.Paint color)
Sets the color (or texture) of the switch.
Parameters:
color - the color (or texture) of the switch.

getToggleCount

public int getToggleCount()
Get the number of times the switch was toggled
Returns:
the number of times the switch was toggled

getMainTrack

@Deprecated
public RailwayTrack getMainTrack()
Deprecated.
Switches with more than 3 connected tracks do not have a notion of "Main Track"

getAlternativeTracks

@Deprecated
public java.util.List<RailwayTrack> getAlternativeTracks()
Deprecated.
Switches with more than 3 connected tracks do not have a notion of "Alternative Tracks"

getTracks

public java.util.List<RailwayTrack> getTracks()
Returns the list of all tracks connected to this switch
Returns:

getTrack

public RailwayTrack getTrack​(int index)
Returns the track with a given index connected to the switch.
Parameters:
index - index of the track
Returns:
the track with a given index connected to the switch.

getSelectedTrack

@Deprecated
public RailwayTrack getSelectedTrack()
Deprecated.
Switches with more than 3 connected tracks do not have a notion of "Selected Track". Use currentStateNextTrack(RailwayTrack) to find the next track in the current switch position
Returns the currently selected track.
Returns:
the currently selected track.

setSelectedTrack

@Deprecated
public void setSelectedTrack​(RailwayTrack track)
Deprecated.
Switches with more than 3 connected tracks do not have a notion of "Selected Track" Use connectTracks(RailwayTrack, RailwayTrack) to set a switch state in which 2 specified tracks are connected (if such state exists)
Selects one of the two alternative track. If a car is over the switch, signals error.
Parameters:
track - the track to select

getAvailableTracks

public java.util.List<RailwayTrack> getAvailableTracks​(RailwayTrack source)
Finds all the tracks that are available to go to if we approach the switch from source track
Parameters:
source - the track
Returns:
an ArrayList of available tracks

stateExists

public boolean stateExists​(RailwayTrack source,
                           RailwayTrack target)
Checks if there is a state in which you can travel through switch from source track to target track
Parameters:
source - source track
target - target track
Returns:
true if there is such a state

connectTracks

public void connectTracks​(RailwayTrack source,
                          RailwayTrack target)
The switch is set to the state (one of them, if several) which allows the travel from source to target track
Parameters:
source - source track
target - target track

toggle

public void toggle()
Toggles the selected tracks.

nextTrack

public RailwayTrack nextTrack​(RailwayTrack source)
Returns the next track, if the switch is approached from a given track. If the current switch state does not allow movement from the source track then the method returns the next track in the next feasible (for the source track) state (without changing the state)
Parameters:
source - the track from which the switch is being approached
Returns:
the next track

currentStateNextTrack

public RailwayTrack currentStateNextTrack​(RailwayTrack source)
Returns the next track (for the current state), if the switch is approached from a given track.
Parameters:
source - the track from which the switch is being approached
Returns:
the next track for the current state, null if the source track does not belong to the current state.

setNextFeasibleState

@AnyLogicInternalAPI
public void setNextFeasibleState​(RailwayTrack source)

isTrailingPoint

public boolean isTrailingPoint​(RailwayTrack from)
Tests if movement from a given track through the switch is a trailing point movement or face point. Will signal error if the track is not connected to the switch. Only applicable to 1-2 switches (1-1 case is trivial).
Parameters:
from - the track by which the switch is being approached
Returns:
true if trailing point, false if facing point

trackStarts

public boolean trackStarts​(RailwayTrack track)
Returns true if a given track start at the switch, and false if it ends there.
Parameters:
track - the track
Returns:
true if the track starts here, false if it ends

contains

public boolean contains​(double px,
                        double py)
Description copied from class: MarkupShape
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e. in the same system with the coordinates of this shape, x and y)
Specified by:
contains in class MarkupShape
Parameters:
px - the x coordinate relative to this shape's container
py - the y coordinate relative to this shape's container
Returns:
true if the shape contains the point with the given coordinates

onClick

@AnyLogicInternalCodegenAPI
public boolean onClick​(double clickx,
                       double clicky)
Description copied from class: MarkupShape
Should be overridden to define the shape reaction on mouse click. The click coordinates are definitely within the shape bounds if this method is called. By default, does nothing and returns false.
Overrides:
onClick in class MarkupShape
Parameters:
clickx - the x coordinate of the click relative to the shape
clicky - the y coordinate of the click relative to the shape
Returns:
always return false here.
How can we improve this article?