/*************************************************************************** * 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: *
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; iDescription: * changes the number of input and output files based on testing on the * system to see if an exsiting file is to be overwritten. *

Paramters: *
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. *

Parameter: *
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=0){ gOutputFileList.setSelectedIndex(selected); } else { gOutputFileList.setSelectedIndex(0); } } /**************************************************************************** * Description: * modifies the output file names. ***************************************************************************/ public void editFileName(){ int selected = -1; String tempName; selected = gOutputFileList.getSelectedIndex(); if(selected >= 0){ tempName = (String)(gOutputFileList.getModel()).getElementAt(selected); LongTextChanger changer = new LongTextChanger(parent, true, tempName); changer.setTitle(parent.TITLE); changer.show(); if(changer.isTextChanged()){ tempName = changer.getText(); StringTokenizer token = new StringTokenizer(tempName, ":"); if(token.countTokens() <= 1){ tempName = "c:\\" + tempName; } tempName = IOUtil.dropExtension(tempName); if(tempName.lastIndexOf('.') == tempName.length()-1){ tempName += FILE_TYPE[outputType]; } else { tempName += "." + FILE_TYPE[outputType]; } outputFileNames.setElementAt(tempName, selected); gOutputFileList.setListData(outputFileNames); gOutputFileList.setSelectedIndex(selected); } } } public Vector getOutputFileNames() { return outputFileNames; } public int getQuantiationWay() { return quantWay; } public Vector getSelectedFiles() { return selectedFiles; } public boolean isOutputReady() { return outputReady; } public boolean keepAllInformation() { return keepAll; } public boolean swapOriginalChannel() { return gSwapChan; } /*************************************************************************** * Description: * removes a set of files from the selected list. ***************************************************************************/ public void removeFileFromList(){ int addrs[], i, indx; addrs = gOutputFileList.getSelectedIndices(); if(addrs.length > 0){ for(i=0; i 0){ gOutputFileList.setSelectedIndex(0); } gFileNumLB.setText(NUM_FILE + selectedFiles.size()); } } /**************************************************************************** * Description: * set the interface to its original status. **************************************************************************/ public void reset(){ selectedFiles.removeAllElements(); outputFileNames.removeAllElements(); gFileNumLB.setText(NUM_FILE); gInputFileList.setListData(selectedFiles); gOutputFileList.setListData(outputFileNames); wantSort = true; keepAll = false; outputReady = false; gSwapChan = false; sortCB.setSelected(wantSort); keepAllCB.setSelected(keepAll); gSwapChanCB.setSelected(gSwapChan); parent.activateButton(outputReady, outputReady); } /*************************************************************************** * Description: * places the selected file names to both genepix and output file lists. **************************************************************************/ public void setSelectedFiles(String[] newFiles){ int num, i; String temp = new String(""); num = newFiles.length; for(i=0; iDescription: * finds a selected file as a File object *

Parameters: *
ext -- file name extension; *
fileType -- describe the file type; *
path --- the path selected file is located at. *

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); } }