ConverterSetup creation could support more cases
tischi opened this issue · 4 comments
I think the logic here could be more permissive:
public static ConverterSetup createConverterSetup(SourceAndConverter sac, int legacyId) {
//return BigDataViewer.createConverterSetup(sac, legacyId);
ConverterSetup setup;
if (sac.getSpimSource().getType() instanceof RealType) {
setup = createConverterSetupRealType(sac);
} else if (sac.getSpimSource().getType() instanceof ARGBType) {
setup = createConverterSetupARGBType(sac);
} else {
errlog.accept("Cannot create convertersetup for Source of type "+sac.getSpimSource().getType().getClass().getSimpleName());
setup = null;
}
//setup.setViewer(() -> requestRepaint.run());
return setup;
}
For example, the else
case could be replace with:
log.accept( "Unsupported ConverterSetup for Converters of class " + source.getConverter().getClass() );
if (source.asVolatile() != null) {
setup = new UnmodifiableConverterSetup( source.getConverter(), source.asVolatile().getConverter());
} else {
setup = new UnmodifiableConverterSetup( source.getConverter());
}
In addition, looking createConverterSetupRealType(..)
into there is:
static private ConverterSetup createConverterSetupRealType(SourceAndConverter source) {
final ConverterSetup setup;
if (source.getConverter() instanceof ColorConverter) {
setup = BigDataViewer.createConverterSetup(source, -1);
BigDataViewer.createConverterSetup(source,
does not require the source to be of any specific type; thus the case source.getConverter() instanceof ColorConverter)
could be handled independent of the type of the source itself.
In fact the return converter will not necessarily be of RealType
.
Would it be OK if I created a PR to potentially improve this?
Sure, make a PR.
The lines of code for reference:
Also there was an interface (ICloneableConverter) which was made to handle particular converters in case that's useful:
And why not taking BigDataViewer.createConverterSetup(source
directly ?
I think BigDataViewer.createConverterSetup()
only works for ColorConverter
...
PR merged. Closing this issue