lecho.lib.hellocharts.model.PointValue Java Examples

The following examples show how to use lecho.lib.hellocharts.model.PointValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ComboLineColumnChartActivity.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private LineChartData generateLineData() {

            List<Line> lines = new ArrayList<Line>();
            for (int i = 0; i < numberOfLines; ++i) {

                List<PointValue> values = new ArrayList<PointValue>();
                for (int j = 0; j < numberOfPoints; ++j) {
                    values.add(new PointValue(j, randomNumbersTab[i][j]));
                }

                Line line = new Line(values);
                line.setColor(ChartUtils.COLORS[i]);
                line.setCubic(isCubic);
                line.setHasLabels(hasLabels);
                line.setHasLines(hasLines);
                line.setHasPoints(hasPoints);
                lines.add(line);
            }

            LineChartData lineChartData = new LineChartData(lines);

            return lineChartData;

        }
 
Example #2
Source File: LineChartRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private void drawPoints(Canvas canvas, Line line, int lineIndex, int mode) {
    pointPaint.setColor(line.getPointColor());
    int valueIndex = 0;
    for (PointValue pointValue : line.getValues()) {
        int pointRadius = ChartUtils.dp2px(density, line.getPointRadius());
        final float rawX = computator.computeRawX(pointValue.getX());
        final float rawY = computator.computeRawY(pointValue.getY());
        if (computator.isWithinContentRect(rawX, rawY, checkPrecision)) {
            // Draw points only if they are within contentRectMinusAllMargins, using contentRectMinusAllMargins
            // instead of viewport to avoid some
            // float rounding problems.
            if (MODE_DRAW == mode) {
                drawPoint(canvas, line, pointValue, rawX, rawY, pointRadius);
                if (line.hasLabels()) {
                    drawLabel(canvas, line, pointValue, rawX, rawY, pointRadius + labelOffset);
                }
            } else if (MODE_HIGHLIGHT == mode) {
                highlightPoint(canvas, line, pointValue, rawX, rawY, lineIndex, valueIndex);
            } else {
                throw new IllegalStateException("Cannot process points in mode: " + mode);
            }
        }
        ++valueIndex;
    }
}
 
Example #3
Source File: MetricCounterFragment.java    From hawkular-android-client with Apache License 2.0 6 votes vote down vote up
private void setUpChartLine() {
    List<PointValue> chartPoints = getChartPoints();
    List<AxisValue> chartAxisPoints = getChartAxisPoints();

    Line chartLine = new Line(chartPoints)
            .setColor(getResources().getColor(R.color.background_primary_dark))
            .setCubic(true)
            .setHasPoints(false);

    LineChartData chartData = new LineChartData()
            .setLines(Collections.singletonList(chartLine));
    chartData.setAxisXBottom(new Axis()
            .setValues(chartAxisPoints));
    chartData.setAxisYLeft(new Axis()
            .setHasLines(true));

    chart.setLineChartData(chartData);
}
 
Example #4
Source File: BgGraphBuilder.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
@Override
public synchronized void onValueSelected(int i, int i1, PointValue pointValue) {
	
	String filtered = "";
	try {
		PointValueExtended pve = (PointValueExtended) pointValue;
		if(pve.calculatedFilteredValue != -1) {
			filtered = " (" + Math.round(pve.calculatedFilteredValue*10) / 10d +")";
		}
	} catch (ClassCastException e) {
		Log.e(TAG, "Error casting a point from pointValue to PointValueExtended", e);
	}
    final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
    //Won't give the exact time of the reading but the time on the grid: close enough.
    Long time = ((long)pointValue.getX())*FUZZER;
    if(tooltip!= null){
        tooltip.cancel();
    }
    tooltip = Toast.makeText(context, timeFormat.format(time)+ ": " + Math.round(pointValue.getY()*10)/ 10d + filtered, Toast.LENGTH_LONG);
    tooltip.show();
}
 
