Examples of RouteConverter


Examples of slash.navigation.converter.gui.RouteConverter

        addUrlDialog.setVisible(true);
    }

    private void addUrlToCatalog(CategoryTreeNode category, String url) {
        if (category == null || category.getParent() == null) {
            RouteConverter r = RouteConverter.getInstance();
            showMessageDialog(r.getFrame(),
                    r.getContext().getBundle().getString("add-url-category-missing"),
                    r.getFrame().getTitle(), ERROR_MESSAGE);
            return;
        }

        showAddUrlToCatalog(category, extractDescription(url), extractUrl(url));
    }
View Full Code Here

Examples of slash.navigation.converter.gui.RouteConverter

* @author Christian Pesch
*/

public class ConvertTrackToRouteAction extends FrameAction {
    public void run() {
        RouteConverter r = RouteConverter.getInstance();
        r.setRouteCharacteristics(Route);
        r.selectInsignificantPositions(100);
        r.getContext().getActionManager().run("delete");
    }
View Full Code Here

Examples of slash.navigation.converter.gui.RouteConverter

    public InsertPositionsDialog() {
        super(RouteConverter.getInstance().getFrame(), "insert-positions");
        setTitle(RouteConverter.getBundle().getString("insert-positions-title"));
        setContentPane(contentPane);

        RouteConverter r = RouteConverter.getInstance();

        setMnemonic(buttonSelectAll, "select-all-action-mnemonic");
        buttonSelectAll.addActionListener(new DialogAction(this) {
            public void run() {
                selectAll();
            }
        });

        setMnemonic(buttonClearSelection, "clear-selection-mnemonic");
        buttonClearSelection.addActionListener(new DialogAction(this) {
            public void run() {
                clearSelection();
            }
        });

        setMnemonic(buttonInsertAllWaypoints, "insert-all-waypoints-mnemonic");
        buttonInsertAllWaypoints.addActionListener(new DialogAction(this) {
            public void run() {
                insertAllWaypoints();
            }
        });

        setMnemonic(buttonInsertOnlyTurnpoints, "insert-only-turnpoints-mnemonic");
        buttonInsertOnlyTurnpoints.addActionListener(new DialogAction(this) {
            public void run() {
                insertOnlyTurnpoints();
            }
        });

        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                close();
            }
        });

        contentPane.registerKeyboardAction(new DialogAction(this) {
            public void run() {
                close();
            }
        }, getKeyStroke(VK_ESCAPE, 0), WHEN_IN_FOCUSED_WINDOW);

        r.getPositionsView().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting())
                    return;
                handlePositionsUpdate();
            }
        });
        r.getRoutingServiceFacade().addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                handlePositionsUpdate();
            }
        });
        r.getPositionsModel().addTableModelListener(new TableModelListener() {
            public void tableChanged(TableModelEvent e) {
                handlePositionsUpdate();
            }
        });
View Full Code Here

Examples of slash.navigation.converter.gui.RouteConverter

        handlePositionsUpdate();
    }

    private void handlePositionsUpdate() {
        RouteConverter r = RouteConverter.getInstance();
        int selectedRowCount = r.getPositionsView().getSelectedRowCount();
        labelSelection.setText(MessageFormat.format(RouteConverter.getBundle().getString("selected-positions"), selectedRowCount));

        boolean existsSelectedPosition = selectedRowCount > 0;
        buttonInsertAllWaypoints.setEnabled(existsSelectedPosition);
        buttonInsertOnlyTurnpoints.setEnabled(existsSelectedPosition && r.getRoutingServiceFacade().getRoutingService().isSupportTurnpoints());
        buttonClearSelection.setEnabled(existsSelectedPosition);

        boolean notAllPositionsSelected = r.getPositionsView().getRowCount() > selectedRowCount;
        buttonSelectAll.setEnabled(notAllPositionsSelected);
    }
View Full Code Here

Examples of slash.navigation.converter.gui.RouteConverter

        boolean notAllPositionsSelected = r.getPositionsView().getRowCount() > selectedRowCount;
        buttonSelectAll.setEnabled(notAllPositionsSelected);
    }

    private void selectAll() {
        RouteConverter r = RouteConverter.getInstance();
        r.getContext().getActionManager().run("select-all");
        int selectedRowCount = r.getPositionsView().getSelectedRowCount();
        labelSelection.setText(MessageFormat.format(RouteConverter.getBundle().getString("selected-all-positions"), selectedRowCount));
    }
View Full Code Here

Examples of slash.navigation.converter.gui.RouteConverter

        this.tree = tree;
        this.catalogModel = catalogModel;
    }

    public void run() {
        RouteConverter r = RouteConverter.getInstance();

        CategoryTreeNode category = getSelectedCategoryTreeNode(tree);
        if(category == null)
            return;

        if(category.isLocalRoot() || category.isRemoteRoot()) {
            showMessageDialog(getFrame(),
                    RouteConverter.getBundle().getString("rename-category-cannot-rename-root"), getFrame().getTitle(),
                    ERROR_MESSAGE);
            return;
        }

        String name = (String) showInputDialog(r.getFrame(),
                format(RouteConverter.getBundle().getString("rename-category-label"), category.getName()),
                r.getFrame().getTitle(), QUESTION_MESSAGE, null, null, category.getName());
        if (trim(name) == null)
            return;

        catalogModel.renameCategory(category, name);
    }
