jmri.jmrit.display
Class LayoutBlock

java.lang.Object
  extended by jmri.AbstractNamedBean
      extended by jmri.jmrit.display.LayoutBlock
All Implemented Interfaces:
Serializable, NamedBean

public class LayoutBlock
extends AbstractNamedBean

A LayoutBlock is a group of track segments and turnouts on a LayoutEditor panel corresponding to a 'block'. LayoutBlock is a LayoutEditor specific extension of the JMRI Block object.

LayoutBlocks may have an occupancy Sensor. The getOccupancy method returns the occupancy state of the LayoutBlock - OCCUPIED, EMPTY, or UNKNOWN. If no occupancy sensor is provided, UNKNOWN is returned. The occupancy sensor if there is one, is the same as the occupancy sensor of the corresponding JMRI Block.

The name of each Layout Block is the same as that of the corresponding block as defined in Layout Editor . A corresponding JMRI Block object is created when a LayoutBlock is created. The JMRI Block uses the name of the block defined in Layout Editor as its user name and a unique IBnnn system name. The JMRI Block object and its associated Path objects are useful in tracking a train around the layout. Blocks may be viewed in the Block Table.

A LayoutBlock may have an associated Memory object. This Memory object contains a string representing the current "value" of the corresponding JMRI Block object. If the value contains a train name, for example, displaying Memory objects associated with LayoutBlocks, and displayed near each Layout Block can follow a train around the layout, displaying its name when it is in the . LayoutBlock.

LayoutBlocks are "cross-panel", similar to sensors and turnouts. A LayoutBlock may be used by more than one Layout Editor panel simultaneously. As a consequence, LayoutBlocks are saved with the configuration, not with a panel.

LayoutBlocks are used by TrackSegments, LevelXings, and LayoutTurnouts. LevelXings carry two LayoutBlock designations, which may be the same. LayoutTurnouts carry LayoutBlock designations also, one per turnout, except for double crossovers which can have up to four.

LayoutBlocks carry a use count. The use count counts the number of track segments, layout turnouts, and levelcrossings which use the LayoutBlock. Only LayoutBlocks which have a use count greater than zero are saved when the configuration is saved.

Author:
Dave Duchamp Copyright (c) 2004-2008
See Also:
Serialized Form

Field Summary
 String blockName
           
 Color blockOccupiedColor
           
 Color blockTrackColor
           
static int EMPTY
           
 String memoryName
           
 String occupancySensorName
           
static int OCCUPIED
           
 int occupiedSense
           
static int UNKNOWN
           
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT
 
Constructor Summary
LayoutBlock(String sName, String uName)
           
 
Method Summary
 void addLayoutEditor(LayoutEditor panel)
          Keeps track of LayoutEditor panels that are using this LayoutBlock
static String colorToString(Color color)
          Utility methods for converting between string and color Note: These names are only used internally, so don't need a resource bundle
 void decrementUse()
           
 void deleteLayoutEditor(LayoutEditor panel)
           
protected  void editLayoutBlock(Component callingPane)
          Edit a Layout Block
 Block getBlock()
          Get the jmri.Block corresponding to this LayoutBlock
 Color getBlockColor()
          Returns the color for drawing items in this block.
 Color getBlockOccupiedColor()
           
 Color getBlockTrackColor()
           
 String getID()
          Accessor methods
protected  LayoutEditor getMaxConnectedPanel()
          Get the Layout Editor panel with the highest connectivity to this Layout Block
 Memory getMemory()
          Returns Memory
 String getMemoryName()
          Returns Memory name
 int getOccupancy()
          Test block occupancy
 Sensor getOccupancySensor()
          Returns occupancy Sensor
 String getOccupancySensorName()
          Returns occupancy Sensor name
 int getOccupiedSense()
          Get/Set occupied sense
 int getState()
          Provide generic access to internal state.
 int getUseCount()
           
 void incrementUse()
           
 boolean isActive()
          "active" means that the object is still displayed, and should be stored.
 boolean isOnPanel(LayoutEditor panel)
           
 void redrawLayoutBlockPanels()
          Redraws panels using this layout block
 void setBlockOccupiedColor(Color color)
           
 void setBlockTrackColor(Color color)
           
 void setMemoryName(String name)
          Add Memory by name
 void setOccupancySensorName(String name)
          Add occupancy sensor by name
 void setOccupiedSense(int sense)
           
 void setState(int i)
          Provide generic access to internal state.
