Scale -> kt

This commit is contained in:
Milos Kozak 2021-05-26 14:17:49 +02:00
parent 309ce50518
commit 6e19d60796
3 changed files with 19 additions and 41 deletions

View file

@ -76,7 +76,7 @@ class GraphData(
addSeries(overviewData.tempBasalGraphSeries)
addSeries(overviewData.basalLineGraphSeries)
addSeries(overviewData.absoluteBasalGraphSeries)
overviewData.basalScale.setMultiplier(maxY * scale / overviewData.maxBasalValueFound)
overviewData.basalScale.multiplier = maxY * scale / overviewData.maxBasalValueFound
}
fun addTargetLine() {
@ -91,7 +91,7 @@ class GraphData(
fun addActivity(scale: Double) {
addSeries(overviewData.activitySeries)
addSeries(overviewData.activityPredictionSeries)
overviewData.actScale.setMultiplier(maxY * scale / overviewData.maxIAValue)
overviewData.actScale.multiplier = maxY * scale / overviewData.maxIAValue
}
//Function below show -BGI to be able to compare curves with deviations
@ -100,7 +100,7 @@ class GraphData(
maxY = overviewData.maxBGIValue
minY = -overviewData.maxBGIValue
}
overviewData.bgiScale.setMultiplier(maxY * scale / overviewData.maxBGIValue)
overviewData.bgiScale.multiplier = maxY * scale / overviewData.maxBGIValue
addSeries(overviewData.minusBgiSeries)
addSeries(overviewData.minusBgiHistSeries)
}
@ -111,7 +111,7 @@ class GraphData(
maxY = overviewData.maxIobValueFound
minY = -overviewData.maxIobValueFound
}
overviewData.iobScale.setMultiplier(maxY * scale / overviewData.maxIobValueFound)
overviewData.iobScale.multiplier = maxY * scale / overviewData.maxIobValueFound
addSeries(overviewData.iobSeries)
addSeries(overviewData.iobPredictions1Series)
addSeries(overviewData.iobPredictions2Series)
@ -123,7 +123,7 @@ class GraphData(
maxY = overviewData.maxIobValueFound
minY = -overviewData.maxIobValueFound
}
overviewData.iobScale.setMultiplier(maxY * scale / overviewData.maxIobValueFound)
overviewData.iobScale.multiplier = maxY * scale / overviewData.maxIobValueFound
addSeries(overviewData.absIobSeries)
}
@ -133,7 +133,7 @@ class GraphData(
maxY = overviewData.maxCobValueFound
minY = 0.0
}
overviewData.cobScale.setMultiplier(maxY * scale / overviewData.maxCobValueFound)
overviewData.cobScale.multiplier = maxY * scale / overviewData.maxCobValueFound
addSeries(overviewData.cobSeries)
addSeries(overviewData.cobMinFailOverSeries)
}
@ -144,7 +144,7 @@ class GraphData(
maxY = overviewData.maxDevValueFound
minY = -maxY
}
overviewData.devScale.setMultiplier(maxY * scale / overviewData.maxDevValueFound)
overviewData.devScale.multiplier = maxY * scale / overviewData.maxDevValueFound
addSeries(overviewData.deviationsSeries)
}
@ -153,9 +153,9 @@ class GraphData(
if (useForScale) {
maxY = 100.0 + max(overviewData.maxRatioValueFound, abs(overviewData.minRatioValueFound))
minY = 100.0 - max(overviewData.maxRatioValueFound, abs(overviewData.minRatioValueFound))
overviewData.ratioScale.setMultiplier(1.0)
overviewData.ratioScale.multiplier = 1.0
} else
overviewData.ratioScale.setMultiplier(maxY * scale / max(overviewData.maxRatioValueFound, abs(overviewData.minRatioValueFound)))
overviewData.ratioScale.multiplier = maxY * scale / max(overviewData.maxRatioValueFound, abs(overviewData.minRatioValueFound))
addSeries(overviewData.ratioSeries)
}
@ -165,8 +165,8 @@ class GraphData(
maxY = max(overviewData.maxFromMaxValueFound, overviewData.maxFromMinValueFound)
minY = -maxY
}
overviewData.dsMaxScale.setMultiplier(maxY * scale / overviewData.maxFromMaxValueFound)
overviewData.dsMinScale.setMultiplier(maxY * scale / overviewData.maxFromMinValueFound)
overviewData.dsMaxScale.multiplier = maxY * scale / overviewData.maxFromMaxValueFound
overviewData.dsMinScale.multiplier = maxY * scale / overviewData.maxFromMinValueFound
addSeries(overviewData.dsMaxSeries)
addSeries(overviewData.dsMinSeries)
}

View file

@ -1,30 +0,0 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions;
/**
* Created by mike on 18.10.2017.
*/
public class Scale {
private double multiplier;
private final double shift;
public Scale() {
shift = 0;
}
public Scale(double shift) {
this.shift = shift;
}
public void setMultiplier(double value) {
this.multiplier = value;
}
public double transform(double original) {
return original * multiplier + shift;
}
public double getShift() {
return shift;
}
}

View file

@ -0,0 +1,8 @@
package info.nightscout.androidaps.plugins.general.overview.graphExtensions
class Scale(var shift: Double = 0.0, var multiplier: Double = 0.0) {
fun transform(original: Double): Double {
return original * multiplier + shift
}
}