Search in sources :

Example 6 with LocoNetSlot

use of jmri.jmrix.loconet.LocoNetSlot in project JMRI by JMRI.

the class SlotMonDataModel method getRowCount.

/**
     * Returns the number of rows to be displayed. This can vary depending on
     * whether only active rows are displayed, and whether the system slots
     * should be displayed.
     * <P>
     * This should probably use a local cache instead of counting/searching each
     * time.
     */
@Override
public int getRowCount() {
    if (_allSlots) {
        // will show the entire set, so don't bother counting
        if (_systemSlots) {
            return 128;
        } else {
            // skip 0, and 120 through 127
            return 120;
        }
    }
    int n = 0;
    int nMin = 1;
    int nMax = 120;
    if (_systemSlots) {
        nMin = 0;
        nMax = 128;
    }
    for (int i = nMin; i < nMax; i++) {
        LocoNetSlot s = memo.getSlotManager().slot(i);
        if (s.slotStatus() != LnConstants.LOCO_FREE || i == 0 || i >= 120) {
            // always show system slots if requested
            n++;
        }
    }
    return n;
}
Also used : LocoNetSlot(jmri.jmrix.loconet.LocoNetSlot)

Aggregations

LocoNetSlot (jmri.jmrix.loconet.LocoNetSlot)6 LocoNetMessage (jmri.jmrix.loconet.LocoNetMessage)2