mev-4.0.01/source/org/tigr/microarray/mev/cluster/gui/impl/svm/SVMFileView.java

Code
Comments
Other
Rev Date Author Line
2 26 Feb 07 jari 1 /*
2 26 Feb 07 jari 2 Copyright @ 1999-2003, The Institute for Genomic Research (TIGR).
2 26 Feb 07 jari 3 All rights reserved.
2 26 Feb 07 jari 4 */
2 26 Feb 07 jari 5 /*
2 26 Feb 07 jari 6  * $RCSfile: SVMFileView.java,v $
2 26 Feb 07 jari 7  * $Revision: 1.3 $
2 26 Feb 07 jari 8  * $Date: 2005/03/10 20:21:56 $
2 26 Feb 07 jari 9  * $Author: braistedj $
2 26 Feb 07 jari 10  * $State: Exp $
2 26 Feb 07 jari 11  */
2 26 Feb 07 jari 12
2 26 Feb 07 jari 13 package org.tigr.microarray.mev.cluster.gui.impl.svm;
2 26 Feb 07 jari 14
2 26 Feb 07 jari 15 import java.io.File;
2 26 Feb 07 jari 16
2 26 Feb 07 jari 17 import javax.swing.Icon;
2 26 Feb 07 jari 18 import javax.swing.filechooser.FileView;
2 26 Feb 07 jari 19
2 26 Feb 07 jari 20 import org.tigr.microarray.mev.cluster.gui.impl.GUIFactory;
2 26 Feb 07 jari 21
2 26 Feb 07 jari 22 public class SVMFileView extends FileView {
2 26 Feb 07 jari 23
2 26 Feb 07 jari 24     private Icon SVMIcon = GUIFactory.getIcon("svmfileicon.gif");
2 26 Feb 07 jari 25
2 26 Feb 07 jari 26     public String getName(File f) {
2 26 Feb 07 jari 27         return null; // let the L&F FileView figure this out
2 26 Feb 07 jari 28     }
2 26 Feb 07 jari 29
2 26 Feb 07 jari 30     public String getDescription(File f) {
2 26 Feb 07 jari 31         return null; // let the L&F FileView figure this out
2 26 Feb 07 jari 32     }
2 26 Feb 07 jari 33
2 26 Feb 07 jari 34     public Boolean isTraversable(File f) {
2 26 Feb 07 jari 35         return null; // let the L&F FileView figure this out
2 26 Feb 07 jari 36     }
2 26 Feb 07 jari 37
2 26 Feb 07 jari 38     public String getTypeDescription(File f) {
2 26 Feb 07 jari 39         String extension = getExtension(f);
2 26 Feb 07 jari 40         String type = null;
2 26 Feb 07 jari 41
2 26 Feb 07 jari 42         if (extension != null) {
2 26 Feb 07 jari 43             if (extension.equals("svm")) {
2 26 Feb 07 jari 44                 type = "SVM File";
2 26 Feb 07 jari 45             }
2 26 Feb 07 jari 46         }
2 26 Feb 07 jari 47         return type;
2 26 Feb 07 jari 48     }
2 26 Feb 07 jari 49
2 26 Feb 07 jari 50     public Icon getIcon(File f) {
2 26 Feb 07 jari 51         String extension = getExtension(f);
2 26 Feb 07 jari 52         Icon icon = null;
2 26 Feb 07 jari 53         if (extension != null) {
2 26 Feb 07 jari 54             if (extension.equals("svm")) {
2 26 Feb 07 jari 55                 icon = SVMIcon;
2 26 Feb 07 jari 56             }
2 26 Feb 07 jari 57         }
2 26 Feb 07 jari 58         return icon;
2 26 Feb 07 jari 59     }
2 26 Feb 07 jari 60
2 26 Feb 07 jari 61     /**
2 26 Feb 07 jari 62      * Get the extension of a file.
2 26 Feb 07 jari 63      */
2 26 Feb 07 jari 64     private String getExtension(File f) {
2 26 Feb 07 jari 65         String ext = null;
2 26 Feb 07 jari 66         String s = f.getName();
2 26 Feb 07 jari 67         int i = s.lastIndexOf('.');
2 26 Feb 07 jari 68         if (i > 0 &&  i < s.length() - 1) {
2 26 Feb 07 jari 69             ext = s.substring(i+1).toLowerCase();
2 26 Feb 07 jari 70         }
2 26 Feb 07 jari 71         return ext;
2 26 Feb 07 jari 72     }
2 26 Feb 07 jari 73 }