Search in sources :

Example 1 with PointDetails

use of jmri.jmrit.signalling.entryexit.PointDetails in project JMRI by JMRI.

the class EntryExitPairs method addNXSourcePoint.

public void addNXSourcePoint(NamedBean source) {
    PointDetails point = null;
    ArrayList<LayoutEditor> layout = jmri.jmrit.display.PanelMenu.instance().getLayoutEditorPanelList();
    for (int i = 0; i < layout.size(); i++) {
        point = providePoint(source, layout.get(i));
    }
    if (point == null) {
        log.error("Unable to find a location on any panel for item " + source.getDisplayName());
        return;
    }
}
Also used : LayoutEditor(jmri.jmrit.display.layoutEditor.LayoutEditor) PointDetails(jmri.jmrit.signalling.entryexit.PointDetails)

Example 2 with PointDetails

use of jmri.jmrit.signalling.entryexit.PointDetails in project JMRI by JMRI.

the class EntryExitPairs method deleteNxPair.

public void deleteNxPair(NamedBean source, NamedBean destination, LayoutEditor panel) {
    PointDetails sourcePoint = getPointDetails(source, panel);
    if (sourcePoint == null) {
        if (log.isDebugEnabled()) {
            log.debug("source " + source.getDisplayName() + " does not exist so can not delete pair");
        }
        return;
    }
    PointDetails destPoint = getPointDetails(destination, panel);
    if (destPoint == null) {
        if (log.isDebugEnabled()) {
            log.debug("destination " + destination.getDisplayName() + " does not exist so can not delete pair");
        }
        return;
    }
    if (nxpair.containsKey(sourcePoint)) {
        nxpair.get(sourcePoint).removeDestination(destPoint);
        firePropertyChange("length", null, null);
        if (nxpair.get(sourcePoint).getDestinationPoints().size() == 0) {
            nxpair.remove(sourcePoint);
        }
    } else if (log.isDebugEnabled()) {
        log.debug("source " + source.getDisplayName() + " is not a valid source so can not delete pair");
    }
}
Also used : PointDetails(jmri.jmrit.signalling.entryexit.PointDetails)

Example 3 with PointDetails

use of jmri.jmrit.signalling.entryexit.PointDetails in project JMRI by JMRI.

the class EntryExitPairs method setMultiPointRoute.

private void setMultiPointRoute(PointDetails fromPd, PointDetails toPd) {
    boolean cleardown = false;
    if (fromPd.isRouteFromPointSet() && toPd.isRouteToPointSet()) {
        cleardown = true;
    }
    for (LayoutBlock pro : fromPd.getProtecting()) {
        try {
            jmri.jmrit.display.layoutEditor.LayoutBlockManager lbm = InstanceManager.getDefault(jmri.jmrit.display.layoutEditor.LayoutBlockManager.class);
            LayoutBlock toProt = null;
            if (!toPd.getProtecting().isEmpty()) {
                toProt = toPd.getProtecting().get(0);
            }
            boolean result = lbm.getLayoutBlockConnectivityTools().checkValidDest(fromPd.getFacing(), pro, toPd.getFacing(), toProt, LayoutBlockConnectivityTools.SENSORTOSENSOR);
            if (result) {
                ArrayList<LayoutBlock> blkList = lbm.getLayoutBlockConnectivityTools().getLayoutBlocks(fromPd.getFacing(), toPd.getFacing(), pro, cleardown, LayoutBlockConnectivityTools.NONE);
                if (!blkList.isEmpty()) {
                    List<jmri.NamedBean> beanList = lbm.getLayoutBlockConnectivityTools().getBeansInPath(blkList, fromPd.getPanel(), jmri.Sensor.class);
                    PointDetails fromPoint = fromPd;
                    refCounter++;
                    if (!beanList.isEmpty()) {
                        for (int i = 1; i < beanList.size(); i++) {
                            NamedBean nb = beanList.get(i);
                            PointDetails cur = getPointDetails(nb, fromPd.getPanel());
                            Source s = nxpair.get(fromPoint);
                            if (s != null) {
                                routesToSet.add(new SourceToDest(s, s.getDestForPoint(cur), false, refCounter));
                            }
                            fromPoint = cur;
                        }
                    }
                    Source s = nxpair.get(fromPoint);
                    if (s != null) {
                        routesToSet.add(new SourceToDest(s, s.getDestForPoint(toPd), false, refCounter));
                    }
                    processRoutesToSet();
                    return;
                }
            }
        } catch (jmri.JmriException e) {
        //Can be considered normal if route is blocked
        }
    }
    fromPd.setNXButtonState(NXBUTTONINACTIVE);
    toPd.setNXButtonState(NXBUTTONINACTIVE);
}
Also used : NamedBean(jmri.NamedBean) JmriException(jmri.JmriException) Source(jmri.jmrit.signalling.entryexit.Source) LayoutBlock(jmri.jmrit.display.layoutEditor.LayoutBlock) PointDetails(jmri.jmrit.signalling.entryexit.PointDetails)

