Package com.anylogic.engine.markup
- Nested Class Summary
- Field Summary
- Constructor Summary
- Method Summary
- Methods inherited from class com.anylogic.engine.markup.AbstractRailwayMarkup
- Methods inherited from class com.anylogic.engine.markup.MarkupShape
- Methods inherited from class com.anylogic.engine.markup.AbstractMarkup
- Methods inherited from class java.lang.Object
- Methods inherited from interface com.anylogic.engine.markup.AbstractPositionalMarkup
- Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement
- Methods inherited from interface com.anylogic.engine.presentation.SVGElement
- Methods inherited from interface com.anylogic.engine.presentation.UsdElement
- Constructor Details
- Method Details
- getDataSource
- setTracks
- setType
- setSingleSlipType
- setDoubleSlipType
- setAllToAllType
- setSwitch
- getX
- getY
- getZ
- getRadius
- setRadius
- getSelectionColor
- setSelectionColor
- getColor
- setColor
- getToggleCount
- getMainTrack
- getAlternativeTracks
- getTracks
- getTrack
- getSelectedTrack
- setSelectedTrack
- getAvailableTracks
- stateExists
- connectTracks
- toggle
- nextTrack
- currentStateNextTrack
- setNextFeasibleState
- isTrailingPoint
- trackStarts
- contains
- onClick
- java.lang.Object
- com.anylogic.engine.markup.AbstractMarkup
- com.anylogic.engine.markup.MarkupShape
- com.anylogic.engine.markup.AbstractRailwayMarkup
- com.anylogic.engine.markup.RailwaySwitch
- All Implemented Interfaces:
AbstractPositionalMarkup
,AggregatableAnimationElement
,HasLevel
,RailMarkup
,SVGElement
,UsdElement
,Serializable
public class RailwaySwitch extends AbstractRailwayMarkup implements AbstractPositionalMarkup
- See Also:
- Serialized Form
Modifier and Type | Class | Description |
---|---|---|
static interface | RailwaySwitch.IRailwaySwitchType |
Constructor | Description |
---|---|
RailwaySwitch() | |
RailwaySwitch |
Deprecated.
deprecated in version 8.4, will be removed in the future releases
|
RailwaySwitch | |
RailwaySwitch |
Deprecated.
deprecated in version 8.4, will be removed in the future releases
|
Modifier and Type | Method | Description |
---|---|---|
void | connectTracks |
The switch is set to the state (one of them, if several) which allows the travel from source to target track
|
boolean | contains |
Test if the shape contains the point with the given coordinates (relative
to this shape's container, i.e.
|
RailwayTrack | currentStateNextTrack |
Returns the next track (for the current state), if the switch is approached from a given track.
|
List<RailwayTrack> | getAlternativeTracks() |
Deprecated.
Switches with more than 3 connected tracks do not have a notion of "Alternative Tracks"
|
List<RailwayTrack> | getAvailableTracks |
Finds all the tracks that are available to go to if we approach the switch from source track
|
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".
|
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 |
Returns the track with a given index connected to the switch.
|
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 |
Tests if movement from a given track through the switch is a trailing point
movement or face point.
|
RailwayTrack | nextTrack |
Returns the next track, if the switch is approached from a given track.
|
boolean | onClick |
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 |
Sets the color (or texture) of the switch.
|
void | setDoubleSlipType() |
Sets the type of the switch to Double Slip.
|
void | setNextFeasibleState | |
void | setRadius |
Sets the radius of this switch
|
void | setSelectedTrack |
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 |
Sets the color of the line animating the current switch position at model runtime.
|
void | setSingleSlipType |
Sets the type of the switch to Single Slip.
|
void | setSwitch |
Deprecated.
use
setTracks(RailwayTrack...) and one of the methods to set switch type:
setAllToAllType() , setSingleSlipType(RailwayTrack) , setDoubleSlipType() |
void | setTracks |
Sets the tracks that are connected to the switch.
|
void | setType | |
boolean | stateExists |
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 |
Returns true if a given track start at the switch, and false if it ends
there.
|
error, getFullName, getPresentable, getSpace, initialize, isClickHandled, isPublic, remove, setDrawMode, setOwner
discardOwner, executeUserAction, findSVGElement, getName, getOrGenerateUSDId, getSVGId, initializeInternal, isVisible, onAggregatorInitialized, onAggregatorVisibilityChanged, removeSVGFromOwner, resetSVGState, setVisible, updateDynamicProperties, updateDynamicPropertiesStructural, updateSVGProperties
public 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
-
@AnyLogicInternalCodegenAPI public RailwaySwitch(Agent owner, ShapeDrawMode drawMode, boolean isPublic, double radius, Color selectionColor, Paint color, RailwaySwitch.IRailwaySwitchType type, RailwayTrack... tracks)
- Parameters:
owner
-drawMode
-isPublic
-radius
-selectionColor
-color
-type
-tracks
-
@AnyLogicInternalAPI @Deprecated public RailwaySwitch(Agent owner, ShapeDrawMode drawMode, boolean isPublic, double radius, Color selectionColor, 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
-
@AnyLogicInternalAPI public SwitchDataSource getDataSource()
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
@AnyLogicInternalAPI public void setType(RailwaySwitch.IRailwaySwitchType type)
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.
public void setDoubleSlipType()
Sets the type of the switch to Double Slip. Can be used only when creating the switch by code.
public void setAllToAllType()
Sets the type of the switch to All to All. Can be used only when creating the switch by code.
@Deprecated public void setSwitch(RailwayTrack track, RailwayTrack... alternativeTracks)
Deprecated.
use
setTracks(RailwayTrack...)
and one of the methods to set switch type:
setAllToAllType()
, setSingleSlipType(RailwayTrack)
, setDoubleSlipType()
public double getX()
Returns X coordinate of this element
- Specified by:
getX
in interfaceAbstractPositionalMarkup
- Returns:
- X coordinate of this element
public double getY()
Returns Y coordinate of this element
- Specified by:
getY
in interfaceAbstractPositionalMarkup
- Returns:
- Y coordinate of this element
public double getZ()
Returns Z coordinate of this element
- Specified by:
getZ
in interfaceAbstractPositionalMarkup
- Returns:
- Z coordinate of this element
public double getRadius()
Returns the radius of this switch
- Returns:
- the radius of this switch
public void setRadius(double radius)
Sets the radius of this switch
- Parameters:
radius
- of this switch
public 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.
public void setSelectionColor(Color selectionColor)
Sets the color of the line animating the current switch position at model runtime.
- Parameters:
selectionColor
- new selection color
public Paint getColor()
Returns the color (or texture) of the switch.
- Returns:
- the color (or texture) of the switch.
public void setColor(Paint color)
Sets the color (or texture) of the switch.
- Parameters:
color
- the color (or texture) of the switch.
public int getToggleCount()
Get the number of times the switch was toggled
- Returns:
- the number of times the switch was toggled
@Deprecated public RailwayTrack getMainTrack()
Deprecated.
Switches with more than 3 connected tracks do not have a notion of "Main Track"
@Deprecated public List<RailwayTrack> getAlternativeTracks()
Deprecated.
Switches with more than 3 connected tracks do not have a notion of "Alternative Tracks"
public List<RailwayTrack> getTracks()
Returns the list of all tracks connected to this switch
- Returns:
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.
@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 positionReturns the currently selected track.
- Returns:
- the currently selected track.
@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
public 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
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 tracktarget
- target track- Returns:
- true if there is such a state
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 tracktarget
- target track
public void toggle()
Toggles the selected tracks.
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
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.
@AnyLogicInternalAPI public void setNextFeasibleState(RailwayTrack source)
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
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
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 classMarkupShape
- Parameters:
px
- the x coordinate relative to this shape's containerpy
- the y coordinate relative to this shape's container- Returns:
true
if the shape contains the point with the given coordinates
@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 classMarkupShape
- Parameters:
clickx
- the x coordinate of the click relative to the shapeclicky
- the y coordinate of the click relative to the shape- Returns:
- always return
false
here.