static Color stringToColor(String string)
           
 void updatePaths()
          Check/Update Path objects for the attached jmri.Block If multiple panels are present, Paths are set according to the panel with the highest connectivity (most LayoutConnectivity objects);
 Memory validateMemory(String memName, Component openFrame)
          Validates that the memory name corresponds to an existing memory.
 Sensor validateSensor(String sensorName, Component openFrame)
          Validates that the supplied occupancy sensor name corresponds to an existing sensor and is unique among all blocks.
 
Methods inherited from class jmri.AbstractNamedBean
addPropertyChangeListener, dispose, firePropertyChange, getComment, getNumPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setComment, setUserName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OCCUPIED

public static final int OCCUPIED
See Also:
Constant Field Values

EMPTY

public static final int EMPTY
See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values

blockName

public String blockName

occupancySensorName

public String occupancySensorName

memoryName

public String memoryName

occupiedSense

public int occupiedSense

blockTrackColor

public Color blockTrackColor

blockOccupiedColor

public Color blockOccupiedColor
Constructor Detail

LayoutBlock

public LayoutBlock(String sName,
                   String uName)
Method Detail

getID

public String getID()
Accessor methods


getBlockTrackColor

public Color getBlockTrackColor()

setBlockTrackColor

public void setBlockTrackColor(Color color)

getBlockOccupiedColor

public Color getBlockOccupiedColor()

setBlockOccupiedColor

public void setBlockOccupiedColor(Color color)

incrementUse

public void incrementUse()

decrementUse

public void decrementUse()

getUseCount

public int getUseCount()

addLayoutEditor

public void addLayoutEditor(LayoutEditor panel)
Keeps track of LayoutEditor panels that are using this LayoutBlock


deleteLayoutEditor

public void deleteLayoutEditor(LayoutEditor panel)

isOnPanel

public boolean isOnPanel(LayoutEditor panel)

redrawLayoutBlockPanels

public void redrawLayoutBlockPanels()
Redraws panels using this layout block


validateSensor

public Sensor validateSensor(String sensorName,
                             Component openFrame)
Validates that the supplied occupancy sensor name corresponds to an existing sensor and is unique among all blocks. If valid, returns the sensor and sets the block sensor name in the block. Else returns null, and does nothing to the block. This method also converts the sensor name to upper case if it is a system name.


validateMemory

public Memory validateMemory(String memName,
                             Component openFrame)
Validates that the memory name corresponds to an existing memory. If valid, returns the memory. Else returns null, and notifies the user. This method also converts the memory name to upper case if it is a system name.


getBlockColor

public Color getBlockColor()
Returns the color for drawing items in this block. Returns color based on block occupancy.


getBlock

public Block getBlock()
Get the jmri.Block corresponding to this LayoutBlock


getMemoryName

public String getMemoryName()
Returns Memory name


getMemory

public Memory getMemory()
Returns Memory


setMemoryName

public void setMemoryName(String name)
Add Memory by name


getOccupancySensorName

public String getOccupancySensorName()
Returns occupancy Sensor name


getOccupancySensor

public Sensor getOccupancySensor()
Returns occupancy Sensor


setOccupancySensorName

public void setOccupancySensorName(String name)
Add occupancy sensor by name


getOccupiedSense

public int getOccupiedSense()
Get/Set occupied sense


setOccupiedSense

public void setOccupiedSense(int sense)

getOccupancy

public int getOccupancy()
Test block occupancy


getState

public int getState()
Description copied from interface: NamedBean
Provide generic access to internal state.

This generally shouldn't be used by Java code; use the class-specific form instead. (E.g. getCommandedState in Turnout) This provided to make Jython script access easier to read.


setState

public void setState(int i)
Description copied from interface: NamedBean
Provide generic access to internal state.

This generally shouldn't be used by Java code; use the class-specific form instead. (E.g. setCommandedState in Turnout) This provided to make Jython script access easier to read.


getMaxConnectedPanel

protected LayoutEditor getMaxConnectedPanel()
Get the Layout Editor panel with the highest connectivity to this Layout Block


updatePaths

public void updatePaths()
Check/Update Path objects for the attached jmri.Block

If multiple panels are present, Paths are set according to the panel with the highest connectivity (most LayoutConnectivity objects);


editLayoutBlock

protected void editLayoutBlock(Component callingPane)
Edit a Layout Block


colorToString

public static String colorToString(Color color)
Utility methods for converting between string and color Note: These names are only used internally, so don't need a resource bundle


stringToColor

public static Color stringToColor(String string)

isActive

public boolean isActive()
"active" means that the object is still displayed, and should be stored.



Copyright © 1997 - 2008 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: SourceForge_Logo