Changeset 7654
 Timestamp:
 03/15/11 20:17:02 (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/projects/slimplugin/src/main/java/loci/slim/ui/UserInterfacePanel.java
r7308 r7654 60 60 import javax.swing.border.EmptyBorder; 61 61 62 import ij.gui.GenericDialog; 63 64 import loci.slim.Excitation; 65 import loci.slim.ExcitationFileHandler; 62 66 import loci.slim.ui.IUserInterfacePanel.FitAlgorithm; 63 67 import loci.slim.ui.IUserInterfacePanel.FitFunction; … … 97 101 private static final String SLIM_CURVE_RLD_ALGORITHM = "SLIMCurve RLD"; 98 102 private static final String SLIM_CURVE_LMA_ALGORITHM = "SLIMCurve LMA"; 103 private static final String SLIM_CURVE_RLD_LMA_ALGORITHM = "SLIMCurve RLD+LMA"; 99 104 100 105 private static final String SINGLE_EXPONENTIAL = "Single Exponential"; … … 102 107 private static final String TRIPLE_EXPONENTIAL = "Triple Exponential"; 103 108 private static final String STRETCHED_EXPONENTIAL = "Stretched Exponential"; 109 110 private static final String EXCITATION_NONE = "None"; 111 private static final String EXCITATION_FILE = "File"; 112 private static final String EXCITATION_CREATE = "Use current X Y"; 104 113 105 114 private static final String DO_FIT = "Do Fit"; … … 110 119 111 120 private static final String REGION_ITEMS[] = { SUM_REGION, ROIS_REGION, PIXEL_REGION, ALL_REGION }; 112 private static final String ALGORITHM_ITEMS[] = { JAOLHO_LMA_ALGORITHM, GRAY_RLD_ALGORITHM, GRAY_LMA_ALGORITHM, SLIM_CURVE_RLD_ALGORITHM, SLIM_CURVE_LMA_ALGORITHM };121 private static final String ALGORITHM_ITEMS[] = { JAOLHO_LMA_ALGORITHM, GRAY_RLD_ALGORITHM, GRAY_LMA_ALGORITHM, SLIM_CURVE_RLD_ALGORITHM, SLIM_CURVE_LMA_ALGORITHM, SLIM_CURVE_RLD_LMA_ALGORITHM }; 113 122 private static final String FUNCTION_ITEMS[] = { SINGLE_EXPONENTIAL, DOUBLE_EXPONENTIAL, TRIPLE_EXPONENTIAL, STRETCHED_EXPONENTIAL }; 123 124 private static final String EXCITATION_ITEMS[] = { EXCITATION_NONE, EXCITATION_FILE, EXCITATION_CREATE }; 114 125 115 126 public IUserInterfacePanelListener m_listener; 127 128 private ExcitationPanel m_excitationPanel; 116 129 117 130 int m_fittedParameterCount = 0; … … 135 148 JTextField m_thresholdField; 136 149 JComboBox m_binningComboBox; 150 JComboBox m_excitationComboBox; 137 151 138 152 // parameter panel … … 145 159 JTextField m_tParam1; 146 160 JCheckBox m_tFix1; 147 JTextField m_ cParam1;148 JCheckBox m_ cFix1;161 JTextField m_zParam1; 162 JCheckBox m_zFix1; 149 163 JTextField m_chiSqParam1; 150 164 JCheckBox m_startParam1; … … 159 173 JTextField m_t2Param2; 160 174 JCheckBox m_t2Fix2; 161 JTextField m_ cParam2;162 JCheckBox m_ cFix2;175 JTextField m_zParam2; 176 JCheckBox m_zFix2; 163 177 JTextField m_chiSqParam2; 164 178 JCheckBox m_startParam2; … … 177 191 JTextField m_t3Param3; 178 192 JCheckBox m_t3Fix3; 179 JTextField m_ cParam3;180 JCheckBox m_ cFix3;193 JTextField m_zParam3; 194 JCheckBox m_zFix3; 181 195 JTextField m_chiSqParam3; 182 196 JCheckBox m_startParam3; … … 189 203 JTextField m_hParam4; 190 204 JCheckBox m_hFix4; 191 JTextField m_ cParam4;192 JCheckBox m_ cFix4;205 JTextField m_zParam4; 206 JCheckBox m_zFix4; 193 207 JTextField m_chiSqParam4; 194 208 JCheckBox m_startParam4; … … 317 331 fitPanel.add(algorithmLabel); 318 332 m_algorithmComboBox = new JComboBox(ALGORITHM_ITEMS); 319 m_algorithmComboBox.setSelectedItem(SLIM_CURVE_ LMA_ALGORITHM);333 m_algorithmComboBox.setSelectedItem(SLIM_CURVE_RLD_LMA_ALGORITHM); 320 334 fitPanel.add(m_algorithmComboBox); 321 335 … … 354 368 } 355 369 370 float[] m_values = null; 371 356 372 /* 357 373 * Creates a panel that has some settings that control the fit. … … 398 414 controlPanel.add(m_binningComboBox); 399 415 416 JLabel excitationLabel = new JLabel("Excitation"); 417 excitationLabel.setHorizontalAlignment(SwingConstants.RIGHT); 418 controlPanel.add(excitationLabel); 419 m_excitationComboBox = new JComboBox(EXCITATION_ITEMS); 420 m_excitationComboBox.addActionListener( 421 new ActionListener() { 422 public void actionPerformed(ActionEvent e) { 423 Excitation excitation = null; 424 425 String selectedItem = (String) m_excitationComboBox.getSelectedItem(); 426 System.out.println("selected " + selectedItem); 427 if (EXCITATION_NONE.equals(selectedItem)) { 428 if (null != m_excitationPanel) { 429 m_excitationPanel.quit(); 430 m_excitationPanel = null; 431 } 432 } 433 else if (EXCITATION_FILE.equals(selectedItem)) { 434 String fileName = getFileName("Load Excitation File", ""); 435 if (null != fileName) { 436 excitation = ExcitationFileHandler.getInstance().loadExcitation(fileName); 437 } 438 if (null != excitation) { 439 m_values = excitation.getValues(); 440 } 441 } 442 else if (EXCITATION_CREATE.equals(selectedItem)) { 443 String fileName = getFileName("Save Excitation File", ""); 444 if (null != fileName) { 445 if (null != m_values) { 446 excitation = ExcitationFileHandler.getInstance().createExcitation(fileName, m_values); 447 } 448 } 449 } 450 451 if (null == excitation) { 452 m_excitationComboBox.setSelectedItem(EXCITATION_NONE); 453 } 454 else { 455 m_excitationComboBox.setSelectedItem(EXCITATION_FILE); 456 m_excitationPanel = new ExcitationPanel(excitation); 457 } 458 } 459 } 460 ); 461 controlPanel.add(m_excitationComboBox); 462 400 463 // rows, cols, initX, initY, xPad, yPad 401 SpringUtilities.makeCompactGrid(controlPanel, 6, 2, 4, 4, 4, 4);464 SpringUtilities.makeCompactGrid(controlPanel, 7, 2, 4, 4, 4, 4); 402 465 403 466 JPanel panel = new JPanel(new BorderLayout()); … … 435 498 expPanel.add(m_tFix1); 436 499 437 JLabel cLabel1 = new JLabel("C");438 cLabel1.setHorizontalAlignment(SwingConstants.RIGHT);439 expPanel.add( cLabel1);440 m_ cParam1 = new JTextField(9);441 //m_ cParam1.setEditable(false);442 expPanel.add(m_ cParam1);443 m_ cFix1 = new JCheckBox("Fix");444 //m_ cFix1.addItemListener(this);445 expPanel.add(m_ cFix1);500 JLabel zLabel1 = new JLabel("Z"); 501 zLabel1.setHorizontalAlignment(SwingConstants.RIGHT); 502 expPanel.add(zLabel1); 503 m_zParam1 = new JTextField(9); 504 //m_zParam1.setEditable(false); 505 expPanel.add(m_zParam1); 506 m_zFix1 = new JCheckBox("Fix"); 507 //m_zFix1.addItemListener(this); 508 expPanel.add(m_zFix1); 446 509 447 510 JLabel chiSqLabel1 = new JLabel("" + CHI + SQUARE); … … 459 522 //m_a1Param1.setBackground(floatColor); 460 523 //m_t1Param1.setBackground(floatColor); 461 //m_ cParam1.setBackground(floatColor);524 //m_zParam1.setBackground(floatColor); 462 525 //m_chiSqParam1.setBackground(floatColor); 463 526 … … 524 587 expPanel.add(m_t2Fix2); 525 588 526 JLabel cLabel2 = new JLabel("C");527 cLabel2.setHorizontalAlignment(SwingConstants.RIGHT);528 expPanel.add( cLabel2);529 m_ cParam2 = new JTextField(9);530 //m_ cParam2.setEditable(false);531 expPanel.add(m_ cParam2);532 m_ cFix2 = new JCheckBox("Fix");533 //m_ cFix2.addItemListener(this);534 expPanel.add(m_ cFix2);589 JLabel zLabel2 = new JLabel("Z"); 590 zLabel2.setHorizontalAlignment(SwingConstants.RIGHT); 591 expPanel.add(zLabel2); 592 m_zParam2 = new JTextField(9); 593 //m_zParam2.setEditable(false); 594 expPanel.add(m_zParam2); 595 m_zFix2 = new JCheckBox("Fix"); 596 //m_zFix2.addItemListener(this); 597 expPanel.add(m_zFix2); 535 598 536 599 JLabel chiSqLabel2 = new JLabel("" + CHI + SQUARE); … … 550 613 //m_a2Param2.setBackground(floatColor); 551 614 //m_t2Param2.setBackground(floatColor); 552 //m_ cParam2.setBackground(floatColor);615 //m_zParam2.setBackground(floatColor); 553 616 //m_chiSqParam2.setBackground(floatColor); 554 617 … … 634 697 expPanel.add(m_t3Fix3); 635 698 636 JLabel cLabel3 = new JLabel("C");637 cLabel3.setHorizontalAlignment(SwingConstants.RIGHT);638 expPanel.add( cLabel3);639 m_ cParam3 = new JTextField(9);640 //m_ cParam3.setEditable(false);641 expPanel.add(m_ cParam3);642 m_ cFix3 = new JCheckBox("Fix");643 //m_ cFix3.addItemListener(this);644 expPanel.add(m_ cFix3);699 JLabel zLabel3 = new JLabel("Z"); 700 zLabel3.setHorizontalAlignment(SwingConstants.RIGHT); 701 expPanel.add(zLabel3); 702 m_zParam3 = new JTextField(9); 703 //m_zParam3.setEditable(false); 704 expPanel.add(m_zParam3); 705 m_zFix3 = new JCheckBox("Fix"); 706 //m_zFix3.addItemListener(this); 707 expPanel.add(m_zFix3); 645 708 646 709 … … 663 726 //m_a3Param3.setBackground(floatColor); 664 727 //m_t3Param3.setBackground(floatColor); 665 //m_ cParam3.setBackground(floatColor);728 //m_zParam3.setBackground(floatColor); 666 729 //m_chiSqParam3.setBackground(floatColor); 667 730 … … 717 780 expPanel.add(m_hFix4); 718 781 719 JLabel cLabel1 = new JLabel("C");720 cLabel1.setHorizontalAlignment(SwingConstants.RIGHT);721 expPanel.add( cLabel1);722 m_ cParam4 = new JTextField(9);723 //m_ cParam1.setEditable(false);724 expPanel.add(m_ cParam4);725 m_ cFix4 = new JCheckBox("Fix");726 //m_ cFix1.addItemListener(this);727 expPanel.add(m_ cFix4);782 JLabel zLabel1 = new JLabel("Z"); 783 zLabel1.setHorizontalAlignment(SwingConstants.RIGHT); 784 expPanel.add(zLabel1); 785 m_zParam4 = new JTextField(9); 786 //m_zParam1.setEditable(false); 787 expPanel.add(m_zParam4); 788 m_zFix4 = new JCheckBox("Fix"); 789 //m_zFix1.addItemListener(this); 790 expPanel.add(m_zFix4); 728 791 729 792 JLabel chiSqLabel4 = new JLabel("" + CHI + SQUARE); … … 741 804 //m_a1Param1.setBackground(floatColor); 742 805 //m_t1Param1.setBackground(floatColor); 743 //m_ cParam1.setBackground(floatColor);806 //m_zParam1.setBackground(floatColor); 744 807 //m_chiSqParam1.setBackground(floatColor); 745 808 … … 798 861 m_tParam1.setEditable(enable); 799 862 m_tFix1.setEnabled(enable); 800 m_ cParam1.setEditable(enable);801 m_ cFix1.setEnabled(enable);863 m_zParam1.setEditable(enable); 864 m_zFix1.setEnabled(enable); 802 865 803 866 // double exponent fit … … 810 873 m_t2Param2.setEditable(enable); 811 874 m_t2Fix2.setEnabled(enable); 812 m_ cParam2.setEditable(enable);813 m_ cFix2.setEnabled(enable);875 m_zParam2.setEditable(enable); 876 m_zFix2.setEnabled(enable); 814 877 815 878 // triple exponent fit … … 826 889 m_t3Param3.setEditable(enable); 827 890 m_t3Fix3.setEnabled(enable); 828 m_ cParam3.setEditable(enable);829 m_ cFix3.setEnabled(enable);891 m_zParam3.setEditable(enable); 892 m_zFix3.setEnabled(enable); 830 893 831 894 // stretched exonent fit … … 836 899 m_hParam4.setEditable(enable); 837 900 m_hFix4.setEnabled(enable); 838 m_ cParam4.setEditable(enable);839 m_ cFix4.setEnabled(enable);901 m_zParam4.setEditable(enable); 902 m_zFix4.setEnabled(enable); 840 903 841 904 if (enable) { … … 879 942 else if (selected.equals(SLIM_CURVE_LMA_ALGORITHM)) { 880 943 algorithm = FitAlgorithm.SLIMCURVE_LMA; 944 } 945 else if (selected.equals(SLIM_CURVE_RLD_LMA_ALGORITHM)) { 946 algorithm = FitAlgorithm.SLIMCURVE_RLD_LMA; 881 947 } 882 948 return algorithm; … … 984 1050 parameters[2] = Double.valueOf(m_aParam1.getText()); 985 1051 parameters[3] = Double.valueOf(m_tParam1.getText()); 986 parameters[1] = Double.valueOf(m_ cParam1.getText());1052 parameters[1] = Double.valueOf(m_zParam1.getText()); 987 1053 } 988 1054 else if (function.equals(DOUBLE_EXPONENTIAL)) { … … 992 1058 parameters[4] = Double.valueOf(m_a2Param2.getText()); 993 1059 parameters[5] = Double.valueOf(m_t2Param2.getText()); 994 parameters[1] = Double.valueOf(m_ cParam2.getText());1060 parameters[1] = Double.valueOf(m_zParam2.getText()); 995 1061 } 996 1062 else if (function.equals(TRIPLE_EXPONENTIAL)) { … … 1002 1068 parameters[6] = Double.valueOf(m_a3Param3.getText()); 1003 1069 parameters[7] = Double.valueOf(m_t3Param3.getText()); 1004 parameters[1] = Double.valueOf(m_ cParam3.getText());1070 parameters[1] = Double.valueOf(m_zParam3.getText()); 1005 1071 } 1006 1072 else if (function.equals(STRETCHED_EXPONENTIAL)) { … … 1009 1075 parameters[3] = Double.valueOf(m_tParam4.getText()); 1010 1076 parameters[4] = Double.valueOf(m_hParam4.getText()); 1011 parameters[1] = Double.valueOf(m_ cParam4.getText());1077 parameters[1] = Double.valueOf(m_zParam4.getText()); 1012 1078 } 1013 1079 parameters[0] = 0.0; … … 1020 1086 m_aParam1.setText ("" + (float) params[2]); 1021 1087 m_tParam1.setText ("" + (float) params[3]); 1022 m_ cParam1.setText ("" + (float) params[1]);1088 m_zParam1.setText ("" + (float) params[1]); 1023 1089 m_chiSqParam1.setText("" + (float) params[0]); 1024 1090 } … … 1028 1094 m_a2Param2.setText ("" + (float) params[4]); 1029 1095 m_t2Param2.setText ("" + (float) params[5]); 1030 m_ cParam2.setText ("" + (float) params[1]);1096 m_zParam2.setText ("" + (float) params[1]); 1031 1097 m_chiSqParam2.setText("" + (float) params[0]); 1032 1098 } … … 1038 1104 m_a3Param3.setText ("" + (float) params[6]); 1039 1105 m_t3Param3.setText ("" + (float) params[7]); 1040 m_ cParam3.setText ("" + (float) params[1]);1106 m_zParam3.setText ("" + (float) params[1]); 1041 1107 m_chiSqParam3.setText("" + (float) params[0]); 1042 1108 } … … 1045 1111 m_tParam4.setText ("" + (float) params[3]); 1046 1112 m_hParam4.setText ("" + (float) params[4]); 1047 m_ cParam4.setText ("" + (float) params[1]);1113 m_zParam4.setText ("" + (float) params[1]); 1048 1114 m_chiSqParam4.setText("" + (float) params[0]); 1049 1115 } … … 1055 1121 m_aParam1.setText ("" + (float) params[2]); 1056 1122 m_tParam1.setText ("" + (float) params[3]); 1057 m_ cParam1.setText ("" + (float) params[1]);1123 m_zParam1.setText ("" + (float) params[1]); 1058 1124 m_chiSqParam1.setText("" + (float) params[0]); 1059 1125 break; … … 1063 1129 m_a2Param2.setText ("" + (float) params[4]); 1064 1130 m_t2Param2.setText ("" + (float) params[5]); 1065 m_ cParam2.setText ("" + (float) params[1]);1131 m_zParam2.setText ("" + (float) params[1]); 1066 1132 m_chiSqParam2.setText("" + (float) params[0]); 1067 1133 break; … … 1073 1139 m_a3Param3.setText ("" + (float) params[6]); 1074 1140 m_t3Param3.setText ("" + (float) params[7]); 1075 m_ cParam3.setText ("" + (float) params[1]);1141 m_zParam3.setText ("" + (float) params[1]); 1076 1142 m_chiSqParam3.setText("" + (float) params[0]); 1077 1143 break; … … 1080 1146 m_tParam4.setText ("" + (float) params[1]); 1081 1147 m_hParam4.setText ("" + (float) params[2]); 1082 m_ cParam4.setText ("" + (float) params[1]);1148 m_zParam4.setText ("" + (float) params[1]); 1083 1149 m_chiSqParam4.setText("" + (float) params[0]); 1084 1150 break; … … 1093 1159 free[0] = !m_aFix1.isSelected(); 1094 1160 free[1] = !m_tFix1.isSelected(); 1095 free[2] = !m_ cFix1.isSelected();1161 free[2] = !m_zFix1.isSelected(); 1096 1162 } 1097 1163 else if (function.equals(DOUBLE_EXPONENTIAL)) { … … 1101 1167 free[2] = !m_a2Fix2.isSelected(); 1102 1168 free[3] = !m_t2Fix2.isSelected(); 1103 free[4] = !m_ cFix2.isSelected();1169 free[4] = !m_zFix2.isSelected(); 1104 1170 } 1105 1171 else if (function.equals(TRIPLE_EXPONENTIAL)) { … … 1111 1177 free[4] = !m_a3Fix3.isSelected(); 1112 1178 free[5] = !m_t3Fix3.isSelected(); 1113 free[6] = !m_ cFix3.isSelected();1179 free[6] = !m_zFix3.isSelected(); 1114 1180 1115 1181 } … … 1119 1185 free[1] = !m_tFix4.isSelected(); 1120 1186 free[2] = !m_hFix4.isSelected(); 1121 free[3] = !m_ cFix4.isSelected();1187 free[3] = !m_zFix4.isSelected(); 1122 1188 } 1123 1189 return free; … … 1165 1231 m_startParam4.setEnabled(enable); 1166 1232 } 1233 1234 private String getFileName(String title, String defaultFileName) { 1235 GenericDialog dialog = new GenericDialog(title); 1236 //TODO works with GenericDialogPlus, dialog.addFileField("File:", defaultFile, 24); 1237 dialog.addStringField("File", defaultFileName); 1238 dialog.showDialog(); 1239 if (dialog.wasCanceled()) { 1240 return null; 1241 } 1242 1243 return dialog.getNextString(); 1244 } 1167 1245 }
Note: See TracChangeset
for help on using the changeset viewer.