Example #5
Source File: ViewPagerChartsActivity.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private LineChartData generateLineChartData() {
    int numValues = 20;

    List<PointValue> values = new ArrayList<PointValue>();
    for (int i = 0; i < numValues; ++i) {
        values.add(new PointValue(i, (float) Math.random() * 100f));
    }

    Line line = new Line(values);
    line.setColor(ChartUtils.COLOR_GREEN);

    List<Line> lines = new ArrayList<Line>();
    lines.add(line);

    LineChartData data = new LineChartData(lines);
    data.setAxisXBottom(new Axis().setName("Axis X"));
    data.setAxisYLeft(new Axis().setName("Axis Y").setHasLines(true));
    return data;

}
 
Example #6
Source File: BgGraphBuilder.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
private void addPredictionLines(List<Line> lines) {
    Map<Integer, List<PointValue>> values = new HashMap<>();
    long endTime = getPredictionEndTime();
    for (BgWatchData bwd : predictionsList) {
        if (bwd.timestamp <= endTime) {
            double value = bwd.sgv < 300 ? bwd.sgv : 300;
            if (!values.containsKey(bwd.color)) {
                values.put(bwd.color, new ArrayList<>());
            }
            values.get(bwd.color).add(new PointValue(fuzz(bwd.timestamp), (float) value));
        }
    }
    for (Map.Entry<Integer, List<PointValue>> entry : values.entrySet()) {
        Line line = new Line(entry.getValue());
        line.setColor(entry.getKey());
        line.setHasLines(false);
        int size = pointSize / 2;
        size = (size > 0) ? size : 1;
        line.setPointRadius(size);
        line.setHasPoints(true);
        lines.add(line);
    }
}
 
Example #7
Source File: BgGraphBuilder.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
public Line tempValuesLine(TempWatchData twd, float offset, double factor, boolean isHighlightLine, int strokeWidth) {
    List<PointValue> lineValues = new ArrayList<PointValue>();
    long begin = (long) Math.max(start_time, twd.startTime);
    lineValues.add(new PointValue(fuzz(begin), offset + (float) (factor * twd.startBasal)));
    lineValues.add(new PointValue(fuzz(begin), offset + (float) (factor * twd.amount)));
    lineValues.add(new PointValue(fuzz(twd.endTime), offset + (float) (factor * twd.amount)));
    lineValues.add(new PointValue(fuzz(twd.endTime), offset + (float) (factor * twd.endBasal)));
    Line valueLine = new Line(lineValues);
    valueLine.setHasPoints(false);
    if (isHighlightLine){
        valueLine.setColor(basalCenterColor);
        valueLine.setStrokeWidth(1);
    }else {
        valueLine.setColor(basalBackgroundColor);
        valueLine.setStrokeWidth(strokeWidth);
    }
    return valueLine;
}
 
Example #8
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
public synchronized void onValueSelected(int i, int i1, PointValue pointValue) {
	
	String filtered = "";
	try {
		PointValueExtended pve = (PointValueExtended) pointValue;
		if(pve.calculatedFilteredValue != -1) {
			filtered = " (" + Math.round(pve.calculatedFilteredValue*10) / 10d +")";
		}
	} catch (ClassCastException e) {
		Log.e(TAG, "Error casting a point from pointValue to PointValueExtended", e);
	}
    final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
    //Won't give the exact time of the reading but the time on the grid: close enough.
    Long time = ((long)pointValue.getX())*FUZZER;
    if(tooltip!= null){
        tooltip.cancel();
    }
    tooltip = Toast.makeText(context, timeFormat.format(time)+ ": " + Math.round(pointValue.getY()*10)/ 10d + filtered, Toast.LENGTH_LONG);
    tooltip.show();
}
 
