Changeset 7308
 Timestamp:
 12/01/10 20:16:13 (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/maven/projects/slimplugin/src/main/java/loci/slim/ui/UserInterfacePanel.java
r7195 r7308 60 60 import javax.swing.border.EmptyBorder; 61 61 62 import loci.slim. SLIMProcessor.FitAlgorithm;63 import loci.slim. SLIMProcessor.FitFunction;64 import loci.slim. SLIMProcessor.FitRegion;62 import loci.slim.ui.IUserInterfacePanel.FitAlgorithm; 63 import loci.slim.ui.IUserInterfacePanel.FitFunction; 64 import loci.slim.ui.IUserInterfacePanel.FitRegion; 65 65 import loci.slim.analysis.SLIMAnalysis; 66 import loci.slim.binning.SLIMBinning; 66 67 67 68 /** … … 133 134 JTextField m_stopField; 134 135 JTextField m_thresholdField; 136 JComboBox m_binningComboBox; 135 137 136 138 // parameter panel … … 195 197 JButton m_fitButton; 196 198 197 public UserInterfacePanel(boolean showTau, S LIMAnalysis analysis) {199 public UserInterfacePanel(boolean showTau, String[] analysisChoices, String[] binningChoices) { 198 200 String lifetimeLabel = "" + (showTau ? TAU : LAMBDA); 199 201 200 202 m_frame = new JFrame("SLIM Plugin"); 201 //m_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);202 203 203 204 // create outer panel … … 209 210 innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS)); 210 211 211 JPanel fitPanel = createFitPanel(analysis );212 JPanel fitPanel = createFitPanel(analysisChoices); 212 213 fitPanel.setBorder(border("Fit")); 213 214 innerPanel.add(fitPanel); 214 215 215 JPanel controlPanel = createControlPanel( );216 JPanel controlPanel = createControlPanel(binningChoices); 216 217 controlPanel.setBorder(border("Control")); 217 218 innerPanel.add(controlPanel); … … 300 301 } 301 302 302 private JPanel createFitPanel(S LIMAnalysis analysis) {303 private JPanel createFitPanel(String[] analysisChoices) { 303 304 JPanel fitPanel = new JPanel(); 304 305 fitPanel.setBorder(new EmptyBorder(0, 0, 8, 8)); … … 337 338 analysisLabel.setHorizontalAlignment(SwingConstants.RIGHT); 338 339 fitPanel.add(analysisLabel); 339 m_analysisComboBox = new JComboBox(analysis .getNames());340 m_analysisComboBox = new JComboBox(analysisChoices); 340 341 fitPanel.add(m_analysisComboBox); 341 342 … … 356 357 * Creates a panel that has some settings that control the fit. 357 358 */ 358 private JPanel createControlPanel( ) {359 private JPanel createControlPanel(String[] binningChoices) { 359 360 JPanel controlPanel = new JPanel(); 360 361 controlPanel.setBorder(new EmptyBorder(0, 0, 8, 8)); … … 391 392 controlPanel.add(m_thresholdField); 392 393 394 JLabel binningLabel = new JLabel("Bin"); 395 binningLabel.setHorizontalAlignment(SwingConstants.RIGHT); 396 controlPanel.add(binningLabel); 397 m_binningComboBox = new JComboBox(binningChoices); 398 controlPanel.add(m_binningComboBox); 399 393 400 // rows, cols, initX, initY, xPad, yPad 394 SpringUtilities.makeCompactGrid(controlPanel, 5, 2, 4, 4, 4, 4);401 SpringUtilities.makeCompactGrid(controlPanel, 6, 2, 4, 4, 4, 4); 395 402 396 403 JPanel panel = new JPanel(new BorderLayout()); … … 784 791 m_stopField.setEditable(enable); 785 792 m_thresholdField.setEditable(enable); 793 m_binningComboBox.setEnabled(enable); 786 794 787 795 // single exponent fit … … 942 950 } 943 951 952 public String getBinning() { 953 String selected = (String) m_binningComboBox.getSelectedItem(); 954 return selected; 955 } 956 944 957 public int getParameterCount() { 945 958 int count = 0; 946 959 String function = (String) m_functionComboBox.getSelectedItem(); 947 960 if (function.equals(SINGLE_EXPONENTIAL)) { 948 count = 3;961 count = 4; 949 962 } 950 963 else if (function.equals(DOUBLE_EXPONENTIAL)) { 964 count = 6; 965 } 966 else if (function.equals(TRIPLE_EXPONENTIAL)) { 967 count = 8; 968 } 969 else if (function.equals(STRETCHED_EXPONENTIAL)) { 951 970 count = 5; 952 }953 else if (function.equals(TRIPLE_EXPONENTIAL)) {954 count = 7;955 }956 else if (function.equals(STRETCHED_EXPONENTIAL)) {957 count = 4;958 971 } 959 972 return count; … … 968 981 String function = (String) m_functionComboBox.getSelectedItem(); 969 982 if (function.equals(SINGLE_EXPONENTIAL)) { 970 parameters = new double[ 3];971 parameters[ 0] = Double.valueOf(m_aParam1.getText());972 parameters[ 1] = Double.valueOf(m_tParam1.getText());973 parameters[ 2] = Double.valueOf(m_cParam1.getText());983 parameters = new double[4]; 984 parameters[2] = Double.valueOf(m_aParam1.getText()); 985 parameters[3] = Double.valueOf(m_tParam1.getText()); 986 parameters[1] = Double.valueOf(m_cParam1.getText()); 974 987 } 975 988 else if (function.equals(DOUBLE_EXPONENTIAL)) { 989 parameters = new double[6]; 990 parameters[2] = Double.valueOf(m_a1Param2.getText()); 991 parameters[3] = Double.valueOf(m_t1Param2.getText()); 992 parameters[4] = Double.valueOf(m_a2Param2.getText()); 993 parameters[5] = Double.valueOf(m_t2Param2.getText()); 994 parameters[1] = Double.valueOf(m_cParam2.getText()); 995 } 996 else if (function.equals(TRIPLE_EXPONENTIAL)) { 997 parameters = new double[8]; 998 parameters[2] = Double.valueOf(m_a1Param3.getText()); 999 parameters[3] = Double.valueOf(m_t1Param3.getText()); 1000 parameters[4] = Double.valueOf(m_a2Param3.getText()); 1001 parameters[5] = Double.valueOf(m_t2Param3.getText()); 1002 parameters[6] = Double.valueOf(m_a3Param3.getText()); 1003 parameters[7] = Double.valueOf(m_t3Param3.getText()); 1004 parameters[1] = Double.valueOf(m_cParam3.getText()); 1005 } 1006 else if (function.equals(STRETCHED_EXPONENTIAL)) { 976 1007 parameters = new double[5]; 977 parameters[0] = Double.valueOf(m_a1Param2.getText()); 978 parameters[1] = Double.valueOf(m_t1Param2.getText()); 979 parameters[2] = Double.valueOf(m_a2Param2.getText()); 980 parameters[3] = Double.valueOf(m_t2Param2.getText()); 981 parameters[4] = Double.valueOf(m_cParam2.getText()); 982 } 983 else if (function.equals(TRIPLE_EXPONENTIAL)) { 984 parameters = new double[7]; 985 parameters[0] = Double.valueOf(m_a1Param3.getText()); 986 parameters[1] = Double.valueOf(m_t1Param3.getText()); 987 parameters[2] = Double.valueOf(m_a2Param3.getText()); 988 parameters[3] = Double.valueOf(m_t2Param3.getText()); 989 parameters[4] = Double.valueOf(m_a3Param3.getText()); 990 parameters[5] = Double.valueOf(m_t3Param3.getText()); 991 parameters[6] = Double.valueOf(m_cParam3.getText()); 992 } 993 else if (function.equals(STRETCHED_EXPONENTIAL)) { 994 parameters = new double[4]; 995 parameters[0] = Double.valueOf(m_aParam4.getText()); 996 parameters[1] = Double.valueOf(m_tParam4.getText()); 997 parameters[2] = Double.valueOf(m_hParam4.getText()); 998 parameters[3] = Double.valueOf(m_cParam4.getText()); 999 } 1008 parameters[2] = Double.valueOf(m_aParam4.getText()); 1009 parameters[3] = Double.valueOf(m_tParam4.getText()); 1010 parameters[4] = Double.valueOf(m_hParam4.getText()); 1011 parameters[1] = Double.valueOf(m_cParam4.getText()); 1012 } 1013 parameters[0] = 0.0; 1000 1014 return parameters; 1001 1015 } … … 1004 1018 String function = (String) m_functionComboBox.getSelectedItem(); 1005 1019 if (function.equals(SINGLE_EXPONENTIAL)) { 1006 m_aParam1.setText("" + (float) params[0]); 1007 m_tParam1.setText("" + (float) params[1]); 1008 m_cParam1.setText( "" + (float) params[2]); 1020 m_aParam1.setText ("" + (float) params[2]); 1021 m_tParam1.setText ("" + (float) params[3]); 1022 m_cParam1.setText ("" + (float) params[1]); 1023 m_chiSqParam1.setText("" + (float) params[0]); 1009 1024 } 1010 1025 else if (function.equals(DOUBLE_EXPONENTIAL)) { 1011 m_a1Param2.setText("" + (float) params[0]); 1012 m_t1Param2.setText("" + (float) params[1]); 1013 m_a2Param2.setText("" + (float) params[2]); 1014 m_t2Param2.setText("" + (float) params[3]); 1015 m_cParam2.setText( "" + (float) params[4]); 1026 m_a1Param2.setText ("" + (float) params[2]); 1027 m_t1Param2.setText ("" + (float) params[3]); 1028 m_a2Param2.setText ("" + (float) params[4]); 1029 m_t2Param2.setText ("" + (float) params[5]); 1030 m_cParam2.setText ("" + (float) params[1]); 1031 m_chiSqParam2.setText("" + (float) params[0]); 1016 1032 } 1017 1033 else if (function.equals(TRIPLE_EXPONENTIAL)) { 1018 m_a1Param3.setText("" + (float) params[0]); 1019 m_t1Param3.setText("" + (float) params[1]); 1020 m_a2Param3.setText("" + (float) params[2]); 1021 m_t2Param3.setText("" + (float) params[3]); 1022 m_a3Param3.setText("" + (float) params[4]); 1023 m_t3Param3.setText("" + (float) params[5]); 1024 m_cParam3.setText( "" + (float) params[6]); 1025 } 1034 m_a1Param3.setText ("" + (float) params[2]); 1035 m_t1Param3.setText ("" + (float) params[3]); 1036 m_a2Param3.setText ("" + (float) params[4]); 1037 m_t2Param3.setText ("" + (float) params[5]); 1038 m_a3Param3.setText ("" + (float) params[6]); 1039 m_t3Param3.setText ("" + (float) params[7]); 1040 m_cParam3.setText ("" + (float) params[1]); 1041 m_chiSqParam3.setText("" + (float) params[0]); 1042 } 1026 1043 else if (function.equals(STRETCHED_EXPONENTIAL)) { 1027 m_aParam4.setText("" + (float) params[0]); 1028 m_tParam4.setText("" + (float) params[1]); 1029 m_hParam4.setText("" + (float) params[2]); 1030 m_cParam4.setText("" + (float) params[3]); 1044 m_aParam4.setText ("" + (float) params[2]); 1045 m_tParam4.setText ("" + (float) params[3]); 1046 m_hParam4.setText ("" + (float) params[4]); 1047 m_cParam4.setText ("" + (float) params[1]); 1048 m_chiSqParam4.setText("" + (float) params[0]); 1031 1049 } 1032 1050 } … … 1035 1053 switch (function) { 1036 1054 case 0: 1037 m_aParam1.setText("" + (float) params[0]); 1038 m_tParam1.setText("" + (float) params[1]); 1039 m_cParam1.setText( "" + (float) params[2]); 1055 m_aParam1.setText ("" + (float) params[2]); 1056 m_tParam1.setText ("" + (float) params[3]); 1057 m_cParam1.setText ("" + (float) params[1]); 1058 m_chiSqParam1.setText("" + (float) params[0]); 1040 1059 break; 1041 1060 case 1: 1042 m_a1Param2.setText("" + (float) params[0]); 1043 m_t1Param2.setText("" + (float) params[1]); 1044 m_a2Param2.setText("" + (float) params[2]); 1045 m_t2Param2.setText("" + (float) params[3]); 1046 m_cParam2.setText( "" + (float) params[4]); 1061 m_a1Param2.setText ("" + (float) params[2]); 1062 m_t1Param2.setText ("" + (float) params[3]); 1063 m_a2Param2.setText ("" + (float) params[4]); 1064 m_t2Param2.setText ("" + (float) params[5]); 1065 m_cParam2.setText ("" + (float) params[1]); 1066 m_chiSqParam2.setText("" + (float) params[0]); 1047 1067 break; 1048 1068 case 2: 1049 m_a1Param3.setText("" + (float) params[0]); 1050 m_t1Param3.setText("" + (float) params[1]); 1051 m_a2Param3.setText("" + (float) params[2]); 1052 m_t2Param3.setText("" + (float) params[3]); 1053 m_a3Param3.setText("" + (float) params[4]); 1054 m_t3Param3.setText("" + (float) params[5]); 1055 m_cParam3.setText( "" + (float) params[6]); 1069 m_a1Param3.setText ("" + (float) params[2]); 1070 m_t1Param3.setText ("" + (float) params[3]); 1071 m_a2Param3.setText ("" + (float) params[4]); 1072 m_t2Param3.setText ("" + (float) params[5]); 1073 m_a3Param3.setText ("" + (float) params[6]); 1074 m_t3Param3.setText ("" + (float) params[7]); 1075 m_cParam3.setText ("" + (float) params[1]); 1076 m_chiSqParam3.setText("" + (float) params[0]); 1056 1077 break; 1057 1078 case 3: 1058 m_aParam4.setText("" + (float) params[0]); 1059 m_tParam4.setText("" + (float) params[1]); 1060 m_hParam4.setText("" + (float) params[2]); 1061 m_cParam4.setText("" + (float) params[3]); 1079 m_aParam4.setText ("" + (float) params[0]); 1080 m_tParam4.setText ("" + (float) params[1]); 1081 m_hParam4.setText ("" + (float) params[2]); 1082 m_cParam4.setText ("" + (float) params[1]); 1083 m_chiSqParam4.setText("" + (float) params[0]); 1062 1084 break; 1063 1085 } … … 1100 1122 } 1101 1123 return free; 1102 }1103 1104 public void setChiSquare(double chiSquare) {1105 String function = (String) m_functionComboBox.getSelectedItem();1106 if (function.equals(SINGLE_EXPONENTIAL)) {1107 m_chiSqParam1.setText("" + (float) chiSquare);1108 }1109 else if (function.equals(DOUBLE_EXPONENTIAL)) {1110 m_chiSqParam2.setText("" + (float) chiSquare);1111 }1112 else if (function.equals(TRIPLE_EXPONENTIAL)) {1113 m_chiSqParam3.setText("" + (float) chiSquare);1114 }1115 else if (function.equals(STRETCHED_EXPONENTIAL)) {1116 m_chiSqParam4.setText("" + (float) chiSquare);1117 }1118 1124 } 1119 1125
Note: See TracChangeset
for help on using the changeset viewer.