+ /**
+ * Create a DataPoint object from the given click coordinates
+ * @param inX x coordinate of click
+ * @param inY y coordinate of click
+ * @return DataPoint with given coordinates and no altitude
+ */
+ private DataPoint createPointFromClick(int inX, int inY)
+ {
+ double lat = MapUtils.getLatitudeFromY(_mapPosition.getYFromPixels(inY, getHeight()));
+ double lon = MapUtils.getLongitudeFromX(_mapPosition.getXFromPixels(inX, getWidth()));
+ return new DataPoint(new Latitude(lat, Coordinate.FORMAT_NONE),
+ new Longitude(lon, Coordinate.FORMAT_NONE), null);
+ }
+
+ /**
+ * Move a DataPoint object to the given mouse coordinates
+ * @param startX start x coordinate of mouse
+ * @param startY start y coordinate of mouse
+ * @param endX end x coordinate of mouse
+ * @param endY end y coordinate of mouse
+ */
+ private void movePointToMouse(int startX, int startY, int endX, int endY )
+ {
+ double lat1 = MapUtils.getLatitudeFromY(_mapPosition.getYFromPixels(startY, getHeight()));
+ double lon1 = MapUtils.getLongitudeFromX(_mapPosition.getXFromPixels(startX, getWidth()));
+ double lat_delta = MapUtils.getLatitudeFromY(_mapPosition.getYFromPixels(endY, getHeight())) - lat1;
+ double lon_delta = MapUtils.getLongitudeFromX(_mapPosition.getXFromPixels(endX, getWidth())) - lon1;
+
+ DataPoint point = _trackInfo.getCurrentPoint();
+ if (point == null) {
+ return;
+ }
+
+ // Make lists for edit and undo, and add each changed field in turn
+ FieldEditList editList = new FieldEditList();
+ FieldEditList undoList = new FieldEditList();
+
+ // Check field list
+ FieldList fieldList = _track.getFieldList();
+ int numFields = fieldList.getNumFields();
+ for (int i=0; i<numFields; i++)
+ {
+ Field field = fieldList.getField(i);
+ if (field == Field.LATITUDE) {
+ editList.addEdit(new FieldEdit(field, Double.toString(point.getLatitude().getDouble() + lat_delta)));
+ undoList.addEdit(new FieldEdit(field, point.getFieldValue(Field.LATITUDE)));
+ }
+ else if (field == Field.LONGITUDE) {
+ editList.addEdit(new FieldEdit(field, Double.toString(point.getLongitude().getDouble() + lon_delta)));
+ undoList.addEdit(new FieldEdit(field, point.getFieldValue(Field.LONGITUDE)));
+ }
+ }
+ _app.completePointEdit(editList, undoList);
+ }
+
+