Example #9
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private void addCalibrations() {
    try {
        for (BgWatchData calibration : calDataList) {
            if(calibration.timestamp > start_time) {
                final long adjusted_timestamp = ((long)(calibration.timestamp) + (estimatedInterstitialLagSeconds * 1000));
                //final long adjusted_timestamp = ((long)calibration.timestamp + (estimatedInterstitialLagSeconds * 1000));
                final PointValueExtended this_point = new PointValueExtended((float) (adjusted_timestamp / FUZZER), (float) unitized(calibration.sgv));
                this_point.real_timestamp = (long)calibration.timestamp;
                //calibrationValues.add(this_point);
                calibrationValues.add(new PointValue(fuzz(adjusted_timestamp), (float) unitized(calibration.sgv)));//KS calibration.timestamp
                if (d)
                    Log.d(TAG, "calibration total record: " + calibration.sgv + " " + " adjusted_timestamp: " + fuzz(calibration.timestamp) + " timestamp=" + JoH.dateTimeText((long) calibration.timestamp));
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "Exception doing calibration values in bggraphbuilder: " + e.toString());
    }
}
 
Example #10
Source File: LibreTrendGraph.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static List<PointValue> getTrendDataPointsOld(boolean doMgdl, long start_time, long end_time) {
   // TODO needs to cut off if would exceed the current graph scope
    final float conversion_factor_mmol = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL);
    final LibreBlock libreBlock= LibreBlock.getLatestForTrend(start_time, end_time );
    if (libreBlock != null) {
        final ArrayList<Float> bg_data = getLatestBg(libreBlock);
        if (bg_data != null) {
            final ArrayList<PointValue> points = new ArrayList<>(bg_data.size());
            long time_offset = 0;
            for (Float bg : bg_data) {
                points.add(new PointValue((float) ((libreBlock.timestamp - time_offset) / FUZZER), bg * conversion_factor_mmol));
                time_offset += Constants.MINUTE_IN_MS;
            }
            return points;
        }
    }
    return null;
}
 
Example #11
Source File: LineChartRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private void drawPoint(Canvas canvas, Line line, PointValue pointValue, float rawX, float rawY,
                       float pointRadius) {
    if (ValueShape.SQUARE.equals(line.getShape())) {
        canvas.drawRect(rawX - pointRadius, rawY - pointRadius, rawX + pointRadius, rawY + pointRadius,
                pointPaint);
    } else if (ValueShape.CIRCLE.equals(line.getShape())) {
        canvas.drawCircle(rawX, rawY, pointRadius, pointPaint);
    } else if (ValueShape.DIAMOND.equals(line.getShape())) {
        canvas.save();
        canvas.rotate(45, rawX, rawY);
        canvas.drawRect(rawX - pointRadius, rawY - pointRadius, rawX + pointRadius, rawY + pointRadius,
                pointPaint);
        canvas.restore();
    } else {
        throw new IllegalArgumentException("Invalid point shape: " + line.getShape());
    }
}
 
Example #12
Source File: IOBCOBLineGraph.java    From HAPP with GNU General Public License v3.0 6 votes vote down vote up
public Line iobFutureLine() {
    List<PointValue> listValues = new ArrayList<>();
    for (int c = 0; c < iobFutureValues.length(); c++) {
        try {
            if (iobFutureValues.getJSONObject(c).getDouble("iob") > yIOBMax) {
                listValues.add(new PointValue((float) (iobFutureValues.getJSONObject(c).getDouble("as_of")), (float) fitIOB2COBRange(yIOBMax))); //Do not go above Max IOB
            } else if (iobFutureValues.getJSONObject(c).getDouble("iob") < yIOBMin) {
                listValues.add(new PointValue((float) (iobFutureValues.getJSONObject(c).getDouble("as_of")), (float) fitIOB2COBRange(yIOBMin))); //Do not go below Min IOB
            } else {
                listValues.add(new PointValue((float) (iobFutureValues.getJSONObject(c).getDouble("as_of")), (float) fitIOB2COBRange(iobFutureValues.getJSONObject(c).getDouble("iob"))));
            }
        } catch (JSONException e) {
            Crashlytics.logException(e);
            e.printStackTrace();
        }
    }
    Line cobValuesLine = new Line(listValues);
    cobValuesLine.setColor(ChartUtils.COLOR_BLUE);
    cobValuesLine.setHasLines(false);
    cobValuesLine.setHasPoints(true);
    cobValuesLine.setFilled(false);
    cobValuesLine.setCubic(false);
    cobValuesLine.setPointRadius(2);
    return cobValuesLine;
}
 
