Closed thanneken closed 6 years ago
Yes, I had noticed the default choices were being weird. I used the same math from the Macro for how to pick defaults, but it does not appear to be working right. I will have to look at that. I should be ale to replicate the desired functionality described above. The current code making the selections is
for (int i=0; i<listOfNarrowbandCaptures.length; i++) {
.
.
.
if ((i+1)/listOfNarrowbandCaptures.length < 0.34){
defaultRange = "B";
radioOptionB.setSelected(true);
}
else if ((i+1)/listOfNarrowbandCaptures.length > 0.67){
defaultRange = "R";
radioOptionR.setSelected(true);
}
else {
defaultRange = "G";
radioOptionG.setSelected(true);
}
.
.
.
}
It was derived from the Macro's
for (i=0; i<listOfNarrowbandCaptures.length; i++) {
if ((i+1)/listOfNarrowbandCaptures.length < 0.34) defaultRange = "B";
else if ((i+1)/listOfNarrowbandCaptures.length > 0.67) defaultRange = "R";
else defaultRange = "G";
Dialog.setInsets(0,0,0);
Dialog.addRadioButtonGroup(listOfNarrowbandCaptures[i], rgbnOptions, 1, 4, defaultRange);
}
Most likely radioOptionB
, radioOptionR
and radioOptionG
are not what I think they are. I will review this.
Doing math with integers means these always come out 0 or 1. Need to Double type the math then check against the right type.
double defaultFraction = 0.00;
defaultFraction = (i+1)/listOfNarrowbandCaptures.length;
if (defaultFraction < 0.34){
defaultRange = "B";
radioOptionB.setSelected(true);
}
else if (defaultFraction > 0.67){
defaultRange = "R";
radioOptionR.setSelected(true);
}
else {
defaultRange = "G";
radioOptionG.setSelected(true);
}
Ugh still Type angry. Force everything to be a float.
float defaultFraction;
float ind = (float) (i+1.0);
float len = (float) listOfNarrowbandCaptures.length;
defaultFraction = ind/len;
if (defaultFraction < 0.34){
defaultRange = "B";
radioOptionB.setSelected(true);
}
else if (defaultFraction > 0.67){
defaultRange = "R";
radioOptionR.setSelected(true);
}
else {
defaultRange = "G";
radioOptionG.setSelected(true);
}
That seems to have fixed it.
In my test it defaulted the last file to R and all the others to B. Since it is conventional to capture in a sequence of short to long wavelengths, it is helpful to default the first third of the files in "narrowband captures" to blue, the middle third to green, and final third to red. The user should be able to override this default, but it is a good start.
This might avoid the other issue of there not being at least one each of R, G, and B. It can warn and fail if there is not at least one of each, and isn't really useful until there are at least two in one of the channels.