public NavigationPosition getPosition(int rowIndex) { return delegate.getPosition(rowIndex); }
int findPredecessorWithTime(PositionsModel positionsModel, int index) { while (index >= 0) { NavigationPosition position = positionsModel.getPosition(index); if (position.hasTime()) return index; index--; } return -1; }
private List<PositionWithLayer> asPositionWithLayers(int[] indices) { List<PositionWithLayer> result = new ArrayList<>(); for (int selectedPosition : indices) { if (selectedPosition >= positionsModel.getRowCount()) continue; result.add(new PositionWithLayer(positionsModel.getPosition(selectedPosition))); } return result; }
public synchronized void handleAdd(int firstRow, int lastRow) { int validLastRow = min(lastRow, positionsModel.getRowCount() - 1); List<PositionWithLayer> added = new ArrayList<>(); for (int i = firstRow; i <= validLastRow; i++) { PositionWithLayer positionWithLayer = new PositionWithLayer(positionsModel.getPosition(i)); positionWithLayers.add(i, positionWithLayer); added.add(positionWithLayer); } if (!added.isEmpty()) waypointOperation.add(added); }
private int getAddRow() { NavigationPosition position = lastSelectedPositions.size() > 0 ? lastSelectedPositions.get(lastSelectedPositions.size() - 1) : null; // quite crude logic to be as robust as possible on failures if (position == null && positionsModel.getRowCount() > 0) position = positionsModel.getPosition(positionsModel.getRowCount() - 1); return position != null ? positionsModel.getIndex(position) + 1 : 0; }
public synchronized void handleUpdate(int firstRow, int lastRow) { int beforeFirstRow = firstRow > 0 ? firstRow - 1 : firstRow; int validLastRow = min(lastRow, positionsModel.getRowCount() - 1); int afterLastRow = lastRow < positionsModel.getRowCount() - 1 ? lastRow + 1 : validLastRow; List<PairWithLayer> updated = new ArrayList<>(); for (int i = beforeFirstRow; i < afterLastRow; i++) { PairWithLayer pairWithLayer = new PairWithLayer(positionsModel.getPosition(i), positionsModel.getPosition(i + 1)); pairWithLayer.setLayer(pairWithLayers.get(i).getLayer()); pairWithLayers.set(i, pairWithLayer); updated.add(pairWithLayers.get(i)); } if (!updated.isEmpty()) trackOperation.update(updated); }
int findSuccessorWithTime(PositionsModel positionsModel, int index) { while (index < positionsModel.getRowCount()) { NavigationPosition position = positionsModel.getPosition(index); if (position.hasTime()) return index; index++; } return -1; }
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(); }
public void run() { int[] selectedRows = table.getSelectedRows(); for (final int selectedRow : selectedRows) { NavigationPosition position = positionsModel.getPosition(selectedRow); if (!(position instanceof Wgs84Position)) continue; Wgs84Position wgs84Position = (Wgs84Position) position; if (!(wgs84Position.getWaypointType().equals(Voice))) continue; addAudio(wgs84Position); } }
public synchronized void handleAdd(int firstRow, int lastRow) { int beforeFirstRow = firstRow > 0 ? firstRow - 1 : firstRow; int validLastRow = min(lastRow, positionsModel.getRowCount() - 1); int afterLastRow = lastRow < positionsModel.getRowCount() - 1 ? lastRow + 1 : validLastRow; List<PairWithLayer> removed = new ArrayList<>(); // do not remove anything if a new position is prepended or appended to the track if (firstRow > 0 && lastRow < positionsModel.getRowCount() - 1) removed.add(pairWithLayers.remove(beforeFirstRow)); List<PairWithLayer> added = new ArrayList<>(); for (int i = beforeFirstRow; i < afterLastRow; i++) { PairWithLayer pairWithLayer = new PairWithLayer(positionsModel.getPosition(i), positionsModel.getPosition(i + 1)); pairWithLayers.add(i, pairWithLayer); added.add(pairWithLayer); } if (!removed.isEmpty()) trackOperation.remove(removed); if (!added.isEmpty()) trackOperation.add(added); }
public NavigationPosition getPosition(int rowIndex) { return getDelegate().getPosition(mapRow(rowIndex)); }
private int getAddRow() { List<PositionWithLayer> lastSelectedPositions = selectionUpdater.getPositionWithLayers(); NavigationPosition position = lastSelectedPositions.size() > 0 ? lastSelectedPositions.get(lastSelectedPositions.size() - 1).getPosition() : null; // quite crude logic to be as robust as possible on failures if (position == null && positionsModel.getRowCount() > 0) position = positionsModel.getPosition(positionsModel.getRowCount() - 1); return position != null ? positionsModel.getIndex(position) + 1 : 0; }
public void run() { File file = new File(urlModel.getString()); if (!file.exists()) return; int[] selectedRows = table.getSelectedRows(); for (final int selectedRow : selectedRows) { NavigationPosition position = positionsModel.getPosition(selectedRow); File voice = extractFile(position); if(voice == null) continue; RouteConverter.getInstance().getAudioPlayer().play(voice); } } }
private void downloadElevationData(int[] rows, boolean waitForDownload) { if (!elevationServiceFacade.isDownload()) return; List<LongitudeAndLatitude> longitudeAndLatitudes = new ArrayList<>(); for (int row : rows) { NavigationPosition position = positionsModel.getPosition(row); if (position.hasCoordinates()) longitudeAndLatitudes.add(new LongitudeAndLatitude(position.getLongitude(), position.getLatitude())); } elevationServiceFacade.downloadElevationDataFor(longitudeAndLatitudes, waitForDownload); }
private Integer count(TagState tagState) { int count = 0; for (int i = 0, c = getDelegate().getRowCount(); i < c; i++) { PhotoPosition position = (PhotoPosition) getDelegate().getPosition(i); if (tagState.equals(position.getTagState())) count++; } return count; }
public boolean run(int index, NavigationPosition position) { NavigationPosition predecessor = index > 0 && index < positionsModel.getRowCount() ? positionsModel.getPosition(index - 1) : null; if (predecessor != null) { String previousSpeed = formatSpeed(position.getSpeed()); String nextSpeed = formatSpeed(position.calculateSpeed(predecessor)); boolean changed = nextSpeed != null && !nextSpeed.equals(previousSpeed); if (changed) positionsModel.edit(index, new PositionColumnValues(SPEED_COLUMN_INDEX, nextSpeed), false, true); return changed; } return false; }
private void updateClosestPositionForTagging(PhotoPosition position) { position.setTagState(NotTaggable); position.setClosestPositionForTagging(null); PositionsModel originalPositionsModel = RouteConverter.getInstance().getConvertPanel().getPositionsModel(); int index = getClosestPositionByCoordinates(position); if (index != -1) { log.info("Tagging with closest position " + index + " by coordinates: " + position); position.setTagState(Tagged); position.setClosestPositionForTagging(originalPositionsModel.getPosition(index)); } else { index = getClosestPositionByTime(position); if (index != -1) { log.info("Tagging with closest position " + index + " by time: " + position); position.setTagState(Taggable); position.setClosestPositionForTagging(originalPositionsModel.getPosition(index)); } } }
private CompactCalendar interpolateTime(PositionsModel positionsModel, int positionIndex, int predecessorIndex, int successorIndex) { NavigationPosition predecessor = positionsModel.getPosition(predecessorIndex); if (!predecessor.hasTime()) return null; NavigationPosition successor = positionsModel.getPosition(successorIndex); if (!successor.hasTime()) return null; long timeDelta = abs(predecessor.calculateTime(successor)); if (timeDelta == 0) return null; double distanceToPredecessor = positionsModel.getRoute().getDistance(predecessorIndex, positionIndex); double distanceToSuccessor = positionsModel.getRoute().getDistance(positionIndex, successorIndex); if (distanceToPredecessor == 0.0) return null; double distanceRatio = distanceToPredecessor / (distanceToPredecessor + distanceToSuccessor); long time = (long) (predecessor.getTime().getTimeInMillis() + (double) timeDelta * distanceRatio); return fromMillis(time); }
private NavigationPosition insertRow(int row, NavigationPosition position) { String description = getBatchPositionAugmenter().createDescription(positionsModel.getRowCount() + 1, null); positionsModel.add(row, position.getLongitude(), position.getLatitude(), position.getElevation(), position.getSpeed(), position.getTime(), description); return positionsModel.getPosition(row); }
protected void handleIntervalYUpdate(int firstRow, int lastRow) { getSeries().setFireSeriesChanged(false); for (int i = firstRow; i < lastRow + 1; i++) { getSeries().updateByIndex(i, formatYValue(getPositions().getPosition(i))); } getSeries().setFireSeriesChanged(true); getSeries().fireSeriesChanged(); }