Examples of Turnout


Examples of ch.fork.AdHocRailway.domain.turnouts.Turnout

    private void parseRoutedSwitch(String qName, Attributes attributes) {
        int switchNumber = Integer
                .parseInt(attributes.getValue("switchNumber"));
        String switchStateRouted = attributes.getValue("switchStateRouted");
        Turnout turnout = null;
        turnout = turnoutPersistence.getTurnoutByNumber(switchNumber);
        if (turnout != null) {

            actualRouteItem = new RouteItem(0, turnout, actualRoute,
                    switchStateRouted);
            actualRoute.getRouteItems().add(actualRouteItem);
            turnout.getRouteItems().add(actualRouteItem);
            routePersistence.addRouteItem(actualRouteItem);
        }
    }
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.Turnout

                if (enteredNumberKeys.toString().equals("")) {
                    if (historyStack.size() == 0)
                        return;
                    Object obj = historyStack.removeFirst();
                    if (obj instanceof Turnout) {
                        Turnout t = (Turnout) obj;
                        turnoutControl.setDefaultState(t);
                    } else if (obj instanceof Route) {
                        Route r = (Route) obj;
                        routeControl.disableRoute(r);
                    } else {
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.Turnout

        private void handleSwitchChange(ActionEvent e, int enteredNumber)
                throws TurnoutException {
            TurnoutPersistenceIface turnoutPersistence = AdHocRailway
                    .getInstance().getTurnoutPersistence();
            Turnout searchedTurnout = null;
            searchedTurnout = turnoutPersistence
                    .getTurnoutByNumber(enteredNumber);
            if (searchedTurnout == null) {
                return;
            }
            TurnoutControlIface turnoutControl = AdHocRailway.getInstance()
                    .getTurnoutControl();

            if (this instanceof CurvedLeftAction) {
                turnoutControl.setCurvedLeft(searchedTurnout);
            } else if (this instanceof StraightAction) {
                turnoutControl.setStraight(searchedTurnout);
            } else if (this instanceof CurvedRightAction) {
                turnoutControl.setCurvedRight(searchedTurnout);
            } else if (this instanceof EnableRouteAction) {
                if (!searchedTurnout.isThreeWay()) {
                    turnoutControl.setNonDefaultState(searchedTurnout);
                }
            } else if (this instanceof DisableRouteAction) {
                if (!searchedTurnout.isThreeWay()) {
                    turnoutControl.setDefaultState(searchedTurnout);
                }
            }
            updateHistory(searchedTurnout);
        }
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.Turnout

        if (type.toUpperCase().equals("DEFAULT")
                || type.toUpperCase().equals("DEFAULTSWITCH")) {
            TurnoutType turnoutType = turnoutPersistence
                    .getTurnoutType(SRCPTurnoutTypes.DEFAULT);
            actualTurnout = new Turnout(0, turnoutType, actualTurnoutGroup,
                    number, desc, defaultstate.toUpperCase(),
                    orientation.toUpperCase(), 0, 0, false);
            actualAddresses = new Address[1];
            turnoutType.getTurnouts().add(actualTurnout);
        } else if (type.toUpperCase().equals("DOUBLECROSS")
                || type.toUpperCase().equals("DOUBLECROSSSWITCH")) {
            TurnoutType turnoutType = turnoutPersistence
                    .getTurnoutType(SRCPTurnoutTypes.DOUBLECROSS);
            actualTurnout = new Turnout(0, turnoutType, actualTurnoutGroup,
                    number, desc, defaultstate.toUpperCase(),
                    orientation.toUpperCase(), 0, 0, false);
            actualAddresses = new Address[1];
            turnoutType.getTurnouts().add(actualTurnout);
        } else if (type.toUpperCase().equals("THREEWAY")
                || type.toUpperCase().equals("THREEWAYSWITCH")) {
            TurnoutType turnoutType = turnoutPersistence
                    .getTurnoutType(SRCPTurnoutTypes.THREEWAY);
            actualTurnout = new Turnout(0, turnoutType, actualTurnoutGroup,
                    number, desc, defaultstate.toUpperCase(),
                    orientation.toUpperCase(), 0, 0, false);
            actualAddresses = new Address[2];
            turnoutType.getTurnouts().add(actualTurnout);
        }
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.Turnout

    private void parseRoutedSwitch(String qName, Attributes attributes) {
        int switchNumber = Integer
                .parseInt(attributes.getValue("switchNumber"));
        String switchStateRouted = attributes.getValue("switchStateRouted");
        Turnout turnout = null;
        turnout = turnoutPersistence.getTurnoutByNumber(switchNumber);
        if (turnout != null) {

            actualRouteItem = new RouteItem(0, turnout, actualRoute,
                    switchStateRouted);
            actualRoute.getRouteItems().add(actualRouteItem);
            turnout.getRouteItems().add(actualRouteItem);
            routePersistence.addRouteItem(actualRouteItem);
        }
    }
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.Turnout

    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        JLabel iconLabel = (JLabel) super.getTableCellRendererComponent(table,
                value, isSelected, hasFocus, row, column);
        iconLabel.setHorizontalAlignment(SwingConstants.CENTER);
        Turnout currentTurnout;
        iconLabel.setText("");
        TurnoutPersistenceIface persistence = AdHocRailway.getInstance()
                .getTurnoutPersistence();
        currentTurnout = persistence.getTurnoutByNumber(Integer
                .valueOf((Integer) table.getValueAt(row, 0)));
        if (currentTurnout == null) {
            return iconLabel;
        }
        SRCPTurnoutState routedState = (SRCPTurnoutState) value;
        String stateString = "";
        switch (routedState) {
        case STRAIGHT:
            stateString = "straight";
            break;
        case LEFT:
        case RIGHT:
            stateString = "curved";
            break;
        }
        if (currentTurnout.isDefault()) {
            iconLabel.setIcon(ImageTools
                    .createImageIcon("switches/default_switch_" + stateString
                            + ".png"));
        } else if (currentTurnout.isDoubleCross()) {
            iconLabel.setIcon(ImageTools
                    .createImageIcon("switches/double_cross_switch_"
                            + stateString + ".png"));
        } else if (currentTurnout.isThreeWay()) {
            switch (routedState) {
            case STRAIGHT:
                iconLabel
                        .setIcon(ImageTools
                                .createImageIcon("switches/three_way_switch_straight.png"));
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.Turnout

    public Turnout getTurnout() {
        return this.turnout;
    }

    public void setTurnout(Turnout turnout) {
        Turnout old = this.turnout;
        this.turnout = turnout;
        firePropertyChange(PROPERTYNAME_TURNOUT, old, turnout);
    }
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.Turnout

     */
    public void deleteRouteItem(RouteItem item)
            throws RoutePersistenceException {
        EntityManager em = HibernatePersistence.getEntityManager();
        try {
            Turnout turnout = item.getTurnout();
            turnout.getRouteItems().remove(item);

            Route route = item.getRoute();
            route.getRouteItems().remove(item);

            em.remove(item);
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.Turnout

     * (ch.fork.AdHocRailway.domain.routes.RouteItem)
     */
    public void deleteRouteItem(RouteItem item) {
        logger.debug("deleteRouteItem()");

        Turnout turnout = item.getTurnout();
        turnout.getRouteItems().remove(item);

        Route route = item.getRoute();
        route.getRouteItems().remove(item);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.