Ignore:
Timestamp:
11/22/10 13:09:36 (9 years ago)
Author:
aivar
Message:

Added dialog to choose what to display, was hard-coded.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/maven/projects/slim-plugin/src/main/java/loci/slim/analysis/plugins/Display.java

    r7217 r7232  
    3636 
    3737import ij.ImagePlus; 
     38import ij.gui.GenericDialog; 
    3839import ij.gui.MessageDialog; 
    3940import ij.process.ColorProcessor; 
     
    4344import java.math.MathContext; 
    4445import java.math.RoundingMode; 
     46 
     47import java.util.HashMap; 
     48import java.util.Map; 
    4549 
    4650import loci.slim.SLIMProcessor.FitFunction; 
     
    6367@SLIMAnalyzer(name="Display Fit Results") 
    6468public class Display implements ISLIMAnalyzer { 
    65     private static final Character TAU = 'T'; //TODO IJ doesn't handle Unicode, was: = '\u03c4'; 
     69    private static final Character TAU = 'T'; //TODO IJ1 doesn't display Unicode, was: = '\u03c4'; 
    6670    private static final String T = "" + TAU; 
    6771    private static final String T1 = "" + TAU + '1'; 
     
    101105     * This table is very specifically tied to the order of parameter indices. 
    102106     */ 
     107    //TODO need Ta, Ti, Tm 
    103108    private static enum Formula { 
    104109        T_FORMULA(T, 2), 
     
    185190     */ 
    186191    public void analyze(Image<DoubleType> image, FitRegion region, FitFunction function) { 
    187         boolean combineMinMax = false; //TODO needs to be set from UI. 
     192        // Used to build optional lists of formulas 
     193        Map<String, Formula[]> formulasMap = null; 
     194        boolean combineMinMax = false; 
    188195 
    189196        // is this plugin appropriate for current data? 
     
    209216        int params   = dimensions[pIndex]; 
    210217 
    211         // get appropriate formula for image dimensions 
     218        // allow user to select formula to display 
    212219        Formula formulas[] = null; 
    213         switch (function) { 
    214             case SINGLE_EXPONENTIAL: 
    215                 formulas = new Formula[] { Formula.A_FORMULA, Formula.T_FORMULA, Formula.C_FORMULA }; //TODO these three formulas are just for testing. 
    216                 break; 
    217             case DOUBLE_EXPONENTIAL: 
    218                 formulas = new Formula[] { Formula.A1_A2_FORMULA, Formula.T1_T2_FORMULA }; 
    219                 break; 
    220             case TRIPLE_EXPONENTIAL: 
    221                 formulas = new Formula[] { Formula.T1_T2_FORMULA, Formula.T1_T3_FORMULA }; 
    222                 break; 
    223             case STRETCHED_EXPONENTIAL: 
    224                 break; 
     220        if (null == formulasMap) { 
     221            formulasMap = initFormulasMap(function); 
     222        } 
     223        GenericDialog dialog = new GenericDialog("Display Formula"); 
     224        String choices[] = formulasMap.keySet().toArray(new String[0]); 
     225        dialog.addChoice("Show", choices, choices[0]); 
     226        if (channels > 1) { 
     227            dialog.addCheckbox("Use common range for all channels", true); 
     228        } 
     229        dialog.showDialog(); 
     230        formulas = formulasMap.get(dialog.getNextChoice()); 
     231        if (channels > 1) { 
     232            combineMinMax = dialog.getNextBoolean(); 
    225233        } 
    226234 
     
    344352    } 
    345353 
     354    /** 
     355     * Builds lists of formulas and associated descriptions that are appropriate 
     356     * to a given fit function. 
     357     * 
     358     * @param function 
     359     * @return 
     360     */ 
     361    private Map<String, Formula[]> initFormulasMap(FitFunction function) { 
     362        Map<String, Formula[]> map = new HashMap<String, Formula[]>(); 
     363        switch (function) { 
     364            case SINGLE_EXPONENTIAL: 
     365                map.put("T", new Formula[] { Formula.T_FORMULA }); 
     366                map.put("A T", new Formula[] { Formula.A_FORMULA, Formula.T_FORMULA }); 
     367                map.put("A T C", new Formula[] { Formula.A_FORMULA, Formula.T_FORMULA, Formula.C_FORMULA }); 
     368                break; 
     369            case DOUBLE_EXPONENTIAL: 
     370                map.put("T1/T2", new Formula[] { Formula.T1_T2_FORMULA }); 
     371                map.put("A1/A2 T1/T2", new Formula[] { Formula.A1_A2_FORMULA, Formula.T1_T2_FORMULA }); 
     372                map.put("T1 T2", new Formula[] { Formula.T1_FORMULA, Formula.T2_FORMULA }); 
     373                map.put("A1 A2 T1 T2", new Formula[] { Formula.A1_FORMULA, Formula.A2_FORMULA, Formula.T1_FORMULA, Formula.T2_FORMULA }); 
     374                map.put("A1 A2 T1 T2 C", new Formula[] { Formula.A1_FORMULA, Formula.A2_FORMULA, Formula.T1_FORMULA, Formula.T2_FORMULA, Formula.C_FORMULA }); 
     375                break; 
     376            case TRIPLE_EXPONENTIAL: 
     377                map.put("T1/T2 T1/T3", new Formula[] { Formula.T1_T2_FORMULA, Formula.T1_T3_FORMULA }); 
     378                map.put("A1/A2 A1/A3 T1/T2 T1/T3", new Formula[] { Formula.A1_A2_FORMULA, Formula.A1_A3_FORMULA, Formula.T1_T2_FORMULA, Formula.T1_T3_FORMULA }); 
     379                map.put("T1 T2 T3", new Formula[] { Formula.T1_FORMULA, Formula.T2_FORMULA, Formula.T3_FORMULA }); 
     380                map.put("A1 A2 A3 T1 T2 T3", new Formula[] { Formula.A1_FORMULA, Formula.A2_FORMULA, Formula.A3_FORMULA, Formula.T1_FORMULA, Formula.T2_FORMULA, Formula.T3_FORMULA }); 
     381                map.put("A1 A2 A3 T1 T2 T3 C", new Formula[] { Formula.A1_FORMULA, Formula.A2_FORMULA, Formula.A3_FORMULA, Formula.T1_FORMULA, Formula.T2_FORMULA, Formula.T3_FORMULA, Formula.C_FORMULA }); 
     382                break; 
     383            case STRETCHED_EXPONENTIAL: 
     384                break; 
     385        } 
     386        return map; 
     387    } 
     388 
     389    /** 
     390     * Initializes minimum and maximum value arrays. 
     391     * 
     392     * @param minValue 
     393     * @param maxValue 
     394     */ 
    346395    private void initMinMax(double minValue[], double maxValue[]) { 
    347396        for (int i = 0; i < minValue.length; ++i) { 
Note: See TracChangeset for help on using the changeset viewer.