Package ch.fork.AdHocRailway.domain.routes

Examples of ch.fork.AdHocRailway.domain.routes.RouteControlIface


    private void updateRoutes() {
        routeGroupsTabbedPane.removeAll();
        int maxRouteCols = preferences
                .getIntValue(PreferencesKeys.ROUTE_CONTROLES);
        int i = 1;
        RouteControlIface routeControl = AdHocRailway.getInstance()
                .getRouteControl();
        routeControl.removeAllRouteChangeListeners();
        RoutePersistenceIface routePersistence = AdHocRailway.getInstance()
                .getRoutePersistence();

        for (RouteGroup routeGroup : routePersistence.getAllRouteGroups()) {

            WidgetTab routeGroupTab = new WidgetTab(maxRouteCols);
            JScrollPane groupScrollPane = new JScrollPane(routeGroupTab,
                    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

            groupScrollPane.setBorder(BorderFactory.createEmptyBorder());
            groupScrollPane.getVerticalScrollBar().setUnitIncrement(10);
            groupScrollPane.getVerticalScrollBar().setBlockIncrement(10);
            for (Route aRoute : routeGroup.getRoutes()) {
                RouteWidget routeWidget = new RouteWidget(aRoute);
                routeGroupTab.addWidget(routeWidget);
                routeControl.addRouteChangeListener(aRoute, routeWidget);
            }
            routeGroupsTabbedPane.add(groupScrollPane, "F" + i + ": "
                    + routeGroup.getName());
            i++;
        }
View Full Code Here


    private abstract class SwitchingAction extends AbstractAction {
        public void actionPerformed(ActionEvent e) {

            try {
                RouteControlIface routeControl = AdHocRailway.getInstance()
                        .getRouteControl();
                TurnoutControlIface turnoutControl = AdHocRailway.getInstance()
                        .getTurnoutControl();

                String enteredNumberAsString = enteredNumberKeys.toString();
                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 {
                        return;
                    }
                    historyWidgets.removeFirst();
                    updateHistory();
View Full Code Here

        private void handleRouteChange(ActionEvent e, int enteredNumber)
                throws TurnoutException, RouteException {
            Route searchedRoute = null;

            RouteControlIface routeControl = AdHocRailway.getInstance()
                    .getRouteControl();
            RoutePersistenceIface routePersistence = AdHocRailway.getInstance()
                    .getRoutePersistence();
            searchedRoute = routePersistence.getRouteByNumber(enteredNumber);
            if (searchedRoute == null) {
                return;
            }
            if (this instanceof EnableRouteAction) {
                routeControl.enableRoute(searchedRoute);
            } else if (this instanceof DisableRouteAction) {
                routeControl.disableRoute(searchedRoute);
            }
            updateHistory(searchedRoute);
        }
View Full Code Here

    private MouseAction mouseAction;
    private JLabel numberLabel;

    public RouteWidget(Route route) {
        this.route = route;
        RouteControlIface routeControl = AdHocRailway.getInstance()
                .getRouteControl();
        initGUI();
        routeControl.addRouteChangeListener(route, this);
    }
View Full Code Here

    public void routeChanged(Route changedRoute) {
        if (route.equals(changedRoute)) {
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    RouteControlIface routeControl = AdHocRailway.getInstance()
                            .getRouteControl();
                    if (routeControl.isRouteEnabled(route)) {
                        iconLabel.setIcon(routeStartIcon);
                        routingProgress.setForeground(Color.GREEN);
                    } else {
                        iconLabel.setIcon(routeStopIcon);
                        routingProgress.setBackground(Color.RED);
View Full Code Here

    private class MouseAction extends MouseAdapter {

        public void mouseClicked(MouseEvent e) {
            try {
                RouteControlIface routeControl = AdHocRailway.getInstance()
                        .getRouteControl();
                if (e.getClickCount() == 1
                        && e.getButton() == MouseEvent.BUTTON1) {
                    if (routeControl.isRouting(route))
                        return;
                    if (routeControl.isRouteEnabled(route))
                        routeControl.disableRoute(route);
                    else
                        routeControl.enableRoute(route);
                    removeMouseListener(mouseAction);
                } else if (e.getClickCount() == 1
                        && e.getButton() == MouseEvent.BUTTON3) {
                    displayRouteConfig();
                }
View Full Code Here

                ExceptionProcessor.getInstance().processException(e1);
            }
        }

        private void displayRouteConfig() {
            RouteControlIface routeControl = AdHocRailway.getInstance()
                    .getRouteControl();
            routeControl.removeRouteChangeListener(route, RouteWidget.this);
            new RouteConfig(AdHocRailway.getInstance(), route);
            routeControl.update();
            routeControl.addRouteChangeListener(route, RouteWidget.this);

            routeChanged(route);
        }
View Full Code Here

    private JPanel southPanel;
    private JLabel numberLabel;

    public StaticRouteWidget(Route route) {
        this.route = route;
        RouteControlIface routeControl = AdHocRailway.getInstance()
                .getRouteControl();
        initGUI();
        routeControl.addRouteChangeListener(route, this);
    }
View Full Code Here

    public void routeChanged(Route changedRoute) {
        if (route.equals(changedRoute)) {
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    RouteControlIface routeControl = AdHocRailway.getInstance()
                            .getRouteControl();
                    if (routeControl.isRouteEnabled(route)) {
                        iconLabel.setIcon(routeStartIcon);
                        routingProgress.setForeground(Color.GREEN);
                    } else {
                        iconLabel.setIcon(routeStopIcon);
                        routingProgress.setBackground(Color.RED);
View Full Code Here

TOP

Related Classes of ch.fork.AdHocRailway.domain.routes.RouteControlIface

Copyright © 2018 www.massapicom. 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.