Fixed json generation of multi-colortransform

Former-commit-id: ecd587d1e623e34b8841d634b2217ef350e25210
This commit is contained in:
T. van der Zwan 2013-11-25 12:26:20 +01:00
parent 336647b95b
commit 602afa14f6
2 changed files with 37 additions and 31 deletions

View File

@ -50,10 +50,16 @@ public class ColorConfig {
strBuf.append("\t\t\"transform\" :\n");
strBuf.append("\t\t[\n");
for (TransformConfig transform : mTransforms) {
for (int i=0; i<mTransforms.size(); ++i) {
TransformConfig transform = mTransforms.get(i);
strBuf.append(transform.toJsonString());
if (i == mTransforms.size()-1) {
strBuf.append("\n");
} else {
strBuf.append(",\n");
}
}
strBuf.append("\t\t]\n");
strBuf.append("\t\t],\n");
strBuf.append(smoothingToString() + "\n");
strBuf.append("\t}");

View File

@ -41,10 +41,10 @@ public class TransformConfig {
public String toJsonString() {
StringBuffer strBuf = new StringBuffer();
strBuf.append("\t\t{\n");
strBuf.append("\t\t\t{\n");
strBuf.append(hsvToJsonString() + ",\n");
strBuf.append(rgbToJsonString() + ",\n");
strBuf.append("\t\t}");
strBuf.append(rgbToJsonString() + "\n");
strBuf.append("\t\t\t}");
return strBuf.toString();
}
@ -55,12 +55,12 @@ public class TransformConfig {
*/
private String hsvToJsonString() {
StringBuffer strBuf = new StringBuffer();
strBuf.append("\t\t\t\"hsv\" :\n");
strBuf.append("\t\t\t{\n");
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"saturationGain\" : %.4f,\n", mSaturationGain));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"valueGain\" : %.4f\n", mValueGain));
strBuf.append("\t\t\t\t\"hsv\" :\n");
strBuf.append("\t\t\t\t{\n");
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"saturationGain\" : %.4f,\n", mSaturationGain));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"valueGain\" : %.4f\n", mValueGain));
strBuf.append("\t\t\t}");
strBuf.append("\t\t\t\t}");
return strBuf.toString();
}
@ -72,29 +72,29 @@ public class TransformConfig {
private String rgbToJsonString() {
StringBuffer strBuf = new StringBuffer();
strBuf.append("\t\t\t\"red\" :\n");
strBuf.append("\t\t\t{\n");
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"threshold\" : %.4f,\n", mRedThreshold));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"gamma\" : %.4f,\n", mRedGamma));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"blacklevel\" : %.4f,\n", mRedBlacklevel));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"whitelevel\" : %.4f\n", mRedWhitelevel));
strBuf.append("\t\t},\n");
strBuf.append("\t\t\t\t\"red\" :\n");
strBuf.append("\t\t\t\t{\n");
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"threshold\" : %.4f,\n", mRedThreshold));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"gamma\" : %.4f,\n", mRedGamma));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"blacklevel\" : %.4f,\n", mRedBlacklevel));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"whitelevel\" : %.4f\n", mRedWhitelevel));
strBuf.append("\t\t\t\t},\n");
strBuf.append("\t\t\t\"green\" :\n");
strBuf.append("\t\t\t{\n");
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"threshold\" : %.4f,\n", mGreenThreshold));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"gamma\" : %.4f,\n", mGreenGamma));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"blacklevel\" : %.4f,\n", mGreenBlacklevel));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"whitelevel\" : %.4f\n", mGreenWhitelevel));
strBuf.append("\t\t\t},\n");
strBuf.append("\t\t\t\t\"green\" :\n");
strBuf.append("\t\t\t\t{\n");
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"threshold\" : %.4f,\n", mGreenThreshold));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"gamma\" : %.4f,\n", mGreenGamma));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"blacklevel\" : %.4f,\n", mGreenBlacklevel));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"whitelevel\" : %.4f\n", mGreenWhitelevel));
strBuf.append("\t\t\t\t},\n");
strBuf.append("\t\t\t\"blue\" :\n");
strBuf.append("\t\t\t{\n");
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"threshold\" : %.4f,\n", mBlueThreshold));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"gamma\" : %.4f,\n", mBlueGamma));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"blacklevel\" : %.4f,\n", mBlueBlacklevel));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\"whitelevel\" : %.4f\n", mBlueWhitelevel));
strBuf.append("\t\t\t}");
strBuf.append("\t\t\t\t\"blue\" :\n");
strBuf.append("\t\t\t\t{\n");
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"threshold\" : %.4f,\n", mBlueThreshold));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"gamma\" : %.4f,\n", mBlueGamma));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"blacklevel\" : %.4f,\n", mBlueBlacklevel));
strBuf.append(String.format(Locale.ROOT, "\t\t\t\t\t\"whitelevel\" : %.4f\n", mBlueWhitelevel));
strBuf.append("\t\t\t\t}");
return strBuf.toString();
}