Example 4 with PointDetails

use of jmri.jmrit.signalling.entryexit.PointDetails in project JMRI by JMRI.

the class EntryExitPairs method getNxSource.

// Need to sort out the presentation of the name here rather than using the point ID.
// This is used for the creation and display of information in the table.
// The presentation of the name might have to be done at the table level.
public ArrayList<Object> getNxSource(LayoutEditor panel) {
    ArrayList<Object> source = new ArrayList<Object>();
    destinationList = new ArrayList<Object>();
    for (Entry<PointDetails, Source> e : nxpair.entrySet()) {
        PointDetails key = e.getKey();
        LayoutEditor pan = key.getPanel();
        if (pan == panel) {
            List<PointDetails> dest = nxpair.get(key).getDestinationPoints();
            for (int i = 0; i < dest.size(); i++) {
                destinationList.add(dest.get(i).getRefObject());
                source.add(key.getRefObject());
            }
        }
    }
    return source;
}
Also used : LayoutEditor(jmri.jmrit.display.layoutEditor.LayoutEditor) ArrayList(java.util.ArrayList) PointDetails(jmri.jmrit.signalling.entryexit.PointDetails) Source(jmri.jmrit.signalling.entryexit.Source)

Example 5 with PointDetails

use of jmri.jmrit.signalling.entryexit.PointDetails in project JMRI by JMRI.

the class EntryExitPairs method getPointDetails.

/**
     * Return either an existing point stored in pointDetails, or create a new one as required.
     *
     * @param source The Layout Block functioning as the source (origin)
     * @param destination A (list of) Layout Blocks functioning as destinations
     * @param panel The Layout Editor panel on which the point is to be placed
     * @return the point object
     */
PointDetails getPointDetails(LayoutBlock source, List<LayoutBlock> destination, LayoutEditor panel) {
    PointDetails newPoint = new PointDetails(source, destination);
    newPoint.setPanel(panel);
    for (int i = 0; i < pointDetails.size(); i++) {
        if (pointDetails.get(i).equals(newPoint)) {
            return pointDetails.get(i);
        }
    }
    //Not found so will add
    pointDetails.add(newPoint);
    return newPoint;
}
Also used : PointDetails(jmri.jmrit.signalling.entryexit.PointDetails)

Aggregations

PointDetails (jmri.jmrit.signalling.entryexit.PointDetails)13 Source (jmri.jmrit.signalling.entryexit.Source)6 LayoutEditor (jmri.jmrit.display.layoutEditor.LayoutEditor)5 ArrayList (java.util.ArrayList)3 LayoutBlock (jmri.jmrit.display.layoutEditor.LayoutBlock)2 JmriException (jmri.JmriException)1 NamedBean (jmri.NamedBean)1