|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.implementation.AbstractNamedBean
jmri.jmrit.display.layoutEditor.LayoutBlock
public class LayoutBlock
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.
| Field Summary | |
|---|---|
Color |
blockExtraColor
|
String |
blockName
|
Color |
blockOccupiedColor
|
Color |
blockTrackColor
|
static int |
EMPTY
|
boolean |
enableAddRouteLogging
|
boolean |
enableDeleteRouteLogging
|
boolean |
enableSearchRouteLogging
|
boolean |
enableUpdateRouteLogging
|
String |
lbSystemName
|
protected Vector<PropertyChangeListener> |
listeners
|
String |
memoryName
|
String |
occupancySensorName
|
static int |
OCCUPIED
|
int |
occupiedSense
|
static int |
RESERVED
|
static int |
UNKNOWN
|
| Fields inherited from class jmri.implementation.AbstractNamedBean |
|---|
mSystemName, mUserName |
| Fields inherited from interface jmri.NamedBean |
|---|
INCONSISTENT |
| Constructor Summary | |
|---|---|
LayoutBlock(String sName,
String uName)
|
|
| Method Summary | |
|---|---|
void |
addAllThroughPaths()
|
void |
addLayoutEditor(LayoutEditor panel)
Keeps track of LayoutEditor panels that are using this LayoutBlock |
void |
addPropertyChangeListener(PropertyChangeListener l)
|
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)
|
void |
disableDeleteRouteLog()
|
protected void |
editLayoutBlock(Component callingPane)
Edit a Layout Block |
void |
enableDeleteRouteLog()
|
protected void |
firePropertyChange(String p,
Object old,
Object n)
|
ArrayList<Block> |
getActiveNextBlocks(Block source)
|
Block |
getBlock()
Get the jmri.Block corresponding to this LayoutBlock |
Color |
getBlockColor()
Returns the color for drawing items in this block. |
Color |
getBlockExtraColor()
|
int |
getBlockHopCount(Block destination,
Block nextBlock)
Returns the number of layout blocks to our desintation block going from the next directly connected block. |
Color |
getBlockOccupiedColor()
|
Color |
getBlockTrackColor()
|
int |
getConnectedBlockRouteIndex(Block destBlock,
int direction)
|
String |
getID()
Accessor methods |
LayoutEditor |
getMaxConnectedPanel()
Get the Layout Editor panel with the highest connectivity to this Layout Block |
Memory |
getMemory()
Returns Memory |
String |
getMemoryName()
Returns Memory name |
Block |
getNeighbourAtIndex(int i)
Get the neighbouring block at index i |
int |
getNeighbourDirection(int i)
Get the direction of travel to neighbouring block at index i |
int |
getNeighbourDirection(LayoutBlock neigh)
Gets the direction of travel to our neighbouring block. |
int |
getNeighbourMetric(int i)
Get the metric/cost to neighbouring block at index i |
String |
getNeighbourPacketFlowAsString(int i)
Get the flow of traffic to and from neighbouring block at index i RXTX - Means Traffic can flow both ways between the blocks RXONLY - Means we can only recieve traffic from our neighbour, we can not send traffic to it TXONLY - Means we do not recieve traffic from our neighbour, but can send traffic to it. |
int |
getNextBestBlock(Block previousBlock,
Block destBlock,
int lastIndex,
int routingMethod)
last index - the index of the last block we returned ie we last returned index 10, so we don't want to return it again. |
Block |
getNextBlock(Block previousBlock,
Block destBlock)
Used if we already know the block prior to our block, and the destination block. |
Block |
getNextBlock(Block destBlock,
int direction)
|
int |
getNextBlockByIndex(Block previousBlock,
Block destBlock,
int offSet)
|
int |
getNextBlockByIndex(Block destBlock,
int direction,
int offSet)
|
int |
getNumberOfNeighbours()
Get the number of neighbour blocks attached to this block |
int |
getNumberOfRoutes()
Get the number of routes that the block has registered. |
int |
getNumberOfThroughPaths()
Returns the number of valid through paths on this block. |
int |
getOccupancy()
Test block occupancy |
Sensor |
getOccupancySensor()
Returns occupancy Sensor |
String |
getOccupancySensorName()
Returns occupancy Sensor name |
int |
getOccupiedSense()
Get/Set occupied sense |
Block |
getRouteDestBlockAtIndex(int i)
Get the destination block at route i |
int |
getRouteDirectionAtIndex(int i)
Get the direction of route i. |
int |
getRouteHopCountAtIndex(int i)
Get the hop count of route i. |
int |
getRouteMetric(int i)
Get the metric/cost at route i |
Block |
getRouteNextBlockAtIndex(int i)
Get the next block at route i |
int |
getRouteState(int i)
Gets the state (Occupied, unoccupied) of the destination layout block at index i |
String |
getRouteStateAsString(int i)
Gets the state of the destination layout block at index i as a string |
boolean |
getRouteValid(int i)
Is the route to the destination potentially valid from our block. |
int |
getState()
Provide generic access to internal state. |
Block |
getThroughPathDestination(int i)
Returns the destination block at index i |
Path |
getThroughPathDestinationPathAtIndex(int i)
|
int |
getThroughPathIndex(Block sourceBlock,
Block destinationBlock)
|
Block |
getThroughPathSource(int i)
Returns the source block at index i |
Path |
getThroughPathSourcePathAtIndex(int i)
|
int |
getUseCount()
|
boolean |
getUseExtraColor()
|
void |
incrementUse()
|
protected void |
initializeLayoutBlock()
|
boolean |
isActive()
"active" means that the object is still displayed, and should be stored. |
boolean |
isNeighbourMutual(int i)
Is our neighbouring block at index i a mutual neighbour, ie both blocks have each other registered as neighbours and are exchaning information. |
boolean |
isOnPanel(LayoutEditor panel)
|
boolean |
isRouteToDestValid(Block protecting,
Block destination)
Is the route to the destination block, going via our neighbouring block valid. |
Boolean |
isThroughPathActive(int i)
Is the through path at index i active |
void |
printAdjacencies()
Provides an output to the console of all our neighbouring blocks |
void |
printRoutes()
Provides an output to the console of all the remote blocks reachable from our block |
void |
printRoutes(String blockName)
Provides an output to the console of how to reach a specific block from our block |
void |
printValidThroughPaths()
Provides an output to the console of all the valid paths through this block |
void |
propertyChange(PropertyChangeEvent e)
|
void |
redrawLayoutBlockPanels()
Redraws panels using this layout block |
void |
refreshValidRoutes()
|
void |
removePropertyChangeListener(PropertyChangeListener l)
Remove a request for a call-back when a bound property changes. |
void |
setBlockExtraColor(Color color)
|
void |
setBlockMetric(int m)
Sets a metric cost against a block, this is used in the calculation of a path between two location on the layout, a lower path cost is always preferred For Layout blocks defined as Mainline the default metric is 50. |
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. |
void |
setSuppressNameUpdate(boolean set)
Sets/resets update of memory name when block goes from occupied to unoccupied or vice versa. |
void |
setUseExtraColor(boolean b)
|
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); |
void |
updatePathsUsingPanel(LayoutEditor panel)
Check/Update Path objects for the attached jmri.Block using the connectivity in the specified Layout Editor panel. |
boolean |
useDefaultMetric()
|
void |
useDefaultMetric(boolean boo)
|
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. |
boolean |
validThroughPath(Block sourceBlock,
Block destinationBlock)
|
| Methods inherited from class jmri.implementation.AbstractNamedBean |
|---|
addPropertyChangeListener, dispose, getComment, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, setComment, setProperty, setUserName, updateListenerRef |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public boolean enableAddRouteLogging
public boolean enableUpdateRouteLogging
public boolean enableDeleteRouteLogging
public boolean enableSearchRouteLogging
public static final int OCCUPIED
public static final int EMPTY
public static final int UNKNOWN
public String blockName
public String lbSystemName
public String occupancySensorName
public String memoryName
public int occupiedSense
public Color blockTrackColor
public Color blockOccupiedColor
public Color blockExtraColor
public static final int RESERVED
protected Vector<PropertyChangeListener> listeners
| Constructor Detail |
|---|
public LayoutBlock(String sName,
String uName)
| Method Detail |
|---|
public void enableDeleteRouteLog()
public void disableDeleteRouteLog()
protected void initializeLayoutBlock()
public String getID()
public Color getBlockTrackColor()
public void setBlockTrackColor(Color color)
public Color getBlockOccupiedColor()
public void setBlockOccupiedColor(Color color)
public Color getBlockExtraColor()
public void setBlockExtraColor(Color color)
public boolean getUseExtraColor()
public void setUseExtraColor(boolean b)
public void incrementUse()
public void decrementUse()
public int getUseCount()
public void addLayoutEditor(LayoutEditor panel)
public void deleteLayoutEditor(LayoutEditor panel)
public boolean isOnPanel(LayoutEditor panel)
public void redrawLayoutBlockPanels()
public Sensor validateSensor(String sensorName,
Component openFrame)
public Memory validateMemory(String memName,
Component openFrame)
public Color getBlockColor()
public Block getBlock()
public String getMemoryName()
public Memory getMemory()
public void setMemoryName(String name)
public String getOccupancySensorName()
public Sensor getOccupancySensor()
public void setOccupancySensorName(String name)
public int getOccupiedSense()
public void setOccupiedSense(int sense)
public int getOccupancy()
public int getState()
NamedBeanThis 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.
getState in interface NamedBeanpublic void setState(int i)
NamedBeanThis 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.
setState in interface NamedBeanpublic LayoutEditor getMaxConnectedPanel()
public void updatePaths()
If multiple panels are present, Paths are set according to the panel with the highest connectivity (most LayoutConnectivity objects);
public void updatePathsUsingPanel(LayoutEditor panel)
public void setSuppressNameUpdate(boolean set)
protected void editLayoutBlock(Component callingPane)
public static String colorToString(Color color)
public static Color stringToColor(String string)
public boolean isActive()
public boolean useDefaultMetric()
public void useDefaultMetric(boolean boo)
public void setBlockMetric(int m)
public void addAllThroughPaths()
public ArrayList<Block> getActiveNextBlocks(Block source)
public Path getThroughPathSourcePathAtIndex(int i)
public Path getThroughPathDestinationPathAtIndex(int i)
public boolean validThroughPath(Block sourceBlock,
Block destinationBlock)
public int getThroughPathIndex(Block sourceBlock,
Block destinationBlock)
public void printValidThroughPaths()
public void printAdjacencies()
public void printRoutes()
public void printRoutes(String blockName)
public Block getNextBlock(Block destBlock,
int direction)
destBlock - - is the destination of the block we are followingdirection - - is the direction of travel from the previous block
public Block getNextBlock(Block previousBlock,
Block destBlock)
public int getConnectedBlockRouteIndex(Block destBlock,
int direction)
public int getNextBlockByIndex(Block destBlock,
int direction,
int offSet)
public int getNextBlockByIndex(Block previousBlock,
Block destBlock,
int offSet)
public int getNextBestBlock(Block previousBlock,
Block destBlock,
int lastIndex,
int routingMethod)
public void addPropertyChangeListener(PropertyChangeListener l)
addPropertyChangeListener in interface NamedBeanaddPropertyChangeListener in class AbstractNamedBeanpublic void removePropertyChangeListener(PropertyChangeListener l)
NamedBean
removePropertyChangeListener in interface NamedBeanremovePropertyChangeListener in class AbstractNamedBean
protected void firePropertyChange(String p,
Object old,
Object n)
firePropertyChange in class AbstractNamedBeanpublic void propertyChange(PropertyChangeEvent e)
propertyChange in interface PropertyChangeListener
public boolean isRouteToDestValid(Block protecting,
Block destination)
public int getNeighbourDirection(LayoutBlock neigh)
public int getNumberOfNeighbours()
public Block getNeighbourAtIndex(int i)
public int getNeighbourDirection(int i)
public int getNeighbourMetric(int i)
public String getNeighbourPacketFlowAsString(int i)
public boolean isNeighbourMutual(int i)
public int getNumberOfRoutes()
public int getRouteDirectionAtIndex(int i)
public Block getRouteDestBlockAtIndex(int i)
public Block getRouteNextBlockAtIndex(int i)
public int getRouteHopCountAtIndex(int i)
public int getRouteMetric(int i)
public int getRouteState(int i)
public boolean getRouteValid(int i)
public String getRouteStateAsString(int i)
public int getBlockHopCount(Block destination,
Block nextBlock)
public int getNumberOfThroughPaths()
public Block getThroughPathSource(int i)
public Block getThroughPathDestination(int i)
public Boolean isThroughPathActive(int i)
public void refreshValidRoutes()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||