View Full Code Here

Examples of slash.navigation.converter.gui.RouteConverter

* @author Christian Pesch
*/

public class InsertPositionFacade {
    public void insertAllWaypoints() {
        RouteConverter r = RouteConverter.getInstance();
        int[] selectedRows = r.getPositionsView().getSelectedRows();
        r.clearSelection();

        RoutingService routingService = r.getRoutingServiceFacade().getRoutingService();
        if (routingService instanceof GoogleDirections && r.isMapViewInitialized()) {
            ((GoogleDirections) routingService).insertAllWaypoints(selectedRows);
        } else
            insertWithRoutingService(routingService, selectedRows);
    }
View Full Code Here

Examples of slash.navigation.converter.gui.RouteConverter

        } else
            insertWithRoutingService(routingService, selectedRows);
    }

    public void insertOnlyTurnpoints() {
        RouteConverter r = RouteConverter.getInstance();
        int[] selectedRows = r.getPositionsView().getSelectedRows();
        r.clearSelection();

        RoutingService routingService = r.getRoutingServiceFacade().getRoutingService();
        if (routingService instanceof GoogleDirections && r.isMapViewInitialized()) {
            ((GoogleDirections) routingService).insertOnlyTurnpoints(selectedRows);
        } else
            throw new UnsupportedOperationException();
    }
View Full Code Here

Examples of slash.navigation.converter.gui.RouteConverter

        this.tree = tree;
        this.catalogModel = catalogModel;
    }

    public void run() {
        RouteConverter r = RouteConverter.getInstance();

        List<CategoryTreeNode> categories = getSelectedCategoryTreeNodes(tree);
        if (categories.size() == 0)
            return;

        StringBuilder categoryNames = new StringBuilder();
        for (int i = 0; i < categories.size(); i++) {
            CategoryTreeNode category = categories.get(i);

            if(category.isLocalRoot() || category.isRemoteRoot()) {
                showMessageDialog(getFrame(),
                        RouteConverter.getBundle().getString("remove-category-cannot-delete-root"), getFrame().getTitle(),
                        ERROR_MESSAGE);
                return;
            }

            categoryNames.append(category.getName());
            if (i < categories.size() - 1)
                categoryNames.append(", ");
        }

        final List<CategoryTreeNode> parents = asParents(categories);

        int confirm = showConfirmDialog(r.getFrame(),
                format(RouteConverter.getBundle().getString("confirm-remove-category"), categoryNames),
                r.getFrame().getTitle(), YES_NO_OPTION);
        if (confirm != YES_OPTION)
            return;

        catalogModel.removeCategories(categories, new Runnable() {
            public void run() {
View Full Code Here

Examples of slash.navigation.converter.gui.RouteConverter

        } else
            throw new UnsupportedOperationException();
    }

    private void insertWithRoutingService(RoutingService routingService, int[] selectedRows) {
        RouteConverter r = RouteConverter.getInstance();
        List<NavigationPosition> selectedPositions = new ArrayList<NavigationPosition>();
        for (int i = 0; i < selectedRows.length; i++)
            selectedPositions.add(r.getPositionsModel().getPosition(i));

        if (routingService.isDownload()) {
            List<LongitudeAndLatitude> lal = new ArrayList<LongitudeAndLatitude>();
            for (NavigationPosition position : selectedPositions) {
                lal.add(asLongitudeAndLatitude(position));
            }
            routingService.downloadRoutingDataFor(lal);
        }

        TravelMode travelMode = r.getRoutingServiceFacade().getTravelMode();
        for (int i = 0; i < selectedPositions.size(); i++) {
            // skip the very last position without successor
            if (i == r.getPositionsModel().getRowCount() - 1 || i == selectedPositions.size() - 1)
                continue;

            RoutingResult result = routingService.getRouteBetween(selectedPositions.get(i), selectedPositions.get(i + 1), travelMode);
            if (result != null) {
                List<BaseNavigationPosition> positions = new ArrayList<BaseNavigationPosition>();
                for (NavigationPosition position : result.getPositions()) {
                    positions.add(r.getPositionsModel().getRoute().createPosition(position.getLongitude(), position.getLatitude(), position.getElevation(), null, null, null));
                }
                int insertRow = r.getPositionsModel().getIndex(selectedPositions.get(i)) + 1;
                r.getPositionsModel().add(insertRow, positions);

                for (int j = 0; j < positions.size(); j++) {
                    int[] rows = new int[]{insertRow + j};
                    r.getBatchPositionAugmenter().addData(rows, false, true, true);
                }
            }
        }
    }
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.