/*************************************************************************** * Author: Jianwei (Jerry) Li * Name: GenepixVsTav (Version 1.0) * Date: Created: 04/02/2003 and modified: 04/04/2002 * Descp: A Java panel that is the interface for converting a ScanArray file format * to Tav and Mev format. ***************************************************************************/ package org.tigr.microarray.converter; import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.event.*; import javax.swing.Timer; import org.tigr.util.awt.GBA; import org.tigr.util.*; import org.tigr.util.io.IOUtil; public class ScanArrayPanel extends ConvertPanel { private JComboBox intensityModeCombx; private JPanel intensityPanel; private JCheckBox keepAllCB, gSwapChanCB; private JList gInputFileList; private JLabel intensityLB; // variable declare private String gfName; // GenePix file name private String tfName; // tav file name private String info; private int quantWay; private boolean keepAll, gSwapChan; private final String NUM_FILE = " Number of Files: "; private final String INTEN_MODE[] = {"Total", "Mean", "Mode", "Median"}; private final int TOTAL = 0; private final int MEAN = 1; private final int MODE = 2; private final int MEDIAN = 3; public ScanArrayPanel(ExpressConverter convt) { super(convt); keepAll = false; gSwapChan = false; quantWay = TOTAL; info = new String(""); createGUI(); } /**************************************************************************** * Description: * alters the interface to meet the requirement for output file type. *
Parameter:
* Paramters:
* Parameter:
* Parameters:
* Return: the selected file.
***************************************************************************/
private File getFile(String ext, String fileType, String path) {
int result;
File temp;
JFileChooser fileChooser;
fileChooser = new JFileChooser(path);
MadamFileFilter wanted = new MadamFileFilter(ext, fileType);
fileChooser.setFileFilter(wanted);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setDialogTitle("Save Output As");
fileChooser.setMultiSelectionEnabled(false);
result = fileChooser.showSaveDialog(this);
if(result == JFileChooser.CANCEL_OPTION) {
return null;
}
temp = fileChooser.getSelectedFile();
return temp;
}
/*****************************************************************************
* Description:
* create a GUI for program
****************************************************************************/
protected void createGUI(){
this.setLayout(new GridBagLayout());
gInputFileLB = new JLabel("ScanArray Files:");
gInputFileList = new JList();
gInputFileList.setBorder(gLow);
actionHandler(gInputFileList);
actionHandler(gOutputFileList);
gFilesSP = new JScrollPane(gInputFileList);
intensityLB = new JLabel("Intensity Generated By:");
intensityPanel = new JPanel(new GridBagLayout());
gSwapChanCB = new JCheckBox("Swap Channel");
gSwapChanCB.setToolTipText("If file has channel 1 as Cy5, swap it as Cy3.");
gSwapChanCB.setSelected(gSwapChan);
gSwapChanCB.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ce){
if(gSwapChanCB.isSelected()){
gSwapChan = true;
} else {
gSwapChan = false;
}
}
});
intensityModeCombx = new JComboBox(INTEN_MODE);
intensityModeCombx.setBorder(gLow);
intensityModeCombx.setPreferredSize(new Dimension(80, 23));
intensityModeCombx.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent ie){
quantWay = intensityModeCombx.getSelectedIndex();
}
});
keepAllCB = new JCheckBox("Keep All Information in the ScanArray File.");
keepAllCB.setToolTipText("Attach all anotation info at the end.");
keepAllCB.setSelected(keepAll);
keepAllCB.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ce){
if(keepAllCB.isSelected()){
keepAll = true;
} else {
keepAll = false;
}
}
});
gba.add(this, gFileSplitPane, 0, 0, 2, 1, 1, 1, GBA.B, GBA.C, 5, 5, 10, 5);
gba.add(this, sortCB, 0, 1, 1, 1, 1, 0, GBA.H, GBA.C, 10, 15, 3, 5);
gba.add(this, keepAllCB, 0, 2, 1, 1, 1, 0, GBA.H, GBA.C, 3, 15, 3, 5);
gba.add(this, gIntenPanel, 1, 1, 1, 2, 1, 0, GBA.H, GBA.W, 10, 0, 3, 5);
gba.add(intensityPanel, intensityLB, 0, 0, 1, 1, 1, 0, GBA.H, GBA.W, 0, 0, 0, 5);
gba.add(intensityPanel, intensityModeCombx, 1, 0, 1, 1, 0, 0, GBA.NONE, GBA.E, 0, 5, 0, 10);
gba.add(intensityPanel, gSwapChanCB, 2, 0, 1, 1, 0, 0, GBA.NONE, GBA.E, 0, 5, 0, 2);
gba.add(gInputPL, gInputFileLB, 0, 0, 1, 1, 1, 0, GBA.H, GBA.C, 5, 10, 5, 2);
gba.add(gInputPL, intensityPanel, 1, 0, 1, 1, 0, 0, GBA.NONE, GBA.C, 5, 0, 5, 5);
gba.add(gInputPL, gFilesSP, 0, 1, 2, 1, 1, 1, GBA.B, GBA.C, 1, 2, 5, 2);
}
}
index -- the selected index of the combobox.
***************************************************************************/
public void adjustGUI(int index){
int numFiles;
String tmpName = new String("");
outputType = index;
if(outputType == TAV_OUT){
gOutputFileLB.setText(TAV_FILE);
keepAllCB.setEnabled(true);
this.activeIntensityWay(false);
} else {
gOutputFileLB.setText(MEV_FILE);
keepAllCB.setEnabled(false);
this.activeIntensityWay(true);
}
numFiles = outputFileNames.size();
for(int i=0; i
inFiles -- the input files.
*
outFiles -- the output files.
***************************************************************************/
public void changeFileList(Vector inFiles, Vector outFiles){
selectedFiles = inFiles;
outputFileNames = outFiles;
gInputFileList.setListData(inFiles);
gOutputFileList.setListData(outFiles);
gFileNumLB.setText(NUM_FILE + selectedFiles.size());
}
/****************************************************************************
* Description:
* modifies the output file names.
*
path -- the new directory.
***************************************************************************/
public void editDirectory(String path){
int selected = -1;
int num;
String tempName, tempPath;
tempPath = path;
selected = gOutputFileList.getSelectedIndex();
num = outputFileNames.size();
for(int i=0; i
ext -- file name extension;
*
fileType -- describe the file type;
*
path --- the path selected file is located at.
*