net.kolls.railworld.segment.sp
Class Yellow

java.lang.Object
  extended by net.kolls.railworld.segment.sp.Yellow
All Implemented Interfaces:
SaveLoad, SignalProgram

public class Yellow
extends java.lang.Object
implements SignalProgram

A yellow (slow, 5 MPH) signal

Author:
Steve Kollmansberger

Constructor Summary
Yellow()
           
 
Method Summary
 void enter(Train t)
          Called by the signal when a train enters the signal from the facing side only.
 javax.swing.Icon icon()
          For use by the signal chooser.
 void load(java.util.Map<java.lang.String,java.lang.String> data)
          Load from saved.
 java.lang.Object newInstance()
          like getClass().newInstance().
 void reacting(Train t)
          Indication that a train's controller is monitoring, responding to or waiting on the signal.
 java.util.Map<java.lang.String,java.lang.String> save()
          Store all persistent data into a map and return for saving.
 java.awt.Color status()
          Indicate the current color of the signal.
 java.lang.String toString()
          Indicates the name of the program to display to the user as a tooltip.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Yellow

public Yellow()
Method Detail

enter

public void enter(Train t)
Description copied from interface: SignalProgram
Called by the signal when a train enters the signal from the facing side only. Train entering in the opposite direction will not cause notification. May be called arbitrarily often while the train is passing or stationary in the signal in the facing direction.

Specified by:
enter in interface SignalProgram
Parameters:
t - The Train entering the signal.

reacting

public void reacting(Train t)
Description copied from interface: SignalProgram
Indication that a train's controller is monitoring, responding to or waiting on the signal. This means the train is "in range" of the signal and could be influenced by it. Called by the controller arbitrarily often.

Specified by:
reacting in interface SignalProgram
Parameters:
t - The Train monitoring/responding/waiting.

status

public java.awt.Color status()
Description copied from interface: SignalProgram
Indicate the current color of the signal. (Green = go, yellow = 5 MPH, red = stop). This is the displayed color and also what trains may respond to. Signal calls this to find out what color it should display.

Specified by:
status in interface SignalProgram
Returns:
Current color

toString

public java.lang.String toString()
Description copied from interface: SignalProgram
Indicates the name of the program to display to the user as a tooltip.

Specified by:
toString in interface SaveLoad
Specified by:
toString in interface SignalProgram
Overrides:
toString in class java.lang.Object
Returns:
Information to display over signal and in chooser window.

icon

public javax.swing.Icon icon()
Description copied from interface: SignalProgram
For use by the signal chooser.

Specified by:
icon in interface SignalProgram
Returns:
A 24x24 icon representing this signal program.

load

public void load(java.util.Map<java.lang.String,java.lang.String> data)
Description copied from interface: SaveLoad
Load from saved.

Specified by:
load in interface SaveLoad
Parameters:
data - Key value pairs saved by an instance of this class

save

public java.util.Map<java.lang.String,java.lang.String> save()
Description copied from interface: SaveLoad
Store all persistent data into a map and return for saving. May return null if there is no data to save. This will be treated the same as the empty map.

Specified by:
save in interface SaveLoad
Returns:
A list of key-value pairs to be saved.

newInstance

public java.lang.Object newInstance()
Description copied from interface: SaveLoad
like getClass().newInstance(). Allows script objects to also be copied.

Specified by:
newInstance in interface SaveLoad
Returns:
A new instance of this class