|
|
@ -753,7 +753,21 @@ public class NutrientScoreCalculation {
|
|
|
|
totalAvg = Math.round(totalAvg/3);
|
|
|
|
totalAvg = Math.round(totalAvg/3);
|
|
|
|
return (long)totalAvg;
|
|
|
|
return (long)totalAvg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getLightEnerc(double x, double crtr) {
|
|
|
|
|
|
|
|
double from = crtr - crtr/100*15;
|
|
|
|
|
|
|
|
double to = crtr + crtr/100*15;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(x<from)
|
|
|
|
|
|
|
|
return Lights.yellow.name();
|
|
|
|
|
|
|
|
else if(from<=x && x<=to)
|
|
|
|
|
|
|
|
return Lights.green.name();
|
|
|
|
|
|
|
|
else if(x>to)
|
|
|
|
|
|
|
|
return Lights.red.name();
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String getLight(double x, double from, double to) {
|
|
|
|
private String getLight(double x, double from, double to) {
|
|
|
|
if(x<from)
|
|
|
|
if(x<from)
|
|
|
|
return Lights.yellow.name();
|
|
|
|
return Lights.yellow.name();
|
|
|
@ -797,7 +811,7 @@ public class NutrientScoreCalculation {
|
|
|
|
result.put("vitamine", null);
|
|
|
|
result.put("vitamine", null);
|
|
|
|
result.put("zn", null);
|
|
|
|
result.put("zn", null);
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
result.put("enerc", getLight(enerc, ARR_INTAKE_FROM[enerc_idx][label], ARR_INTAKE_TO[enerc_idx][label]));
|
|
|
|
result.put("enerc", getLightEnerc(enerc, ARR_INTAKE_FROM[enerc_idx][label]));
|
|
|
|
result.put("chotdf", getLight(chotdf, ARR_INTAKE_FROM[chotdf_idx][label], ARR_INTAKE_TO[chotdf_idx][label]));
|
|
|
|
result.put("chotdf", getLight(chotdf, ARR_INTAKE_FROM[chotdf_idx][label], ARR_INTAKE_TO[chotdf_idx][label]));
|
|
|
|
result.put("procnp", getLight(procnp, ARR_INTAKE_FROM[procnp_idx][label], ARR_INTAKE_TO[procnp_idx][label]));
|
|
|
|
result.put("procnp", getLight(procnp, ARR_INTAKE_FROM[procnp_idx][label], ARR_INTAKE_TO[procnp_idx][label]));
|
|
|
|
result.put("fat", getLight(fat, ARR_INTAKE_FROM[fat_idx][label], ARR_INTAKE_TO[fat_idx][label]));
|
|
|
|
result.put("fat", getLight(fat, ARR_INTAKE_FROM[fat_idx][label], ARR_INTAKE_TO[fat_idx][label]));
|
|
|
|