Search in sources :

Example 1 with IdentityTypeConverter

use of uk.ac.sussex.gdsc.core.data.utils.IdentityTypeConverter in project GDSC-SMLM by aherbert.

the class PeakResultConversionHelper method getConverters.

/**
 * Gets the converters for the peak results parameters. This includes the standard parameters and
 * any additional parameters defined in the PSF. If a parameter unit type is undefined then an
 * identity converter is created.
 *
 * @return the converters
 */
public Converter[] getConverters() {
    final LocalList<Converter> list = new LocalList<>(5);
    getIntensityConverter();
    getDistanceConverter();
    list.add(intensityConverter);
    list.add(intensityConverter);
    list.add(distanceConverter);
    list.add(distanceConverter);
    list.add(distanceConverter);
    if (psf != null) {
        try {
            for (final PSFParameter p : PsfHelper.getParameters(psf)) {
                switch(p.getUnit()) {
                    case DISTANCE:
                        list.add(distanceConverter);
                        break;
                    case INTENSITY:
                        list.add(intensityConverter);
                        break;
                    case ANGLE:
                        list.add(getAngleConverter());
                        break;
                    default:
                        list.add(new IdentityTypeConverter<>(p.getUnit()));
                }
            }
        } catch (final ConfigurationException ex) {
        // Ignore
        }
    }
    return list.toArray(new Converter[0]);
}
Also used : LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) ConfigurationException(uk.ac.sussex.gdsc.smlm.data.config.ConfigurationException) IdentityTypeConverter(uk.ac.sussex.gdsc.core.data.utils.IdentityTypeConverter) Converter(uk.ac.sussex.gdsc.core.data.utils.Converter) TypeConverter(uk.ac.sussex.gdsc.core.data.utils.TypeConverter) PSFParameter(uk.ac.sussex.gdsc.smlm.data.config.PSFProtos.PSFParameter)

Aggregations

Converter (uk.ac.sussex.gdsc.core.data.utils.Converter)1 IdentityTypeConverter (uk.ac.sussex.gdsc.core.data.utils.IdentityTypeConverter)1 TypeConverter (uk.ac.sussex.gdsc.core.data.utils.TypeConverter)1 LocalList (uk.ac.sussex.gdsc.core.utils.LocalList)1 ConfigurationException (uk.ac.sussex.gdsc.smlm.data.config.ConfigurationException)1 PSFParameter (uk.ac.sussex.gdsc.smlm.data.config.PSFProtos.PSFParameter)1