Java Code Examples for com.eveningoutpost.dexdrip.Models.Calibration#allForSensor()
The following examples show how to use
com.eveningoutpost.dexdrip.Models.Calibration#allForSensor() .
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: CalibrationGraph.java From xDrip with GNU General Public License v3.0 | 4 votes |
public void setupCharts() { chart = (LineChartView) findViewById(R.id.chart); List<Line> lines = new ArrayList<Line>(); //calibration values List<Calibration> calibrations = Calibration.allForSensor(); List<Line> greyLines = getCalibrationsLine(calibrations, Color.parseColor("#66FFFFFF")); calibrations = Calibration.allForSensorInLastFourDays(); List<Line> blueLines = getCalibrationsLine(calibrations, ChartUtils.COLOR_BLUE); Calibration calibration = Calibration.lastValid(); if (calibration != null) { //set header DecimalFormat df = new DecimalFormat("#"); df.setMaximumFractionDigits(2); df.setMinimumFractionDigits(2); String Header = "slope = " + df.format(calibration.slope) + " intercept = " + df.format(calibration.intercept); GraphHeader.setText(Header); //red line List<PointValue> lineValues = new ArrayList<PointValue>(); final float conversion_factor = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL); lineValues.add(new PointValue((float) start_x, (conversion_factor * (float) (start_x * calibration.slope + calibration.intercept)))); lineValues.add(new PointValue((float) end_x, (conversion_factor * (float) (end_x * calibration.slope + calibration.intercept)))); Line calibrationLine = new Line(lineValues); calibrationLine.setColor(ChartUtils.COLOR_RED); calibrationLine.setHasLines(true); calibrationLine.setHasPoints(false); lines.add(calibrationLine); // calibration plugin final CalibrationAbstract plugin = getCalibrationPluginFromPreferences(); if (plugin != null) { final CalibrationAbstract.CalibrationData pcalibration = plugin.getCalibrationData(); final List<PointValue> plineValues = new ArrayList<PointValue>(); plineValues.add(new PointValue((float) start_x, (conversion_factor * (float) (plugin.getGlucoseFromSensorValue(start_x, pcalibration))))); plineValues.add(new PointValue((float) end_x, (conversion_factor * (float) (plugin.getGlucoseFromSensorValue(end_x, pcalibration))))); final Line pcalibrationLine = new Line(plineValues); pcalibrationLine.setColor(Color.parseColor(plugin_color)); pcalibrationLine.setHasLines(true); pcalibrationLine.setHasPoints(false); lines.add(pcalibrationLine); PluginHeader.setText("(" + plugin.getAlgorithmName() + ") " + "s = " + df.format(pcalibration.slope) + " i = " + df.format(pcalibration.intercept)); PluginHeader.setTextColor(Color.parseColor(plugin_color)); } //add lines in order for (Line greyLine : greyLines) { lines.add(greyLine); } for (Line blueLine : blueLines) { lines.add(blueLine); } } Axis axisX = new Axis(); Axis axisY = new Axis().setHasLines(true); axisX.setName("Raw Value"); axisY.setName("Glucose " + (doMgdl ? "mg/dl" : "mmol/l")); data = new LineChartData(lines); data.setAxisXBottom(axisX); data.setAxisYLeft(axisY); chart.setLineChartData(data); }
Example 2
Source File: CalibrationGraph.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public void setupCharts() { chart = (LineChartView) findViewById(R.id.chart); List<Line> lines = new ArrayList<Line>(); //calibration values List<Calibration> calibrations = Calibration.allForSensor(); List<Line> greyLines = getCalibrationsLine(calibrations, Color.parseColor("#66FFFFFF")); calibrations = Calibration.allForSensorInLastFourDays(); List<Line> blueLines = getCalibrationsLine(calibrations, ChartUtils.COLOR_BLUE); Calibration calibration = Calibration.lastValid(); if (calibration != null) { //set header DecimalFormat df = new DecimalFormat("#"); df.setMaximumFractionDigits(2); df.setMinimumFractionDigits(2); String Header = "slope = " + df.format(calibration.slope) + " intercept = " + df.format(calibration.intercept); GraphHeader.setText(Header); //red line List<PointValue> lineValues = new ArrayList<PointValue>(); final float conversion_factor = (float) (doMgdl ? 1 : Constants.MGDL_TO_MMOLL); lineValues.add(new PointValue((float) start_x, (conversion_factor * (float) (start_x * calibration.slope + calibration.intercept)))); lineValues.add(new PointValue((float) end_x, (conversion_factor * (float) (end_x * calibration.slope + calibration.intercept)))); Line calibrationLine = new Line(lineValues); calibrationLine.setColor(ChartUtils.COLOR_RED); calibrationLine.setHasLines(true); calibrationLine.setHasPoints(false); lines.add(calibrationLine); // calibration plugin final CalibrationAbstract plugin = getCalibrationPluginFromPreferences(); if (plugin != null) { final CalibrationAbstract.CalibrationData pcalibration = plugin.getCalibrationData(); final List<PointValue> plineValues = new ArrayList<PointValue>(); plineValues.add(new PointValue((float) start_x, (conversion_factor * (float) (plugin.getGlucoseFromSensorValue(start_x, pcalibration))))); plineValues.add(new PointValue((float) end_x, (conversion_factor * (float) (plugin.getGlucoseFromSensorValue(end_x, pcalibration))))); final Line pcalibrationLine = new Line(plineValues); pcalibrationLine.setColor(Color.parseColor(plugin_color)); pcalibrationLine.setHasLines(true); pcalibrationLine.setHasPoints(false); lines.add(pcalibrationLine); PluginHeader.setText("(" + plugin.getAlgorithmName() + ") " + "s = " + df.format(pcalibration.slope) + " i = " + df.format(pcalibration.intercept)); PluginHeader.setTextColor(Color.parseColor(plugin_color)); } //add lines in order for (Line greyLine : greyLines) { lines.add(greyLine); } for (Line blueLine : blueLines) { lines.add(blueLine); } } Axis axisX = new Axis(); Axis axisY = new Axis().setHasLines(true); axisX.setName("Raw Value"); axisY.setName("Glucose " + (doMgdl ? "mg/dl" : "mmol/l")); data = new LineChartData(lines); data.setAxisXBottom(axisX); data.setAxisYLeft(axisY); chart.setLineChartData(data); }
Example 3
Source File: CalibrationGraph.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
public void setupCharts() { chart = (LineChartView) findViewById(R.id.chart); List<Line> lines = new ArrayList<Line>(); Calibration calibration = Calibration.last(); if(calibration != null) { //set header DecimalFormat df = new DecimalFormat("#"); df.setMaximumFractionDigits(2); df.setMinimumFractionDigits(2); String Header = "slope = " + df.format(calibration.slope) + " intercept = " + df.format(calibration.intercept); GraphHeader.setText(Header); //red line List<PointValue> lineValues = new ArrayList<PointValue>(); lineValues.add(new PointValue((float) start_x, (float) (start_x * calibration.slope + calibration.intercept))); lineValues.add(new PointValue((float) end_x, (float) (end_x * calibration.slope + calibration.intercept))); Line calibrationLine = new Line(lineValues); calibrationLine.setColor(ChartUtils.COLOR_RED); calibrationLine.setHasLines(true); calibrationLine.setHasPoints(false); //calibration values List<Calibration> calibrations = Calibration.allForSensor(); Line greyLine = getCalibrationsLine(calibrations, Color.parseColor("#66FFFFFF")); calibrations = Calibration.allForSensorInLastFourDays(); Line blueLine = getCalibrationsLine(calibrations, ChartUtils.COLOR_BLUE); //add lines in order lines.add(greyLine); lines.add(blueLine); lines.add(calibrationLine); } Axis axisX = new Axis(); Axis axisY = new Axis().setHasLines(true); axisX.setName("Raw Value"); axisY.setName("BG"); data = new LineChartData(lines); data.setAxisXBottom(axisX); data.setAxisYLeft(axisY); chart.setLineChartData(data); }