2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
* AnalysisFileView.java |
2 |
26 Feb 07 |
jari |
3 |
* |
2 |
26 Feb 07 |
jari |
* Created on January 29, 2004, 1:32 PM |
2 |
26 Feb 07 |
jari |
5 |
*/ |
2 |
26 Feb 07 |
jari |
6 |
|
2 |
26 Feb 07 |
jari |
7 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
8 |
|
2 |
26 Feb 07 |
jari |
9 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
10 |
|
2 |
26 Feb 07 |
jari |
11 |
import javax.swing.Icon; |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
import org.tigr.microarray.mev.cluster.gui.impl.GUIFactory; |
2 |
26 Feb 07 |
jari |
14 |
|
2 |
26 Feb 07 |
jari |
15 |
/** |
2 |
26 Feb 07 |
jari |
16 |
* |
2 |
26 Feb 07 |
jari |
* @author braisted |
2 |
26 Feb 07 |
jari |
18 |
*/ |
2 |
26 Feb 07 |
jari |
19 |
public class AnalysisFileView extends javax.swing.filechooser.FileView { |
2 |
26 Feb 07 |
jari |
20 |
|
2 |
26 Feb 07 |
jari |
21 |
private Icon analysisIcon = GUIFactory.getIcon("analysis16.gif"); |
2 |
26 Feb 07 |
jari |
22 |
|
2 |
26 Feb 07 |
jari |
23 |
|
2 |
26 Feb 07 |
jari |
/** Creates a new instance of AnalysisFileView */ |
2 |
26 Feb 07 |
jari |
25 |
public AnalysisFileView() { |
2 |
26 Feb 07 |
jari |
26 |
} |
2 |
26 Feb 07 |
jari |
27 |
|
2 |
26 Feb 07 |
jari |
28 |
public String getName(File f) { |
2 |
26 Feb 07 |
jari |
29 |
return null; // let the L&F FileView figure this out |
2 |
26 Feb 07 |
jari |
30 |
} |
2 |
26 Feb 07 |
jari |
31 |
|
2 |
26 Feb 07 |
jari |
32 |
public String getDescription(File f) { |
2 |
26 Feb 07 |
jari |
33 |
return null; // let the L&F FileView figure this out |
2 |
26 Feb 07 |
jari |
34 |
} |
2 |
26 Feb 07 |
jari |
35 |
|
2 |
26 Feb 07 |
jari |
36 |
public Boolean isTraversable(File f) { |
2 |
26 Feb 07 |
jari |
37 |
return null; // let the L&F FileView figure this out |
2 |
26 Feb 07 |
jari |
38 |
} |
2 |
26 Feb 07 |
jari |
39 |
|
2 |
26 Feb 07 |
jari |
40 |
public String getTypeDescription(File f) { |
2 |
26 Feb 07 |
jari |
41 |
String extension = getExtension(f); |
2 |
26 Feb 07 |
jari |
42 |
String type = null; |
2 |
26 Feb 07 |
jari |
43 |
|
2 |
26 Feb 07 |
jari |
44 |
if (extension != null) { |
2 |
26 Feb 07 |
jari |
45 |
if (extension.equals("anl")) { |
2 |
26 Feb 07 |
jari |
46 |
type = "MeV Analysis File"; |
2 |
26 Feb 07 |
jari |
47 |
} |
2 |
26 Feb 07 |
jari |
48 |
} |
2 |
26 Feb 07 |
jari |
49 |
return type; |
2 |
26 Feb 07 |
jari |
50 |
} |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
52 |
public Icon getIcon(File f) { |
2 |
26 Feb 07 |
jari |
53 |
String extension = getExtension(f); |
2 |
26 Feb 07 |
jari |
54 |
Icon icon = null; |
2 |
26 Feb 07 |
jari |
55 |
if (extension != null) { |
2 |
26 Feb 07 |
jari |
56 |
if (extension.equals("anl")) { |
2 |
26 Feb 07 |
jari |
57 |
icon = analysisIcon; |
2 |
26 Feb 07 |
jari |
58 |
} |
2 |
26 Feb 07 |
jari |
59 |
} |
2 |
26 Feb 07 |
jari |
60 |
return icon; |
2 |
26 Feb 07 |
jari |
61 |
} |
2 |
26 Feb 07 |
jari |
62 |
|
2 |
26 Feb 07 |
jari |
63 |
/** |
2 |
26 Feb 07 |
jari |
* Get the extension of a file. |
2 |
26 Feb 07 |
jari |
65 |
*/ |
2 |
26 Feb 07 |
jari |
66 |
private String getExtension(File f) { |
2 |
26 Feb 07 |
jari |
67 |
String ext = null; |
2 |
26 Feb 07 |
jari |
68 |
String s = f.getName(); |
2 |
26 Feb 07 |
jari |
69 |
int i = s.lastIndexOf('.'); |
2 |
26 Feb 07 |
jari |
70 |
if (i > 0 && i < s.length() - 1) { |
2 |
26 Feb 07 |
jari |
71 |
ext = s.substring(i+1).toLowerCase(); |
2 |
26 Feb 07 |
jari |
72 |
} |
2 |
26 Feb 07 |
jari |
73 |
return ext; |
2 |
26 Feb 07 |
jari |
74 |
} |
2 |
26 Feb 07 |
jari |
75 |
|
2 |
26 Feb 07 |
jari |
76 |
} |