fix rendering treatments with duration

This commit is contained in:
Milos Kozak 2018-01-22 19:12:22 +01:00
parent f835c272ad
commit d033407ba7
2 changed files with 13 additions and 12 deletions

View file

@ -253,7 +253,7 @@ public class GraphData {
} }
// Careportal // Careportal
List<CareportalEvent> careportalEvents = MainApp.getDbHelper().getCareportalEventsFromTime(fromTime, true); List<CareportalEvent> careportalEvents = MainApp.getDbHelper().getCareportalEventsFromTime(fromTime - 6 * 60 * 60 * 1000, true);
for (int tx = 0; tx < careportalEvents.size(); tx++) { for (int tx = 0; tx < careportalEvents.size(); tx++) {
DataPointWithLabelInterface t = careportalEvents.get(tx); DataPointWithLabelInterface t = careportalEvents.get(tx);

View file

@ -141,9 +141,6 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
Iterator<E> values = getValues(minX, maxX); Iterator<E> values = getValues(minX, maxX);
// draw background // draw background
double lastEndY = 0;
double lastEndX = 0;
// draw data // draw data
double diffY = maxY - minY; double diffY = maxY - minY;
@ -154,9 +151,8 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
float graphLeft = graphView.getGraphContentLeft(); float graphLeft = graphView.getGraphContentLeft();
float graphTop = graphView.getGraphContentTop(); float graphTop = graphView.getGraphContentTop();
lastEndY = 0; float scaleX = (float) (graphWidth / diffX);
lastEndX = 0;
float firstX = 0;
int i=0; int i=0;
while (values.hasNext()) { while (values.hasNext()) {
E value = values.next(); E value = values.next();
@ -171,9 +167,6 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
double ratX = valX / diffX; double ratX = valX / diffX;
double x = graphWidth * ratX; double x = graphWidth * ratX;
double orgX = x;
double orgY = y;
// overdraw // overdraw
boolean overdraw = false; boolean overdraw = false;
if (x > graphWidth) { // end right if (x > graphWidth) { // end right
@ -185,6 +178,14 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
if (y > graphHeight) { // end top if (y > graphHeight) { // end top
overdraw = true; overdraw = true;
} }
long duration = value.getDuration();
float endWithDuration = (float) (x + duration * scaleX + graphLeft + 1);
// cut off to graph start if needed
if (x < 0 && endWithDuration > 0) {
x = 0;
}
/* Fix a bug that continue to show the DOT after Y axis */ /* Fix a bug that continue to show the DOT after Y axis */
if(x < 0) { if(x < 0) {
overdraw = true; overdraw = true;
@ -195,8 +196,8 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
registerDataPoint(endX, endY, value); registerDataPoint(endX, endY, value);
float xpluslength = 0; float xpluslength = 0;
if (value.getDuration() > 0) { if (duration > 0) {
xpluslength = endX + Math.min((float) (value.getDuration() * graphWidth / diffX), graphLeft + graphWidth); xpluslength = Math.min(endWithDuration, graphLeft + graphWidth);
} }
// draw data point // draw data point