jmri
Class Path

java.lang.Object
  extended by jmri.Path

public class Path
extends Object

Represents a particular set of NamedBean (usually turnout) settings to put a path through trackwork to a Block.

Directions are defined for traffic along this path "to" the block, and "from" the block. Being more specific:

Although useful constants are defined, you don't have to restrict to those, and there's no assumption that they have to be opposites; NORTH for "to" does not imply SOUTH for "from". This allows you to e.g. handle a piece of curved track where you can be going LEFT at one point and UP at another. The constants are defined as bits, so you can use more than one at a time, for example a direction can simultanously be EAST and RIGHT if desired. What that means needs to be defined by whatever object is using this Path.

This implementation handles paths with a list of bean settings. This has been extended from the initial implementation.

Author:
Bob Jacobsen Copyright (C) 2006, 2008

Field Summary
static int CCW
          Counter-clockwise
static int CW
          Clockwise
static int DOWN
          Downward, e.g. on a schematic diagram or CTC panel
static int EAST
          Eastward
static int LEFT
          Leftward, e.g. on a schematic diagram or CTC panel
static int NONE
          Direction not known or not specified.
static int NORTH
          Northward
static int RIGHT
          Rightward, e.g. on a schematic diagram or CTC panel
static int SOUTH
          Southward
static int UP
          Upward, e.g. on a schematic diagram or CTC panel
static int WEST
          Westward
 
Constructor Summary
Path()
          Create an object with default directions of NONE, and no setting element.
Path(Block dest, int toBlockDirection, int fromBlockDirection)
          Convenience constructor to set the destination/source block and directions in one call.
Path(Block dest, int toBlockDirection, int fromBlockDirection, BeanSetting setting)
          Convenience constructor to set the destination/source block, directions and a single setting element in one call.
 
Method Summary
 void addSetting(BeanSetting t)
           
 boolean checkPathSet()
          Check that the Path can be traversed.
 void clearSettings()
           
static String decodeDirection(int d)
          Decode the direction constants into a human-readable form.
 Block getBlock()
           
 int getFromBlockDirection()
           
 List<BeanSetting> getSettings()
           
 int getToBlockDirection()
           
 void setBlock(Block b)
           
 void setFromBlockDirection(int d)
           
 void setToBlockDirection(int d)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
Direction not known or not specified. May also represent "stopped", in the sense of not moving in any direction.

See Also:
Constant Field Values

NORTH

public static final int NORTH
Northward

See Also:
Constant Field Values

SOUTH

public static final int SOUTH
Southward

See Also:
Constant Field Values

EAST

public static final int EAST
Eastward

See Also:
Constant Field Values

WEST

public static final int WEST
Westward

See Also:
Constant Field Values

CW

public static final int CW
Clockwise

See Also:
Constant Field Values

CCW

public static final int CCW
Counter-clockwise

See Also:
Constant Field Values

LEFT

public static final int LEFT
Leftward, e.g. on a schematic diagram or CTC panel

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Rightward, e.g. on a schematic diagram or CTC panel

See Also:
Constant Field Values

UP

public static final int UP
Upward, e.g. on a schematic diagram or CTC panel

See Also:
Constant Field Values

DOWN

public static final int DOWN
Downward, e.g. on a schematic diagram or CTC panel

See Also:
Constant Field Values
Constructor Detail

Path

public Path()
Create an object with default directions of NONE, and no setting element.


Path

public Path(Block dest,
            int toBlockDirection,
            int fromBlockDirection)
Convenience constructor to set the destination/source block and directions in one call.


Path

public Path(Block dest,
            int toBlockDirection,
            int fromBlockDirection,
            BeanSetting setting)
Convenience constructor to set the destination/source block, directions and a single setting element in one call.

Method Detail

addSetting

public void addSetting(BeanSetting t)

getSettings

public List<BeanSetting> getSettings()

clearSettings

public void clearSettings()

setBlock

public void setBlock(Block b)

getBlock

public Block getBlock()

getToBlockDirection

public int getToBlockDirection()

setToBlockDirection

public void setToBlockDirection(int d)

getFromBlockDirection

public int getFromBlockDirection()

setFromBlockDirection

public void setFromBlockDirection(int d)

checkPathSet

public boolean checkPathSet()
Check that the Path can be traversed. This means that any path elements are set to the proper state, e.g. that the Turnouts on this path are set to the proper CLOSED or OPEN status.

Returns:
true if the path can be traversed; always true if no path elements (BeanSettings) are defined.

decodeDirection

public static String decodeDirection(int d)
Decode the direction constants into a human-readable form. This should eventually be internationalized.



Copyright © 1997 - 2009 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads