Package slash.navigation.common

Examples of slash.navigation.common.NavigationPosition


        processSpeeds(positionsView, positionsModel, rows, COORDINATE_PREDICATE);
    }

    private NavigationPosition findPredecessorWithTime(PositionsModel positionsModel, int index) {
        while (index-- > 0) {
            NavigationPosition position = positionsModel.getPosition(index);
            if (position.hasTime())
                return position;
        }
        return null;
    }
View Full Code Here


        return null;
    }

    private NavigationPosition findSuccessorWithTime(PositionsModel positionsModel, int index) {
        while (index++ < positionsModel.getRowCount() - 1) {
            NavigationPosition position = positionsModel.getPosition(index);
            if (position.hasTime())
                return position;
        }
        return null;
    }
View Full Code Here

                    public void performOnStart() {
                    }

                    public boolean run(int index, NavigationPosition position) throws Exception {
                        NavigationPosition predecessor = findPredecessorWithTime(positionsModel, index);
                        NavigationPosition successor = findSuccessorWithTime(positionsModel, index);
                        if (predecessor != null && successor != null) {
                            CompactCalendar previousTime = position.getTime();
                            CompactCalendar nextTime = intrapolateTime(position, predecessor, successor);
                            boolean changed = nextTime == null || !nextTime.equals(previousTime);
                            if (changed)
View Full Code Here

                                columnValues.add(nextElevation);
                            }
                        }

                        if (complementTime) {
                            NavigationPosition predecessor = findPredecessorWithTime(positionsModel, index);
                            NavigationPosition successor = findSuccessorWithTime(positionsModel, index);
                            if (predecessor != null && successor != null) {
                                CompactCalendar previousTime = position.getTime();
                                CompactCalendar nextTime = intrapolateTime(position, predecessor, successor);
                                boolean changed = nextTime == null || !nextTime.equals(previousTime);
                                if (changed) {
View Full Code Here

    public int getColumnCount() {
        throw new IllegalArgumentException("This is determined by the PositionsTableColumnModel");
    }

    public String getStringAt(int rowIndex, int columnIndex) {
        NavigationPosition position = getPosition(rowIndex);
        switch (columnIndex) {
            case DESCRIPTION_COLUMN_INDEX:
                return position.getDescription();
            case DATE_TIME_COLUMN_INDEX:
                return extractDateTime(position);
            case TIME_COLUMN_INDEX:
                return extractTime(position);
            case LONGITUDE_COLUMN_INDEX:
                return formatLongitude(position.getLongitude());
            case LATITUDE_COLUMN_INDEX:
                return formatLatitude(position.getLatitude());
            case ELEVATION_COLUMN_INDEX:
                return extractElevation(position);
            case SPEED_COLUMN_INDEX:
                return extractSpeed(position);
        }
View Full Code Here

                fireTableRowsUpdated(rowIndex, rowIndex, columnToValues.getColumnIndices().get(0));
        }
    }

    private void editCell(int rowIndex, int columnIndex, Object value) {
        NavigationPosition position = getPosition(rowIndex);
        String string = value != null ? trim(value.toString()) : null;
        switch (columnIndex) {
            case DESCRIPTION_COLUMN_INDEX:
                position.setDescription(string);
                break;
            case DATE_TIME_COLUMN_INDEX:
                position.setTime(parseDateTime(value, string));
                break;
            case TIME_COLUMN_INDEX:
                position.setTime(parseTime(value, string, position.getTime()));
                break;
            case LONGITUDE_COLUMN_INDEX:
                position.setLongitude(parseLongitude(value, string));
                break;
            case LATITUDE_COLUMN_INDEX:
                position.setLatitude(parseLatitude(value, string));
                break;
            case ELEVATION_COLUMN_INDEX:
                position.setElevation(parseElevation(value, string));
                break;
            case SPEED_COLUMN_INDEX:
                position.setSpeed(parseSpeed(value, string));
                break;
            default:
                throw new IllegalArgumentException("Row " + rowIndex + ", column " + columnIndex + " does not exist");
        }
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    void add(int row, List<NavigationPosition> positions, boolean fireEvent, boolean trackUndo) {
        for (int i = positions.size() - 1; i >= 0; i--) {
            NavigationPosition position = positions.get(i);
            getRoute().add(row, (BaseNavigationPosition) position);
        }
        if (fireEvent)
            delegate.fireTableRowsInserted(row, row - 1 + positions.size());
        if (trackUndo)
View Full Code Here

        this.positionsModel = positionsModel;
        this.positionsSelectionModel = positionsSelectionModel;
    }

    private NavigationPosition calculateCenter(int row) {
        NavigationPosition position = positionsModel.getPosition(row);
        // if there is only one position or it is the first row, choose the map center
        if (row >= positionsModel.getRowCount() - 1)
            return null;
        // otherwise center between given positions
        NavigationPosition second = positionsModel.getPosition(row + 1);
        if (!second.hasCoordinates() || !position.hasCoordinates())
            return null;
        return new BoundingBox(asList(second, position)).getCenter();
    }
View Full Code Here

        if (!areRowsSelected)
            rowIndices = new int[]{table.getRowCount()};
        for (int row : rowIndices) {
            int insertRow = row > positionsModel.getRowCount() - 1 ? row : row + 1;

            NavigationPosition center = areRowsSelected ? calculateCenter(row) :
                    positionsModel.getRowCount() > 0 ? calculateCenter(positionsModel.getRowCount() - 1) : null;
            if (center == null) {
                // only insert row in map center once
                if (hasInsertedRowInMapCenter)
                    continue;
View Full Code Here

        assertEquals(testPositionCount + appendPositionCount, route.getPositionCount());

        List<BaseNavigationPosition> positions = route.getPositions();
        Class<? extends NavigationPosition> positionClass = testPositions.get(0).getClass();
        for (int i = 0; i < testPositionCount; i++) {
            NavigationPosition position = positions.get(i);
            assertEquals(positionClass, position.getClass());
            assertEquals(testPositions.get(i), position);
        }

        for (int i = testPositionCount; i < testPositionCount + appendPositionCount; i++) {
            NavigationPosition position = positions.get(i);
            assertEquals(positionClass, position.getClass());
            NavigationPosition expected = asFormat(appendPositions.get(i - testPositionCount), route.getFormat());
            assertEquals(expected, position);
        }
    }
View Full Code Here

TOP

Related Classes of slash.navigation.common.NavigationPosition

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.