Example #13
Source File: LibreTrendGraph.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static List<PointValue> getTrendDataPointsOld(boolean doMgdl, long start_time, long end_time) {
   // TODO needs to cut off if would exceed the current graph scope
    final float conversion_factor_mmol = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL);
    final LibreBlock libreBlock= LibreBlock.getLatestForTrend(start_time, end_time );
    if (libreBlock != null) {
        final ArrayList<Float> bg_data = getLatestBg(libreBlock);
        if (bg_data != null) {
            final ArrayList<PointValue> points = new ArrayList<>(bg_data.size());
            long time_offset = 0;
            for (Float bg : bg_data) {
                points.add(new PointValue((float) ((libreBlock.timestamp - time_offset) / FUZZER), bg * conversion_factor_mmol));
                time_offset += Constants.MINUTE_IN_MS;
            }
            return points;
        }
    }
    return null;
}
 
Example #14
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private void addCalibrations() {
    try {
        for (BgWatchData calibration : calDataList) {
            if(calibration.timestamp > start_time) {
                final long adjusted_timestamp = ((long)(calibration.timestamp) + (estimatedInterstitialLagSeconds * 1000));
                //final long adjusted_timestamp = ((long)calibration.timestamp + (estimatedInterstitialLagSeconds * 1000));
                final PointValueExtended this_point = new PointValueExtended((float) (adjusted_timestamp / FUZZER), (float) unitized(calibration.sgv));
                this_point.real_timestamp = (long)calibration.timestamp;
                //calibrationValues.add(this_point);
                calibrationValues.add(new PointValue(fuzz(adjusted_timestamp), (float) unitized(calibration.sgv)));//KS calibration.timestamp
                if (d)
                    Log.d(TAG, "calibration total record: " + calibration.sgv + " " + " adjusted_timestamp: " + fuzz(calibration.timestamp) + " timestamp=" + JoH.dateTimeText((long) calibration.timestamp));
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "Exception doing calibration values in bggraphbuilder: " + e.toString());
    }
}
 
Example #15
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public synchronized void onValueSelected(int i, int i1, PointValue pointValue) {
	
	String filtered = "";
	try {
		PointValueExtended pve = (PointValueExtended) pointValue;
		if(pve.calculatedFilteredValue != -1) {
			filtered = " (" + Math.round(pve.calculatedFilteredValue*10) / 10d +")";
		}
	} catch (ClassCastException e) {
		Log.e(TAG, "Error casting a point from pointValue to PointValueExtended", e);
	}
    final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
    //Won't give the exact time of the reading but the time on the grid: close enough.
    Long time = ((long)pointValue.getX())*FUZZER;
    if(tooltip!= null){
        tooltip.cancel();
    }
    tooltip = Toast.makeText(context, timeFormat.format(time)+ ": " + Math.round(pointValue.getY()*10)/ 10d + filtered, Toast.LENGTH_LONG);
    tooltip.show();
}
 
Example #16
Source File: LineColumnDependencyActivity.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
private void generateLineData(int color, float range) {
    // Cancel last animation if not finished.
    chartTop.cancelDataAnimation();

    // Modify data targets
    Line line = lineData.getLines().get(0);// For this example there is always only one line.
    line.setColor(color);
    for (PointValue value : line.getValues()) {
        // Change target only for Y value.
        value.setTarget(value.getX(), (float) Math.random() * range);
    }

    // Start new data animation with 300ms duration;
    chartTop.startDataAnimation(300);
}
 
Example #17
Source File: NoteClassifier.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private static PointValue icon(@DrawableRes int id, @ColorInt int color, String note) {
    final PointValueExtended pv = new PointValueExtended();
    BitmapLoader.loadAndSetKey(pv, id, 0);
    pv.setBitmapTint(color);
    pv.setBitmapScale(1f);
    pv.note = note;
    return pv;
}
 
Example #18
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public Line predictiveLowLine() {
    List<PointValue> lowLineValues = new ArrayList<PointValue>();
    lowLineValues.add(new PointValue((float) end_time, (float) lowMark));
    lowLineValues.add(new PointValue((float) predictive_end_time, (float) lowMark));
    Line lowLine = new Line(lowLineValues);
    lowLine.setHasPoints(false);
    lowLine.setAreaTransparency(40);
    lowLine.setColor(ChartUtils.darkenColor(ChartUtils.darkenColor(ChartUtils.darkenColor(getCol(X.color_low_values)))));
    lowLine.setStrokeWidth(1);
    lowLine.setFilled(true);
    return lowLine;
}
 
Example #19
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private Line libreTrendLine() {
    final List<PointValue> libreTrendValues =  LibreTrendGraph.getTrendDataPoints(doMgdl, (long)(start_time * FUZZER), (long)(end_time * FUZZER));
    final Line line = new Line(libreTrendValues);
    line.setHasPoints(true);
    line.setHasLines(false);
    line.setCubic(false);
    line.setStrokeWidth(2);
    line.setPointRadius(1);
    line.setColor(Color.argb(240,25,206,244)); // temporary pending preference
    return line;
}
 
Example #20
Source File: IOBCOBLineGraph.java    From HAPP with GNU General Public License v3.0 5 votes vote down vote up
public void addIOBValues(){
    iobValues.clear();                                                                          //clears past data
    for (Stat iobReading : statsReadings) {
        if (iobReading.getIob() > yIOBMax) {
            iobValues.add(new PointValue((float) (iobReading.getTimestamp().getTime()), (float) fitIOB2COBRange(yIOBMax.floatValue()))); //Do not go above Max IOB
        } else if (iobReading.getIob() < yIOBMin) {
            iobValues.add(new PointValue((float) (iobReading.getTimestamp().getTime()), (float) fitIOB2COBRange(yIOBMin.floatValue()))); //Do not go below Min IOB
        } else {
            //iobValues.add(new SubcolumnValue((float) (iobReading.datetime / fuzz), (int)iobReading.value));
            iobValues.add(new PointValue((float) (iobReading.getTimestamp().getTime()), (float) fitIOB2COBRange(iobReading.getIob())));
        }
    }
}
 
Example #21
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public Line avg2Line() {
    List<PointValue> myLineValues = new ArrayList<PointValue>();
    myLineValues.add(new PointValue((float) start_time, (float) unitized(avg2value)));
    myLineValues.add(new PointValue((float) end_time, (float) unitized(avg2value)));
    Line myLine = new Line(myLineValues);
    myLine.setHasPoints(false);
    myLine.setStrokeWidth(1);
    myLine.setColor(getCol(X.color_average2_line));
    myLine.setPathEffect(new DashPathEffect(new float[]{30.0f, 10.0f}, 0));
    myLine.setAreaTransparency(50);
    return myLine;
}
 
Example #22
Source File: IOBCOBLineGraph.java    From HAPP with GNU General Public License v3.0 5 votes vote down vote up
public void addCOBValues(){
    cobValues.clear();                                                                          //clear past data
    for (Stat cobReading : statsReadings) {
        if (cobReading.getCob() > yCOBMax) {
            cobValues.add(new PointValue((float) (cobReading.getTimestamp().getTime()), (float) yCOBMax.floatValue())); //Do not go above Max COB
        } else if (cobReading.getCob() < yCOBMin) {
            cobValues.add(new PointValue((float) (cobReading.getTimestamp().getTime()), (float) yCOBMin.floatValue())); //Do not go below Min COB
        } else {
            cobValues.add(new PointValue((float) (cobReading.getTimestamp().getTime()), (float) cobReading.getCob()));
        }
    }
}
 
Example #23
Source File: LibreTrendGraph.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static List<PointValue> getTrendDataPoints(boolean doMgdl, long start_time, long end_time) {
   // TODO needs to cut off if would exceed the current graph scope
    final float conversion_factor_mmol = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL);
    ArrayList<Float> bg_data = getLatestBgForXMinutes((int) ((end_time - start_time) /  Constants.MINUTE_IN_MS)  );
    if (bg_data == null) {
        Log.e(TAG, "Error getting data from getLatestBgForXMinutes. Returning");
        return null;
        
    }
    
    LibreTrendLatest libreTrendLatest = LibreTrendUtil.getInstance().getLibreTrendLatest();
    if(libreTrendLatest.glucoseLevelRaw == 0) {
        Log.e(TAG, "libreBlock exists but libreTrendLatest.glucoseLevelRaw is zero ");
        return null;
    }
    

    
    final ArrayList<PointValue> points = new ArrayList<>(bg_data.size());
    long time_offset = 0;
    //int i = 0;
    for (Float bg : bg_data) {
        if(bg <= 0) {
            time_offset += Constants.MINUTE_IN_MS;
            continue;   
        }
        long bg_time = libreTrendLatest.timestamp - time_offset;
        if (bg_time <= end_time && bg_time >= start_time) {
            double time = (double) ((double)(bg_time) / FUZZER);
            points.add(new PointValue((float) ((double)(bg_time) / FUZZER), bg * conversion_factor_mmol));
        }
        
        time_offset += Constants.MINUTE_IN_MS;
    }
    return points;
  
}
 
