Package slash.navigation.base

Examples of slash.navigation.base.BaseRoute


            if (coordinates.size() < 5 || pair == null)
                return true;

            final NavigationPosition before = pair.getFirst();
            NavigationPosition after = pair.getSecond();
            final BaseRoute route = parseRoute(coordinates, before, after);
            synchronized (notificationMutex) {
                int row = positions.indexOf(before) + 1;
                insertPositions(row, route);
            }
            invokeLater(new Runnable() {
View Full Code Here


        return !isEmpty(result) ? result : null;
    }

    @SuppressWarnings("unchecked")
    private BaseRoute parseRoute(List<String> coordinates, NavigationPosition before, NavigationPosition after) {
        BaseRoute route = new NavigatingPoiWarnerFormat().createRoute(Waypoints, null, new ArrayList<NavigationPosition>());
        // count backwards as inserting at position 0
        CompactCalendar time = after.getTime();
        int positionInsertionCount = coordinates.size() / 5;
        for (int i = coordinates.size() - 1; i > 0; i -= 5) {
            String instructions = trim(coordinates.get(i));
            Double seconds = parseSeconds(coordinates.get(i - 1));
            // Double meters = parseDouble(coordinates.get(i - 2));
            Double longitude = parseDouble(coordinates.get(i - 3));
            Double latitude = parseDouble(coordinates.get(i - 4));
            if (seconds != null && time != null) {
                Calendar calendar = time.getCalendar();
                calendar.add(SECOND, -seconds.intValue());
                time = fromCalendar(calendar);
            }
            int positionNumber = positionsModel.getRowCount() + (positionInsertionCount - route.getPositionCount()) - 1;
            String description = instructions != null ? instructions : mapViewCallback.createDescription(positionNumber, null);
            BaseNavigationPosition position = route.createPosition(longitude, latitude, null, null, seconds != null ? time : null, description);
            if (!isDuplicate(before, position) && !isDuplicate(after, position)) {
                route.add(0, position);
            }
        }
        return route;
    }
View Full Code Here

        RouteConverter r = RouteConverter.getInstance();
        if (file.getParent() != null)
            preferences.put(WRITE_PATH_PREFERENCE + format.getClass().getName(), file.getParent());

        boolean duplicateFirstPosition = format instanceof NmnFormat && !(format instanceof Nmn7Format) || format instanceof CoPilotFormat;
        BaseRoute route = formatAndRoutesModel.getSelectedRoute();
        int fileCount = getNumberOfFilesToWriteFor(route, format, duplicateFirstPosition);
        if (fileCount > 1) {
            int confirm = showConfirmDialog(r.getFrame(),
                    MessageFormat.format(RouteConverter.getBundle().getString("save-confirm-split"),
                            shortenPath(file.getPath(), 60), route.getPositionCount(), format.getName(),
                            format.getMaximumPositionCount(), fileCount),
                    r.getFrame().getTitle(), YES_NO_CANCEL_OPTION
            );
            switch (confirm) {
                case YES_OPTION:
View Full Code Here

*/

public class RouteListCellRenderer extends DefaultListCellRenderer {
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        BaseRoute route = (BaseRoute) value;
        String text = "?";
        if (route != null) {
            String characteristics = RouteConverter.getBundle().getString(route.getCharacteristics().name().toLowerCase() + "-characteristics");
            String name = route.getName() != null ? route.getName() : "?";
            text = name + " (" + characteristics + ")";
        }
        label.setText(text);
        return label;
    }
View Full Code Here

    public RemovePositionListAction(FormatAndRoutesModel formatAndRoutesModel) {
        this.formatAndRoutesModel = formatAndRoutesModel;
    }

    public void run() {
        BaseRoute selectedRoute = formatAndRoutesModel.getSelectedRoute();
        if (selectedRoute != null)
            formatAndRoutesModel.removePositionList(selectedRoute);
    }
View Full Code Here

    }

    public void run() {
        int[] selectedRows = table.getSelectedRows();
        if (selectedRows.length > 0) {
            BaseRoute selectedRoute = formatAndRoutesModel.getSelectedRoute();
            int routeInsertIndex = formatAndRoutesModel.getIndex(selectedRoute) + 1;

            for (int i = selectedRows.length - 1; i >= 0; i--) {
                int fromIndex = selectedRows[i];
                fromIndex = max(fromIndex, 0);
                int toIndex = i + 1 < selectedRows.length ? selectedRows[i + 1] : positionsModel.getRowCount();
                toIndex = max(toIndex, 0);
                if (fromIndex == 0 && toIndex == 0)
                    break;

                List<NavigationPosition> positions = positionsModel.getPositions(fromIndex, toIndex);
                positionsModel.remove(fromIndex, toIndex);
                NavigationFormat format = formatAndRoutesModel.getFormat();
                @SuppressWarnings({"unchecked"})
                BaseRoute<BaseNavigationPosition, BaseNavigationFormat> target =
                        format.createRoute(selectedRoute.getCharacteristics(), getRouteName(selectedRoute, routeInsertIndex), positions);
                formatAndRoutesModel.addPositionList(routeInsertIndex, target);
            }

            final int selectedRow = max(selectedRows[selectedRows.length - 1] - 1, 0);
            invokeLater(new Runnable() {
View Full Code Here

    }

    public void setSelectedRoute(BaseRoute route, boolean trackUndo) {
        if ((getSelectedRoute() != null && !getSelectedRoute().equals(route)) ||
                getSelectedRoute() == null && route != null) {
            BaseRoute previousRoute = trackUndo ? getSelectedRoute() : null;
            delegate.setSelectedRoute(route);
            if (trackUndo)
                undoManager.addEdit(new ChangeRoute(this, previousRoute, route));
        }
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public void run() {
        NavigationFormat format = formatAndRoutesModel.getFormat();
        BaseRoute route = format.createRoute((RouteCharacteristics) formatAndRoutesModel.getCharacteristicsModel().getSelectedItem(),
                MessageFormat.format(RouteConverter.getBundle().getString("new-positionlist-name"), formatAndRoutesModel.getSize() + 1),
                new ArrayList<NavigationPosition>());
        formatAndRoutesModel.addPositionList(formatAndRoutesModel.getSize(), route);
        formatAndRoutesModel.setSelectedItem(route);
    }
View Full Code Here

                !(e.getColumn() == LONGITUDE_COLUMN_INDEX || e.getColumn() == LATITUDE_COLUMN_INDEX))
            return;
        if (getDelegate().isContinousRange())
            return;

        BaseRoute route = getDelegate().getRoute();
        if (route != null && route.getCharacteristics() == Waypoints) {
            updateLabel(0, 0);
        }
    }
View Full Code Here

                !(e.getColumn() == ELEVATION_COLUMN_INDEX))
            return;
        if (getDelegate().isContinousRange())
            return;

        BaseRoute route = getDelegate().getRoute();
        if (route != null) {
            updateLabel(route.getElevationAscend(0, route.getPositionCount() - 1),
                        route.getElevationDescend(0, route.getPositionCount() - 1));
        } else {
            updateLabel(0, 0);
        }
    }
View Full Code Here

TOP

Related Classes of slash.navigation.base.BaseRoute

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.