From eeaa363132fbe08acfb9816f118c68454e0b68bc Mon Sep 17 00:00:00 2001 From: Sandor Dornbush Date: Mon, 7 Feb 2011 21:50:12 -0800 Subject: [PATCH] Minor chart fixes. --- .../google/android/apps/mytracks/ChartActivity.java | 2 +- .../com/google/android/apps/mytracks/ChartView.java | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/MyTracks/src/com/google/android/apps/mytracks/ChartActivity.java b/MyTracks/src/com/google/android/apps/mytracks/ChartActivity.java index 0e4576326..73f201776 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/ChartActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/ChartActivity.java @@ -610,7 +610,7 @@ public class ChartActivity extends Activity implements */ private ArrayList readPointsToList(Track track) { Cursor cursor = null; - long lastLocationRead = track.getStartId(); + long lastLocationRead = lastSeenLocationId; int points = 0; int chartSamplingFrequency = getSamplingFrequency(track); ArrayList result = new ArrayList(); diff --git a/MyTracks/src/com/google/android/apps/mytracks/ChartView.java b/MyTracks/src/com/google/android/apps/mytracks/ChartView.java index 948b5439d..753a4a753 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/ChartView.java +++ b/MyTracks/src/com/google/android/apps/mytracks/ChartView.java @@ -216,7 +216,7 @@ public class ChartView extends View { R.color.speed_fill, R.color.speed_border, new ZoomSettings(MAX_INTERVALS, 0, Integer.MIN_VALUE, - new int[] {5, 10, 20, 50}), + new int[] {1, 5, 10, 20, 50}), R.string.speed); series[POWER_SERIES] = new ChartValueSeries(context, @@ -610,7 +610,8 @@ public class ChartView extends View { c.translate(getScrollX(), 0); drawYAxis(c); - final int spacer = 5; + float density = getContext().getResources().getDisplayMetrics().density; + final int spacer = (int) (5 * density); int x = leftBorder - spacer; for (ChartValueSeries cvs : series) { if (cvs.isEnabled() && cvs.hasData()) { @@ -726,9 +727,10 @@ public class ChartView extends View { maxLength += cvs.getMaxLabelLength(); } } - leftBorder = 4 + 8 * maxLength; - effectiveWidth = w - leftBorder - RIGHT_BORDER; float density = getContext().getResources().getDisplayMetrics().density; + // TODO: This should be function of the number of variables displayed. + leftBorder = (int) (density * (4 + 8 * maxLength)); + effectiveWidth = w - leftBorder - RIGHT_BORDER; bottomBorder = (int) (density * BOTTOM_BORDER); topBorder = (int) (density * TOP_BORDER); effectiveHeight = h - topBorder - bottomBorder; @@ -739,8 +741,9 @@ public class ChartView extends View { } private int getY(ChartValueSeries cvs, double y) { + int effectiveSpread = cvs.getInterval() * MAX_INTERVALS; return topBorder + effectiveHeight - - (int) ((y - cvs.getMin()) * effectiveHeight / cvs.getSpread()); + - (int) ((y - cvs.getMin()) * effectiveHeight / effectiveSpread); } private void drawXLabels(Canvas c) {