Example #24
Source File: LineColumnDependencyActivity.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
/**
 * Generates initial data for line chart. At the begining all Y values are equals 0. That will change when user
 * will select value on column chart.
 */
private void generateInitialLineData() {
    int numValues = 7;

    List<AxisValue> axisValues = new ArrayList<AxisValue>();
    List<PointValue> values = new ArrayList<PointValue>();
    for (int i = 0; i < numValues; ++i) {
        values.add(new PointValue(i, 0));
        axisValues.add(new AxisValue(i).setLabel(days[i]));
    }

    Line line = new Line(values);
    line.setColor(ChartUtils.COLOR_GREEN).setCubic(true);

    List<Line> lines = new ArrayList<Line>();
    lines.add(line);

    lineData = new LineChartData(lines);
    lineData.setAxisXBottom(new Axis(axisValues).setHasLines(true));
    lineData.setAxisYLeft(new Axis().setHasLines(true).setMaxLabelChars(3));

    chartTop.setLineChartData(lineData);

    // For build-up animation you have to disable viewport recalculation.
    chartTop.setViewportCalculationEnabled(false);

    // And set initial max viewport and current viewport- remember to set viewports after data.
    Viewport v = new Viewport(0, 110, 6, 0);
    chartTop.setMaximumViewport(v);
    chartTop.setCurrentViewport(v);

    chartTop.setZoomType(ZoomType.HORIZONTAL);
}
 
