2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 import javax.swing.filechooser.*;
27 public class JalviewFileView extends FileView
29 static Hashtable alignSuffix = new Hashtable();
33 alignSuffix.put("fasta", "Fasta file");
34 alignSuffix.put("fa", "Fasta file");
35 alignSuffix.put("fastq", "Fasta file");
36 alignSuffix.put("blc", "BLC file");
37 alignSuffix.put("msf", "MSF file");
38 alignSuffix.put("pfam", "PFAM file");
39 alignSuffix.put("aln", "Clustal file");
40 alignSuffix.put("pir", "PIR file");
41 alignSuffix.put("jar", "Jalview file");
44 public String getTypeDescription(File f)
46 String extension = getExtension(f);
49 if (extension != null)
51 if (alignSuffix.containsKey(extension))
53 type = alignSuffix.get(extension).toString();
60 public Icon getIcon(File f)
62 String extension = getExtension(f);
65 if (extension != null)
67 if (alignSuffix.containsKey(extension))
69 icon = createImageIcon("/images/file.png");
77 * Get the extension of a file.
79 public static String getExtension(File f)
82 String s = f.getName();
83 int i = s.lastIndexOf('.');
85 if ((i > 0) && (i < (s.length() - 1)))
87 ext = s.substring(i + 1).toLowerCase();
93 /** Returns an ImageIcon, or null if the path was invalid. */
94 protected static ImageIcon createImageIcon(String path)
96 java.net.URL imgURL = JalviewFileView.class.getResource(path);
100 return new ImageIcon(imgURL);
105 .println("JalviewFileView.createImageIcon: Couldn't find file: "