Example #25
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void addBloodTests() {
    // enumerate blood tests
    try {
        for (BgWatchData bloodtest : btDataList) {
            if(bloodtest.timestamp > start_time) {
                final long adjusted_timestamp = (Math.round(bloodtest.timestamp) + (estimatedInterstitialLagSeconds * 1000));
                final PointValueExtended this_point = new PointValueExtended((float) (adjusted_timestamp / FUZZER), (float) unitized(bloodtest.sgv));
                this_point.type = PointValueExtended.BloodTest;
                //this_point.uuid = bloodtest.uuid; //TODO
                this_point.real_timestamp = (long)bloodtest.timestamp;
                // exclude any which have been used for calibration
                boolean matches = false;
                for (PointValue calibration_point : calibrationValues) {
                    if ((Math.abs(calibration_point.getX() - this_point.getX())) <= ((estimatedInterstitialLagSeconds * 1000) / FUZZER) && (calibration_point.getY() == calibration_point.getY())) {
                        matches = true;
                        break;
                    }
                }
                //if (!matches) bloodTestValues.add(this_point);
                if (!matches)
                    bloodTestValues.add(new PointValue(fuzz(adjusted_timestamp), (float) unitized(bloodtest.sgv)));//KS bloodtest.timestamp
                if (d)
                    Log.d(TAG, "bloodtest total record: " + bloodtest.sgv + " " + " adjusted_timestamp: " + fuzz(bloodtest.timestamp) + " timestamp=" + JoH.dateTimeText((long) bloodtest.timestamp));
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "Exception doing bloodtest values in bggraphbuilder: " + e.toString());
    }

}
 
Example #26
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private ArrayList<Line> autoSplitLine(Line macroline, final float jumpthresh) {
    ArrayList<Line> linearray = new ArrayList<>();
    float lastx = -999999;

    List<PointValue> macropoints = macroline.getValues();
    List<PointValue> thesepoints = new ArrayList<>();

    if (macropoints.size() > 0) {
        final float endmarker = macropoints.get(macropoints.size() - 1).getX();
        for (PointValue thispoint : macropoints) {

            // a jump too far for a line? make it a new one
            if (((lastx != -999999) && (Math.abs(thispoint.getX() - lastx) > jumpthresh))
                    || thispoint.getX() == endmarker) {

                if (thispoint.getX() == endmarker) {
                    thesepoints.add(thispoint);
                }
                Line line = (Line) cloneObject(macroline); // aieeee
                try {
                    line.setValues(thesepoints);
                    linearray.add(line);
                } catch (NullPointerException e) {
                //
                }
                    thesepoints = new ArrayList<PointValue>();
            }
            lastx = thispoint.getX();
            thesepoints.add(thispoint); // grow current line list
        }
    }
    return linearray;
}
 
Example #27
Source File: CheckableLineChartRenderer.java    From SoloPi with Apache License 2.0 5 votes vote down vote up
private void drawChecked(Canvas canvas) {
    if (checkedValue == null){
        return;
    }
    int lineIndex = checkedValue.getFirstIndex();
    Line line = dataProvider.getLineChartData().getLines().get(lineIndex);
    PointValue pointValue = line.getValues().get(checkedValue.getSecondIndex());
    int pointRadius = ChartUtils.dp2px(density, line.getPointRadius());
    float rawX = computator.computeRawX(pointValue.getX());
    float rawY = computator.computeRawY(pointValue.getY());
    canvas.drawCircle(rawX, rawY, pointRadius, checkedPaint);
}
 
Example #28
Source File: NoteClassifier.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private static PointValue icon(@DrawableRes int id, @ColorInt int color, String note) {
    final PointValueExtended pv = new PointValueExtended();
    BitmapLoader.loadAndSetKey(pv, id, 0);
    pv.setBitmapTint(color);
    pv.setBitmapScale(1f);
    pv.note = note;
    return pv;
}
 
Example #29
Source File: NoteClassifier.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static PointValue noteToPointValue(final String note) {

        final String haystack = note.toLowerCase();
        if (haystack.contains("battery low")) {
            return red(R.drawable.alert_icon, note);

        } else if (haystack.contains("stopped")) {
            return red(R.drawable.flag_variant, note);

        } else if (haystack.contains("paused")) {
            return amber(R.drawable.flag_variant, note);

        } else if (haystack.contains("started")) {
            return green(R.drawable.flag_variant, note);

        } else if (haystack.contains("cartridge low")) {
            return red(R.drawable.alert_icon, note);

        } else if (haystack.equals("connection timed out")) {
            return red(R.drawable.alert_icon, note);

        } else if (haystack.startsWith("warning")) {
            return amber(R.drawable.alert_icon, note);

        } else if (haystack.startsWith("maintenance")) {
            return grey(R.drawable.wrench_icon, note);
        }
        return grey(R.drawable.note_text_icon, note);
    }
 
Example #30
Source File: LineChartView.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
@Override
public void callTouchListener() {
    SelectedValue selectedValue = chartRenderer.getSelectedValue();

    if (selectedValue.isSet()) {
        PointValue point = data.getLines().get(selectedValue.getFirstIndex()).getValues()
                .get(selectedValue.getSecondIndex());
        onValueTouchListener.onValueSelected(selectedValue.getFirstIndex(), selectedValue.getSecondIndex(), point);
    } else {
        onValueTouchListener.onValueDeselected();
    }
}